/* 全局重置与基础变量 */
:root {
    --bg-color: #0a0a0c;
    --panel-bg: rgba(20, 20, 25, 0.7);
    --neon-yellow: #fcee0a;
    --neon-cyan: #00f0ff;
    --text-main: #e0e0e0;
    --text-muted: #666677;
    --border-color: rgba(0, 240, 255, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Share Tech Mono', 'Noto Sans JP', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    background-image: linear-gradient(rgba(0,240,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,240,255,0.03) 1px, transparent 1px);
    background-size: 30px 30px;
}

/* 💻 电脑端布局 */
.app-container {
    display: flex;
    flex-direction: row; 
    height: 100vh;
    padding: 20px;
    gap: 20px;
}

.sidebar {
    width: 320px;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.05);
    overflow: hidden;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px 20px 10px 20px;
}

/* 搜索栏样式 */
.search-box {
    padding: 0 20px 15px 20px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
}

.search-box input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-box input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.glitch-text {
    color: var(--neon-yellow);
    font-size: 1.5rem;
    letter-spacing: 2px;
    text-shadow: 2px 0 0 red, -2px 0 0 blue;
}

.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.channel-list::-webkit-scrollbar { width: 6px; }
.channel-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.channel-group { margin-bottom: 10px; }

/* 可折叠分类头部 */
.group-title {
    position: sticky;
    top: -15px;
    background: rgba(10, 10, 12, 0.95);
    color: var(--neon-cyan);
    padding: 8px 6px;
    font-size: 0.9rem;
    letter-spacing: 1px;
    z-index: 10;
    margin-bottom: 8px;
    backdrop-filter: blur(5px);
    border-bottom: 1px dashed var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    user-select: none;
    justify-content: space-between;
}

.group-title::after {
    content: '▼';
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.channel-group.collapsed .group-title::after {
    transform: rotate(-90deg);
}

.channel-group.collapsed .group-items-container {
    display: none;
}

.channel-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.channel-item:hover { background: rgba(0, 240, 255, 0.1); border-color: var(--neon-cyan); }
.channel-item.active {
    background: rgba(252, 238, 10, 0.1);
    border-left: 4px solid var(--neon-yellow);
    border-color: var(--neon-yellow);
}

.ch-logo {
    width: 45px;
    height: 45px;
    object-fit: contain;
    background: #fff;
    border-radius: 4px;
    margin-right: 12px;
    padding: 2px;
    flex-shrink: 0;
}

.ch-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    flex: 1;
    padding-right: 25px;
}

.ch-name { font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 跑马灯 */
.ch-epg-now {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}
.channel-item.active .ch-epg-now {
    color: rgba(252, 238, 10, 0.8);
}
.channel-item:hover .ch-epg-now {
    text-overflow: clip;
    overflow: visible;
    display: inline-block;
    min-width: max-content;
    animation: terminal-marquee 8s linear infinite;
}
@keyframes terminal-marquee {
    0% { transform: translateX(0); }
    15% { transform: translateX(0); }
    45% { transform: translateX(-40%); }
    55% { transform: translateX(-40%); }
    85% { transform: translateX(0); }
    100% { transform: translateX(0); }
}

/* 心形收藏图标样式 */
.heart-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    z-index: 5;
}

.heart-icon:hover {
    color: #ff4757;
    transform: translateY(-50%) scale(1.1);
}

.heart-icon.is-fav {
    color: #ff4757;
    text-shadow: 0 0 8px rgba(255, 71, 87, 0.4);
}

/* 🎬 播放器区域 */
.player-section {
    flex: 1;
    background: #000;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.video-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    background: #000;
}

#video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    outline: none;
    display: block;
}

.no-signal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #000; display: flex; justify-content: center; align-items: center;
    color: var(--neon-cyan); font-size: 1.5rem; z-index: 5; pointer-events: none;
}

.video-container.playing .no-signal { display: none; }
.no-signal span { animation: blink 2s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* 📊 新增：悬浮监控面板 UI 样式设计 */
.stats-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(10, 10, 14, 0.88);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 16px;
    border-radius: 8px;
    z-index: 10;
    width: 250px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85rem;
    color: #f0f0f0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.7);
    pointer-events: auto; /* 保证内部关闭按钮可以点击 */
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
    margin-bottom: 12px;
    color: var(--neon-yellow);
    font-weight: bold;
    letter-spacing: 1px;
}

