/* ============================================================
   WebIPTV - 明亮温暖主题（Light & Warm）
   主色：暖橙 #F97316 / 琥珀 #F59E0B / 暖米白背景
   ============================================================ */

:root {
    --warm-bg-1: #FFF8F0;
    --warm-bg-2: #FFEFDD;
    --panel: #FFFDF9;
    --panel-border: #FFE3C6;
    --primary: #F97316;
    --primary-dark: #EA580C;
    --primary-soft: #FFF3E8;
    --amber: #F59E0B;
    --text-main: #3F2E21;
    --text-sub: #8A6F58;
    --text-light: #A8907B;
    --ok: #22A06B;
    --bad: #E4572E;
    --checking: #F59E0B;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(249, 115, 22, 0.10);
    --shadow-lg: 0 12px 40px rgba(120, 70, 20, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    background: linear-gradient(135deg, var(--warm-bg-1) 0%, var(--warm-bg-2) 100%);
    color: var(--text-main);
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Inter', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------- 整体布局 ---------- */
.app {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
    overflow: hidden;
}

/* ---------- 左侧频道列表 ---------- */
.sidebar {
    width: 350px;
    min-width: 350px;
    height: 100vh;
    background: linear-gradient(180deg, var(--panel) 0%, #FFF6EA 100%);
    border-right: 1.5px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    z-index: 30;
    box-shadow: 4px 0 24px rgba(249, 115, 22, 0.06);
    transition: margin-left 0.28s ease;
}
.sidebar.hidden { margin-left: -350px; }

.sidebar-header {
    padding: 18px 16px 10px 16px;
    border-bottom: 1px solid #FFEFDB;
}
.sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.22rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 0.02em;
}
.sidebar-title .logo {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, #FB923C, #F97316);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    box-shadow: 0 3px 10px rgba(249, 115, 22, 0.35);
}
.sidebar-title small {
    font-size: 0.75rem; font-weight: 400; color: var(--text-light);
    margin-left: auto;
    white-space: nowrap;
}

.search-box {
    margin-top: 12px;
    display: flex;
    align-items: center;
    background: #FFF1E0;
    border: 1.5px solid #FFE0BD;
    border-radius: 12px;
    padding: 0 12px;
    transition: border 0.2s, box-shadow 0.2s;
}
.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}
.search-box svg { color: var(--text-sub); flex-shrink: 0; }
.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 10px 10px;
    font-size: 0.98rem;
    color: var(--text-main);
}
.search-box input::placeholder { color: var(--text-light); }

.btn {
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.12s, box-shadow 0.18s, background 0.18s;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, #FB923C, var(--primary));
    color: #fff;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.32);
}
.btn-primary:hover { box-shadow: 0 6px 16px rgba(249, 115, 22, 0.42); }
.btn-soft {
    background: #FFE9D2;
    color: var(--primary-dark);
}
.btn-soft:hover { background: #FFDFBE; }

/* 列表统计 */
.channel-count {
    padding: 8px 18px 2px 18px;
    font-size: 0.8rem;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 6px;
}
.channel-count .badge {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-radius: 20px;
    padding: 1px 9px;
    font-weight: 700;
    font-size: 0.78rem;
}

/* 侧栏订阅地址条 */
.sub-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 16px 4px 16px;
    padding: 7px 8px 7px 10px;
    background: #FFF1E0;
    border: 1.5px solid #FFE0BD;
    border-radius: 10px;
}
.sub-bar .sub-label {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--primary-dark);
    flex-shrink: 0;
    background: #FFE9D2;
    border-radius: 8px;
    padding: 2px 8px;
}
.sub-bar input[type="text"] {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 0.74rem;
    color: var(--text-sub);
    outline: none;
}
.btn-sm { padding: 5px 10px; font-size: 0.76rem; }

/* 频道列表滚动区 */
.channel-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px 12px 16px 12px;
}
.channel-scroll::-webkit-scrollbar { width: 8px; }
.channel-scroll::-webkit-scrollbar-thumb {
    background: #FFD9B0;
    border-radius: 8px;
}
.channel-scroll::-webkit-scrollbar-track { background: transparent; }

/* 分组标题 */
.group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 8px 6px 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--primary-dark);
    cursor: pointer;
    user-select: none;
}
.group-title .arrow {
    transition: transform 0.2s;
    color: var(--amber);
    font-size: 0.7rem;
}
.group-title.collapsed .arrow { transform: rotate(-90deg); }
.group-title .g-count {
    font-size: 0.72rem;
    color: var(--text-light);
    background: #FFEEDC;
    border-radius: 20px;
    padding: 0 7px;
    font-weight: 600;
}
.group-title:hover { color: var(--primary); }

/* 频道项 */
.channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    margin-bottom: 4px;
    background: #FFFFFF;
    border: 1.5px solid #FFEFDB;
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.96rem;
    cursor: pointer;
    text-align: left;
    transition: border 0.16s, background 0.16s, box-shadow 0.16s;
    position: relative;
}
.channel-item:hover {
    border-color: #FDC68F;
    background: #FFF8F0;
    box-shadow: 0 3px 10px rgba(249, 115, 22, 0.10);
}
.channel-item.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.18);
}
.channel-item .ch-logo {
    width: 30px; height: 30px;
    object-fit: contain;
    border-radius: 8px;
    background: #FFF3E8;
    flex-shrink: 0;
    padding: 2px;
}
.channel-item .ch-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

