/* ========== TVBox Web 样式（暗色主题，仿 TVBox） ========== */
:root {
  --bg: #0f1419;
  --bg-elev: #1a1f29;
  --panel: #1e2430;
  --panel-hover: #252b38;
  --line: #2a3142;
  --text: #e6e9ef;
  --text-muted: #8b95a7;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-bg: rgba(59,130,246,.15);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 180px;
  --topbar-h: 56px;
  --shadow: 0 4px 20px rgba(0,0,0,.4);
}

/* 亮色主题 */
body.theme-light {
  --bg: #f5f6f8;
  --bg-elev: #ffffff;
  --panel: #ffffff;
  --panel-hover: #f0f4ff;
  --line: #e3e6ea;
  --text: #1f2933;
  --text-muted: #6b7280;
  --accent-bg: rgba(59,130,246,.08);
  --shadow: 0 4px 20px rgba(0,0,0,.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== 左侧导航 ========== */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 50;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  padding: 18px 16px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 16px;
}
.logo-icon { font-size: 22px; }
.nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px; margin-bottom: 4px;
  background: transparent; border: none; color: var(--text-muted);
  font-size: 14px; cursor: pointer; border-radius: var(--radius-sm);
  transition: all .15s; text-align: left;
}
.nav-item:hover { background: var(--panel-hover); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); }
.nav-item .icon { font-size: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--line); }
.version { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 8px; }

/* ========== 主区域 ========== */
.main {
  margin-left: var(--sidebar-w);
  height: 100vh;
  display: flex; flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  padding: 0 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h1 { font-size: 16px; font-weight: 600; }
.status-badge {
  padding: 3px 10px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text-muted);
}
.status-badge.ok { color: var(--success); border-color: var(--success); }
.topbar-right { display: flex; gap: 8px; }