.stats-close {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color 0.2s ease;
    padding: 0 4px;
}
.stats-close:hover { color: #ff4757; }

.stats-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}
.stats-label { color: #8a8a9a; }
.stats-val { color: var(--neon-cyan); font-weight: bold; }

/* 📅 EPG 全量节目面板 */
.epg-panel {
    height: 240px; 
    background: rgba(12, 12, 16, 0.95);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 12px 20px;
    box-sizing: border-box;
}

.epg-panel-header {
    color: var(--neon-cyan);
    font-size: 0.85rem;
    letter-spacing: 1px;
    margin-bottom: 10px;
    border-bottom: 1px dashed rgba(0, 240, 255, 0.2);
    padding-bottom: 4px;
}

.epg-timeline {
    flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth; 
}
.epg-timeline::-webkit-scrollbar { width: 4px; }
.epg-timeline::-webkit-scrollbar-thumb { background: rgba(0, 240, 255, 0.2); }

.epg-empty { color: var(--text-muted); font-size: 0.9rem; font-style: italic; padding-top: 20px; }
.epg-date-header {
    color: var(--text-muted); font-size: 0.8rem; letter-spacing: 1px; font-weight: bold;
    padding: 10px 0 4px 0; margin-top: 6px; border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}
.epg-date-header:first-child { margin-top: 0; }

.epg-row {
    display: flex; align-items: center; padding: 8px 12px;
    background: rgba(255,255,255,0.01); border: 1px solid rgba(255,255,255,0.02);
    border-radius: 4px; transition: all 0.3s ease;
}

.epg-past { opacity: 0.35; }
.epg-future { opacity: 0.85; }
.epg-live {
    background: rgba(252, 238, 10, 0.08) !important;
    border: 1px solid var(--neon-yellow) !important;
    color: var(--neon-yellow);
    box-shadow: 0 0 15px rgba(252, 238, 10, 0.15);
    font-weight: bold;
}

.epg-time { font-weight: bold; width: 120px; font-size: 0.9rem; flex-shrink: 0; }
.epg-future .epg-time { color: var(--neon-cyan); }
.epg-live .epg-time { color: var(--neon-yellow); }
.epg-title { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.epg-blink-tag { color: var(--neon-yellow); margin-right: 8px; animation: live-blink 1.5s infinite; }
@keyframes live-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* 📱 移动端自适应布局 */
@media (max-width: 768px) {
    .app-container { flex-direction: column-reverse; padding: 0; gap: 0; }
    .main-content { width: 100%; height: auto; flex: none; }
    .video-container { height: 30vh; flex: none; }
    .epg-panel { height: 200px; }
    .sidebar { width: 100%; flex: 1; border-radius: 0; border: none; }
    .channel-item { padding: 12px; margin-bottom: 10px; }
    .ch-logo { width: 40px; height: 40px; }
    .ch-name { font-size: 1rem; }
    .stats-overlay { top: 10px; right: 10px; width: 200px; padding: 10px; font-size: 0.75rem; }
}

/* 🔒 登录面板基础设置 */
.login-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: var(--bg-color);
    background-image: linear-gradient(rgba(0,240,255,0.03) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(0,240,255,0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    display: flex; justify-content: center; align-items: center; z-index: 9999; padding: 20px;
}

.login-box {
    width: 100%; max-width: 450px; background: var(--panel-bg); backdrop-filter: blur(15px);
    border: 2px solid var(--border-color); border-radius: 8px; padding: 35px 30px; box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
    box-sizing: border-box;
}

.login-header { margin-bottom: 30px; text-align: center; }
.login-header h2 { font-size: 1.15rem; letter-spacing: 1px; }
.input-group { margin-bottom: 22px; display: flex; flex-direction: column; gap: 8px; }
.input-group label { color: var(--neon-cyan); font-size: 0.85rem; letter-spacing: 1px; font-weight: bold; }
.input-group input {
    background: rgba(0, 0, 0, 0.6); border: 1px solid var(--border-color); border-radius: 4px;
    padding: 12px 15px; color: var(--text-main); font-size: 1rem; outline: none; transition: all 0.3s ease;
}
.input-group input:focus { border-color: var(--neon-yellow); box-shadow: 0 0 10px rgba(252, 238, 10, 0.2); }

.login-error {
    color: #ff3333; font-size: 0.8rem; min-height: 20px; margin-bottom: 15px;
    letter-spacing: 0.5px; font-weight: bold; text-shadow: 1px 0 5px rgba(255, 0, 0, 0.2);
}

.login-btn {
    width: 100%; background: transparent; border: 1px dashed var(--neon-yellow);
    color: var(--neon-yellow); padding: 14px; font-size: 1.05rem; font-weight: bold;
    cursor: pointer; border-radius: 4px; transition: all 0.2s ease; letter-spacing: 1px;
}
.login-btn:hover { background: rgba(252, 238, 10, 0.1); box-shadow: 0 0 15px rgba(252, 238, 10, 0.25); border-style: solid; }

/* =========================================================
   🎛️ 彻底重构：极简高级流媒体控制按键栏 UI
========================================================= */
.terminal-control-bar {
    background: rgba(14, 14, 18, 0.95);
    padding: 10px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
}

.control-btn {
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.5px;
    outline: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.control-btn.btn-cyan {
    border: 1px solid rgba(0, 240, 255, 0.4);
    color: var(--neon-cyan);
}
.control-btn.btn-cyan:hover, 
.control-btn.btn-cyan.active-panel {
    background: var(--neon-cyan);
    color: #000;
    border-color: var(--neon-cyan);
    box-shadow: 0 0 14px rgba(0, 240, 255, 0.4);
    transform: translateY(-1px);
}

.control-btn.btn-yellow {
    border: 1px solid rgba(252, 238, 10, 0.4);
    color: var(--neon-yellow);
}
.control-btn.btn-yellow:hover,
.control-btn.btn-yellow.active-pip {
    background: var(--neon-yellow);
    color: #000;
    border-color: var(--neon-yellow);
    box-shadow: 0 0 14px rgba(252, 238, 10, 0.4);
    transform: translateY(-1px);
}

.control-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
    .terminal-control-bar { padding: 8px 15px; gap: 8px; }
    .control-btn { padding: 6px 12px; font-size: 0.75rem; }
}

/* =========================================================
   📺 四分屏（Multiview）核心布局与赛博朋克 UI 样式
========================================================= */
#multiview-box {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: #000;
    z-index: 6;
    gap: 6px;
    padding: 6px;
    box-sizing: border-box;
}

.multiview-slot {
    position: relative;
    background: #050508;
    border: 1px solid rgba(0, 240, 255, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

/* 🌟 焦点激活状态（青色高亮边框与内发光） */
.multiview-slot.active-focus {
    border: 2px solid var(--neon-cyan);
    box-shadow: inset 0 0 15px rgba(0, 240, 255, 0.4), 0 0 10px rgba(0, 240, 255, 0.2);
}

.multiview-slot video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
    background: #000;
}

.multiview-slot.has-stream video {
    display: block;
}

/* 中间大加号占位符 */
.slot-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    font-size: 3rem;
    cursor: pointer;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    transition: all 0.2s ease;
}

.slot-placeholder:hover {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
}

.multiview-slot.has-stream .slot-placeholder {
    display: none;
}

/* 右上角独立关闭按钮 */
.slot-close {
    position: absolute;
    top: 8px;
    right: 8px;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 0.85rem;
    z-index: 3;
    display: none;
    background: rgba(10, 10, 14, 0.85);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.multiview-slot.has-stream:hover .slot-close {
    display: block;
}

.slot-close:hover {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
    border-color: #ff4757;
}

/* 底部滑出式独立音频控制条 */
.slot-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(10, 10, 14, 0.85);
    backdrop-filter: blur(4px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    padding: 6px 12px;
    gap: 10px;
    transform: translateY(100%);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3;
    box-sizing: border-box;
}

.multiview-slot.has-stream:hover .slot-controls {
    transform: translateY(0);
}

.slot-mute-btn {
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
    transition: transform 0.1s;
}
.slot-mute-btn:active { transform: scale(0.9); }

.slot-volume-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    outline: none;
}

.slot-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--neon-cyan);
    cursor: pointer;
    box-shadow: 0 0 6px var(--neon-cyan);
}