/* 空状态 */
.empty-tip {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
    font-size: 0.95rem;
    line-height: 1.8;
}
.empty-tip .big { font-size: 1.1rem; font-weight: 600; color: var(--text-sub); }

/* ---------- 主播放区 ---------- */
.player-area {
    flex: 1;
    position: relative;
    background: #0D0A06;
    min-width: 0;
}
#player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    display: block;
}

/* 右侧浮动按钮（仅投屏，自动隐藏） */
.float-btns {
    position: absolute;
    top: 14px;
    right: 18px;
    display: flex;
    gap: 10px;
    z-index: 20;
}
.float-btn {
    width: 46px; height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.28);
    transition: transform 0.14s, box-shadow 0.18s, opacity 0.3s;
    color: #fff;
    /* 自动隐藏：静置后跟随播放器控件一起淡出 */
    opacity: 0;
    pointer-events: none;
}
body.ui-visible .float-btn { opacity: 1; pointer-events: auto; }
.float-btn:hover { transform: translateY(-2px); }
.float-btn:active { transform: scale(0.95); }
.float-btn.cast-btn {
    background: linear-gradient(135deg, #FB923C, #F97316);
    width: 40px; height: 40px;
}
.float-btn.cast-btn.connected {
    background: linear-gradient(135deg, #34D399, #10B981);
    animation: glow-green 1.6s ease-in-out infinite;
}
@keyframes glow-green {
    0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
    50% { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
}
.float-btn.cast-btn:disabled,
.float-btn.cast-btn.off {
    background: #B9A891;
    cursor: pointer;
}
/* 左侧：展开/收回频道列表按钮（独立定位） */
.float-btn.sidebar-toggle {
    position: absolute;
    top: 14px;
    left: 18px;
    background: rgba(20, 12, 4, 0.72);
    backdrop-filter: blur(8px);
    z-index: 20;
}

/* 全屏下的侧边栏收起按钮位置 */
.sidebar.hidden + .player-area .sidebar-toggle { display: flex; }

/* 通知 */
.notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 12, 4, 0.92);
    backdrop-filter: blur(8px);
    color: #FFF4E8;
    font-size: 1.02rem;
    border-radius: 14px;
    padding: 18px 28px;
    z-index: 1000;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    max-width: 80%;
}
.notification.show { opacity: 1; }
.notification .spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: #FB923C;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 投屏接收端提示浮层（默认隐藏，投屏成功时才显示） */
.cast-hint {
    display: none;
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 12, 4, 0.85);
    color: #FFE9D2;
    font-size: 0.86rem;
    padding: 10px 20px;
    border-radius: 22px;
    z-index: 25;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    max-width: 90%;
    line-height: 1.5;
}
.cast-hint b { color: #4ADE80; }

/* 加载浮层 */
.loading-mask {
    position: absolute;
    inset: 0;
    background: rgba(10, 6, 2, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #FFE9D2;
    font-size: 1rem;
    z-index: 15;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.loading-mask.show { opacity: 1; pointer-events: auto; }
.loading-mask .ring {
    width: 46px; height: 46px;
    border: 4px solid rgba(251,146,60,0.2);
    border-top-color: #FB923C;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: min(88vw, 380px);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.hidden { margin-left: -110%; }
    .float-btns { top: 12px; right: 12px; }
    .float-btn.sidebar-toggle { top: 12px; left: 12px; }
}


/* ---------- 投屏降级面板 ---------- */
.cast-fallback {
    position: absolute;
    inset: 0;
    background: rgba(30, 18, 6, 0.55);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.cast-fallback.show { display: flex; }
.cf-card {
    background: #FFFDF9;
    border: 1.5px solid var(--panel-border);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(80, 45, 10, 0.3);
    padding: 24px 26px;
    max-width: min(420px, 90vw);
    text-align: center;
    color: var(--text-main);
}
.cf-card h3 { color: var(--primary-dark); margin-bottom: 10px; font-size: 1.15rem; }
.cf-card p { font-size: 0.88rem; color: var(--text-sub); line-height: 1.7; margin-bottom: 14px; }
.cf-card .cf-tips {
    background: #FFF8F0;
    border: 1px solid #FFE8CE;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.82rem;
    color: var(--text-sub);
}
#qrBox { display: flex; justify-content: center; margin: 6px 0 12px 0; }
#qrBox img, #qrBox canvas { border-radius: 10px; border: 1px solid #FFE8CE; }
.cf-url {
    background: #FFF1E0;
    border: 1px dashed #FDBD7E;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 0.78rem;
    color: var(--text-sub);
    word-break: break-all;
    margin-bottom: 14px;
    text-align: left;
    max-height: 80px;
    overflow-y: auto;
}
.cf-actions { display: flex; gap: 10px; justify-content: center; }