/* ========== 播放器悬浮条（最上层，可拖动） ========== */
.player-bar {
  position: fixed; top: 70px; right: 20px; width: 480px; max-width: calc(100vw - 40px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,.6);
  /* 关键：z-index 高于所有弹窗（modal=1000）和 toast（2000），永远在最上层 */
  z-index: 9999;
  overflow: hidden; user-select: none;
}
.player-bar.hidden { display: none; }
/* 拖动手柄：player-info 区域作为拖动条 */
.player-info {
  padding: 8px 12px; font-size: 13px; color: var(--text-muted);
  cursor: move; border-top: 1px solid var(--line);
  background: var(--bg-elev); display: flex; align-items: center; gap: 8px;
}
.player-info .drag-hint { color: var(--text-muted); font-size: 11px; opacity: .6; margin-left: auto; }
.player-info b { color: var(--text); }
.player-wrapper { position: relative; background: #000; }
.player-wrapper video { width: 100%; display: block; max-height: 320px; background: #000; }
.player-status {
  position: absolute; left: 8px; top: 8px; padding: 4px 10px;
  background: rgba(0,0,0,.7); color: #fff; font-size: 12px;
  border-radius: 4px; display: none; pointer-events: none;
}
.player-status.show { display: block; }
.player-close, .player-fullscreen {
  position: absolute; top: 8px; padding: 4px 8px;
  background: rgba(0,0,0,.7); color: #fff; border: none;
  border-radius: 4px; cursor: pointer; font-size: 14px;
}
.player-close { right: 8px; }
.player-fullscreen { right: 40px; }
.player-bar.dragging { box-shadow: 0 12px 40px rgba(59,130,246,.4); opacity: .98; }

/* ========== 内容区 ========== */
.content { flex: 1; overflow-y: auto; padding: 20px; }
.panel { display: none; }
.panel.active { display: block; }

/* ========== 按钮 / 输入 ========== */
.btn {
  padding: 8px 14px; font-size: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--panel-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 10px 18px; font-size: 15px; }
.input, .select {
  padding: 8px 12px; font-size: 14px; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none;
  font-family: inherit;
}
.input:focus, .select:focus { border-color: var(--accent); }
.input-lg { padding: 10px 14px; }
.input { min-width: 120px; }

/* ========== 首页 ========== */
.hero {
  background: linear-gradient(135deg, var(--panel) 0%, var(--bg-elev) 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px 24px; margin-bottom: 20px; text-align: center;
}
.hero h2 { font-size: 24px; margin-bottom: 8px; }
.hero-sub { color: var(--text-muted); margin-bottom: 20px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.stat-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.stat-num { font-size: 24px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.section-title {
  font-size: 15px; font-weight: 600; margin: 20px 0 12px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}

/* ========== 工具条 ========== */
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 14px;
}
.toolbar .input, .toolbar .select { font-size: 13px; padding: 6px 10px; }
.page-info { color: var(--text-muted); font-size: 13px; padding: 0 4px; }

/* ========== 影视网格 ========== */
.vod-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.vod-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: all .15s;
}
.vod-card:hover {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(59,130,246,.25);
}
.vod-card .poster {
  position: relative; aspect-ratio: 2/3; background: var(--bg-elev);
  overflow: hidden;
}
.vod-card .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vod-card .poster .badge {
  position: absolute; right: 6px; top: 6px;
  padding: 2px 6px; background: rgba(0,0,0,.7); color: #fff;
  font-size: 11px; border-radius: 3px;
}
.vod-card .info { padding: 6px 8px; }
.vod-card .info .n { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vod-card .info .r { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.vod-card .fav-btn {
  position: absolute; left: 6px; bottom: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,.7); border: none; color: #fff;
  cursor: pointer; font-size: 14px; line-height: 24px; padding: 0;
}
.vod-card .fav-btn.active { color: var(--warning); }

/* ========== 直播 ========== */
.live-layout { display: grid; grid-template-columns: 180px 1fr; gap: 14px; height: calc(100vh - var(--topbar-h) - 120px); }
.live-groups {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px; overflow-y: auto;
}
.live-groups .group-item {
  padding: 8px 10px; cursor: pointer; border-radius: var(--radius-sm);
  font-size: 13px; transition: background .15s;
}
.live-groups .group-item:hover { background: var(--panel-hover); }
.live-groups .group-item.active { background: var(--accent-bg); color: var(--accent); }
.live-groups .group-item .cnt { float: right; color: var(--text-muted); font-size: 11px; }
.live-channels {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; overflow-y: auto;
}
.live-channels .ch-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.live-channels .ch-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--bg-elev); border-radius: var(--radius-sm);
  cursor: pointer; transition: all .15s;
}
.live-channels .ch-item:hover { background: var(--panel-hover); }
.live-channels .ch-item.active { background: var(--accent-bg); border: 1px solid var(--accent); }
.live-channels .ch-item .ch-logo { width: 32px; height: 32px; flex-shrink: 0; object-fit: contain; border-radius: 4px; background: var(--panel); }
.live-channels .ch-item .ch-name { font-size: 13px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-channels .ch-item .ch-src { font-size: 11px; color: var(--text-muted); }

/* ========== 仓库 ========== */
.breadcrumb { padding: 8px 0; font-size: 13px; color: var(--text-muted); }
.breadcrumb .crumb { cursor: pointer; }
.breadcrumb .crumb:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 6px; }
.repo-list { display: grid; gap: 8px; }
.repo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer; transition: all .15s;
}
.repo-item:hover { background: var(--panel-hover); border-color: var(--accent); }
.repo-item .ico { font-size: 22px; flex-shrink: 0; }
.repo-item .meta { flex: 1; min-width: 0; }
.repo-item .meta .n { font-weight: 600; }
.repo-item .meta .p { font-size: 12px; color: var(--text-muted); word-break: break-all; }
.repo-item .actions { display: flex; gap: 6px; }
.repo-item.json { border-left: 3px solid var(--accent); }
.repo-item.dir { border-left: 3px solid var(--warning); }

/* ========== 弹窗 ========== */
.modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 1000;
  align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
.modal.show { display: flex; }
.modal-content {
  background: var(--panel); border-radius: var(--radius);
  width: 520px; max-width: 92vw; max-height: 86vh;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-lg { width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.modal-tip { color: var(--text-muted); font-size: 13px; margin: 12px 0 8px; }

.modal-tabs { display: flex; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.modal-tabs .tab {
  padding: 6px 14px; background: transparent; border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; font-size: 13px;
}
.modal-tabs .tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 源管理表单 */
.mng-form { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px; background: var(--bg-elev); }
.mng-form .input { font-size: 13px; padding: 6px 10px; }
.mng-list { max-height: 360px; overflow-y: auto; padding: 8px 12px; }
.mng-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 6px; font-size: 13px; background: var(--bg-elev);
}
.mng-item .mn-name { font-weight: 600; min-width: 100px; }
.mng-item .mn-url { flex: 1; color: var(--text-muted); word-break: break-all; font-size: 12px; }
.mng-item .mn-actions { display: flex; gap: 4px; }
.mng-item .mn-actions button { font-size: 12px; padding: 4px 10px; }
.mng-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

.preset-list { display: flex; flex-direction: column; gap: 6px; }
.preset-item {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; background: var(--bg-elev); transition: all .15s;
}
.preset-item:hover { border-color: var(--accent); background: var(--panel-hover); }
.preset-item .pn { font-weight: 600; font-size: 13px; }
.preset-item .pu { font-size: 11px; color: var(--text-muted); margin-top: 2px; word-break: break-all; }

/* 详情 */
.detail-info { display: flex; gap: 14px; }
.detail-info .poster { width: 140px; aspect-ratio: 2/3; flex-shrink: 0; border-radius: var(--radius); overflow: hidden; background: var(--bg-elev); }
.detail-info .poster img { width: 100%; height: 100%; object-fit: cover; }
.detail-info .meta { flex: 1; }
.detail-info .meta .t { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.detail-info .meta .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.detail-info .meta .tag { padding: 2px 8px; background: var(--accent-bg); color: var(--accent); font-size: 11px; border-radius: 3px; }
.detail-info .meta .desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; max-height: 100px; overflow-y: auto; }
.line-label { font-size: 13px; font-weight: 600; color: var(--accent); margin: 14px 0 6px; }
.ep-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ep-list button { font-size: 12px; padding: 5px 12px; background: var(--bg-elev); border: 1px solid var(--line); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; }
.ep-list button:hover { background: var(--panel-hover); }
.ep-list button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 设置 */
.settings-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: none; }
.setting-row span { color: var(--text); }
.config-info { background: var(--bg-elev); padding: 14px; border-radius: var(--radius); font-size: 12px; color: var(--text-muted); white-space: pre-wrap; word-break: break-all; }

/* 空状态 */
.empty {
  padding: 40px 20px; text-align: center; color: var(--text-muted);
  grid-column: 1 / -1; font-size: 14px;
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(40px);
  background: var(--panel); color: var(--text); padding: 12px 20px;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); font-size: 14px; z-index: 2000;
  opacity: 0; transition: all .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

.search-info { padding: 8px 12px; font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }

/* 响应式 */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-item span:not(.icon), .version { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .main { margin-left: 60px; }
  .player-bar { width: calc(100vw - 80px); right: 10px; }
  .live-layout { grid-template-columns: 1fr; height: auto; }
}

/* ========== 登录遮罩 ========== */
.login-mask {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px 28px 28px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 22px;
  font-weight: 700;
}
.login-logo .logo-icon { font-size: 28px; }
.login-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 20px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-form .input-lg { width: 100%; box-sizing: border-box; padding: 12px 14px; }
.login-form .btn-lg { width: 100%; padding: 12px; font-size: 15px; }
.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 4px;
}
