/* ========== IPTV Live — 深色主题 ========== */
:root {
  --bg: #0a0a0f;
  --bg-elev: #12121a;
  --bg-elev-2: #1a1a26;
  --bg-hover: #22222f;
  --border: #262635;
  --border-light: #33334a;
  --text: #e8e8f0;
  --text-dim: #9090a8;
  --text-faint: #606078;
  --accent: #6c5ce7;
  --accent-hover: #7d6ff0;
  --accent-glow: rgba(108, 92, 231, 0.25);
  --green: #00ce9d;
  --green-dim: rgba(0, 206, 157, 0.12);
  --orange: #f0932b;
  --orange-dim: rgba(240, 147, 43, 0.12);
  --red: #e74c3c;
  --red-dim: rgba(231, 76, 60, 0.12);
  --blue: #4a9eff;
  --blue-dim: rgba(74, 158, 255, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --topbar-h: 56px;
  --subbar-h: 44px;
  --footer-h: 32px;
  --sidebar-w: 300px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg: #f0f0f5;
  --bg-elev: #ffffff;
  --bg-elev-2: #f8f8fc;
  --bg-hover: #eaeaf2;
  --border: #e0e0ea;
  --border-light: #d0d0dc;
  --text: #1a1a2e;
  --text-dim: #5a5a70;
  --text-faint: #8a8aa0;
  --accent: #5b4bd4;
  --accent-hover: #4a3cc0;
  --accent-glow: rgba(91, 75, 212, 0.15);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ========== 顶栏 ========== */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
  position: relative;
}

.topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand-logo { font-size: 26px; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand-sub {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.5px;
}

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 480px;
  margin: 0 auto;
}

.search-box {
  position: relative;
  width: 100%;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
}

#searchInput {
  width: 100%;
  height: 34px;
  padding: 0 36px 0 36px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#searchInput::placeholder { color: var(--text-faint); }

.hint-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg-hover);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.engine-badge {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-elev-2);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-light);
}

.icon-btn svg { width: 16px; height: 16px; }

/* ========== 副栏 ========== */
.subbar {
  height: var(--subbar-h);
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.subbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
}

.stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.stat-item strong {
  color: var(--text);
  font-weight: 600;
}

.stat-sep { color: var(--text-faint); }

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-group {
  display: flex;
  gap: 4px;
  background: var(--bg-elev);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.chip {
  padding: 4px 12px;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.chip:hover { color: var(--text); }

.chip.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px var(--accent-glow);
}

.sort-group select {
  height: 28px;
  padding: 0 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.sort-group select:focus { border-color: var(--accent); }

/* ========== 布局 ========== */
.layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ========== 侧栏 ========== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.group-list {
  display: flex;
  gap: 2px;
  padding: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  scrollbar-width: none;
}

.group-list::-webkit-scrollbar { display: none; }

.group-chip {
  padding: 5px 12px;
  font-size: 12px;
  border: none;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.group-chip:hover { background: var(--bg-hover); color: var(--text); }

.group-chip.active {
  background: var(--accent);
  color: #fff;
}

.group-chip .count {
  font-size: 10px;
  opacity: 0.7;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  border-left: 3px solid transparent;
}

.channel-item:hover { background: var(--bg-hover); }

.channel-item.active {
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.channel-item.active .ch-name { color: var(--text); font-weight: 500; }

.ch-index {
  font-size: 11px;
  color: var(--text-faint);
  min-width: 28px;
  font-variant-numeric: tabular-nums;
}

.ch-name {
  font-size: 13px;
  color: var(--text-dim);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition);
}

.ch-badges {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.ch-badge {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.ch-badge.h264 { background: var(--green-dim); color: var(--green); }
.ch-badge.hevc { background: var(--orange-dim); color: var(--orange); }
.ch-badge.fav { background: var(--blue-dim); color: var(--blue); }

.ch-star {
  font-size: 12px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 2px;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
}

.channel-item:hover .ch-star,
.channel-item.active .ch-star { opacity: 1; }

.ch-star.on { color: #f1c40f; opacity: 1; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-faint);
  text-align: center;
  gap: 8px;
}

.empty-state .empty-icon { font-size: 36px; }

/* ========== 播放器区域 ========== */
.player-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.video-wrap {
  position: relative;
  flex: 1;
  background: #000;
  overflow: hidden;
  min-height: 0;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* 覆盖层 */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.3s;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.overlay-text {
  color: var(--text);
  font-size: 14px;
}

.overlay-sub {
  color: var(--text-faint);
  font-size: 12px;
}

/* HUD */
.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.hud.show { opacity: 1; }

.hud-row {
  display: flex;
  gap: 6px;
}

.hud-row-2 {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  gap: 10px;
}

.hud-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(0,0,0,0.6);
  color: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
}

/* 中央控制条 */
.center-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s;
}

.video-wrap:hover .center-controls,
.center-controls.show { opacity: 1; }

.ctrl-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.ctrl-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
}

.ctrl-btn svg { width: 18px; height: 18px; }

.play-btn {
  width: 48px;
  height: 48px;
}

.play-btn .ico-pause { display: none; }

.play-btn.playing .ico-play { display: none; }
.play-btn.playing .ico-pause { display: block; }

/* ========== 频道信息栏 ========== */
.channel-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ci-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.ci-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ci-group {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}

.ci-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.ci-engine {
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 8px;
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.star-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.star-btn:hover { border-color: var(--border-light); }

.star-btn.on { color: #f1c40f; border-color: rgba(241, 196, 15, 0.4); }

/* ========== 节目表 ========== */
.epg-panel {
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  max-height: 80px;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px 16px;
}

.epg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
}

.epg-hint { color: var(--text-faint); font-size: 11px; }

/* ========== 弹窗 ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal.show { opacity: 1; pointer-events: auto; }

.modal-box {
  width: 400px;
  max-width: 90vw;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal.show .modal-box { transform: scale(1); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 { font-size: 15px; font-weight: 600; }

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.modal-body { padding: 20px; }

.form-row { margin-bottom: 14px; }

.form-row label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: var(--accent); }

.form-row textarea { resize: vertical; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
}

.btn-ghost { background: var(--bg-elev-2); color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }

/* ========== 页脚 ========== */
.footer {
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.footer-sep { opacity: 0.4; }

/* ========== 响应式 ========== */
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }

  .brand-sub { display: none; }
  .engine-badge { display: none; }
  .hint-kbd { display: none; }

  .stats { font-size: 11px; }
  .stat-sep:nth-of-type(2) { display: none; }
  .stat-item:nth-of-type(3) { display: none; }
}

@media (max-width: 640px) {
  :root { --sidebar-w: 100%; }

  .sidebar {
    position: fixed;
    top: calc(var(--topbar-h) + var(--subbar-h));
    left: 0;
    bottom: calc(var(--footer-h) + 140px);
    width: 100%;
    z-index: 50;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .layout { flex-direction: column; }

  .player-area {
    margin-top: calc(var(--topbar-h) + var(--subbar-h) + 200px);
  }

  .subbar-inner { gap: 8px; }
  .filters { gap: 6px; }

  .epg-panel { display: none; }
}
