/* ===== 变量定义 ===== */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2236;
  --bg-hover: #1e293b;
  --bg-active: #1e40af;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --border: #1e293b;
  --status-bar-height: 48px;
  --list-width: 320px;
  --type-text: #22c55e;
  --type-image: #f59e0b;
  --type-video: #ef4444;
}

/* ===== 基础重置 ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ===== 加载页面覆盖层 ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  transition: opacity 0.8s ease;
}

.loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-slogan {
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  margin-bottom: 20px;
  opacity: 0;
  animation: sloganIn 0.8s 0.2s ease forwards;
}

.loading-brand {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--text-primary);
  margin-bottom: 40px;
  opacity: 0;
  transform: scale(0.6);
  animation: brandIn 0.8s 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sloganIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes brandIn {
  0%   { opacity: 0; transform: scale(0.6); }
  60%  { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

.loading-bar {
  width: 240px;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f97316);
  border-radius: 2px;
  transition: width 0.15s linear;
}

/* ===== 顶部状态栏 ===== */
.status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--status-bar-height);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-item {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
}

.status-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 6px;
}

.status-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 1.05rem;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  line-height: 1;
}

.status-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.status-btn.hidden {
  display: none;
}

/* ===== 主内容区 ===== */
.main-content {
  position: fixed;
  top: var(--status-bar-height);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
}

/* ===== 左侧节目列表 ===== */
.list-panel {
  width: var(--list-width);
  min-width: var(--list-width);
  height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.list-panel.visible {
  visibility: visible;
  opacity: 1;
}

.program-list {
  list-style: none;
  padding: 6px 0;
}

.program-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.program-list li:hover {
  background: var(--bg-hover);
}

.program-list li.selected {
  background: var(--bg-tertiary);
  border-left-color: var(--accent);
}

.program-list li.selected .program-name {
  color: var(--text-primary);
}

.program-name {
  font-size: 0.92rem;
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.program-type {
  font-size: 0.72rem;
  padding: 2px 10px;
  border-radius: 3px;
  margin-left: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.program-type.type-text {
  color: var(--type-text);
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.program-type.type-image {
  color: var(--type-image);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.program-type.type-video {
  color: var(--type-video);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.program-seq {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 20px;
  text-align: center;
  margin-right: 8px;
  flex-shrink: 0;
}

.program-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 10px;
}

.program-status-dot.dot-green {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.program-status-dot.dot-red {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* ===== 右侧预览区 ===== */
.preview-area {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.preview-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.preview-hint {
  color: var(--text-muted);
  font-size: 1rem;
}

/* 预览自动播放倒计时 (纯文本) */
.preview-countdown {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.88rem;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 16px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ===== 预览 - 文本广告 ===== */
.preview-text-display {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 48px;
  text-align: center;
}

.preview-text-display .text-title {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 1.2rem;
}

.preview-text-display .text-body {
  font-size: 1.15rem;
  line-height: 1.9;
  max-width: 600px;
}

/* ===== 预览 - 图片广告 ===== */
.preview-image-display {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-image-display img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

/* ===== 预览 - 视频广告 ===== */
.preview-video-display {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 10px;
  gap: 16px;
}

.preview-video-display .video-icon {
  font-size: 4.5rem;
  opacity: 0.6;
}

.preview-video-display .video-title {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.preview-video-display .video-duration {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== 广告全屏播放覆盖层 ===== */
.ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  transition: opacity 0.4s ease;
}

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

/* 左上角播放时间 */
.ad-time-top {
  position: absolute;
  top: 20px;
  left: 28px;
  font-size: 1.15rem;
  color: rgba(255, 255, 255, 0.6);
  z-index: 1010;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.ad-time-top.hidden {
  display: none;
}

/* 右上角广告标识 */
.ad-badge {
  position: absolute;
  top: 20px;
  right: 28px;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.6);
  padding: 5px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  z-index: 1010;
  letter-spacing: 0.08em;
}

/* 底部信息栏 */
.ad-bottom-bar {
  position: absolute;
  bottom: 24px;
  left: 28px;
  right: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1010;
}

/* 左下角圆环倒计时 */
.ad-ring-countdown {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.ad-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ad-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 3;
}

.ad-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.ad-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  font-variant-numeric: tabular-nums;
}

/* 右下角设备ID */
.ad-device-id {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.4);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

/* 广告内容区 */
.ad-content {
  position: absolute;
  inset: 0;
  z-index: 1005;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: adFadeIn 0.6s ease;
}

@keyframes adFadeIn {
  from { opacity: 0; transform: scale(1.02); }
  to   { opacity: 1; transform: scale(1); }
}

/* ===== 广告内容 - 文本 ===== */
.ad-text-display {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px;
  text-align: center;
}

.ad-text-display .text-title {
  font-size: 3.8rem;
  font-weight: bold;
  margin-bottom: 2rem;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.4);
}

.ad-text-display .text-body {
  font-size: 1.8rem;
  line-height: 1.8;
  max-width: 800px;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.3);
}

/* ===== 广告内容 - 图片 ===== */
.ad-image-display {
  position: absolute;
  inset: 0;
}

.ad-image-display img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== 广告内容 - 视频 ===== */
.ad-video-display {
  position: absolute;
  inset: 0;
  background: #000;
}

.ad-video-display video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== 网络断开提示栏 ===== */
.network-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  background: #dc2626;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  animation: networkPulse 2s ease-in-out infinite;
}

.network-bar.hidden {
  display: none;
}

.network-icon {
  font-size: 1.2rem;
}

@keyframes networkPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

/* ===== 通用面板覆盖层 ===== */
.panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  animation: fadeIn 0.2s ease;
}

.panel-overlay.hidden {
  display: none;
}

.panel-box {
  width: 480px;
  max-height: 80vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.panel-close:hover {
  color: var(--text-primary);
}

.panel-body {
  padding: 20px 24px;
  overflow-y: auto;
}

/* ===== 设置项 ===== */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-row label {
  font-size: 0.92rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.toggle-group {
  display: flex;
  gap: 6px;
}

.toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle-btn:hover {
  color: var(--text-secondary);
  border-color: var(--text-muted);
}

.toggle-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ===== 统计面板 ===== */
.stats-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stats-row:last-child {
  border-bottom: none;
}

.stats-label {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.stats-value {
  font-size: 0.88rem;
  color: var(--text-primary);
  text-align: right;
}

.stats-value.highlight {
  color: var(--accent);
}

/* ===== 滚动条 ===== */
.list-panel::-webkit-scrollbar,
.panel-body::-webkit-scrollbar {
  width: 5px;
}

.list-panel::-webkit-scrollbar-track,
.panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.list-panel::-webkit-scrollbar-thumb,
.panel-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.list-panel::-webkit-scrollbar-thumb:hover,
.panel-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== 二维码覆盖层 ===== */
.qr-overlay {
  position: absolute;
  bottom: 60px;
  right: 28px;
  z-index: 1010;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.qr-overlay img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  display: block;
}

.qr-overlay .qr-contact {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #333;
  white-space: nowrap;
}

/* ===== 列表头部 ===== */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.list-header-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.list-header-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 1rem;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.list-header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ===== 登录码展示 ===== */
.login-code-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
}

.login-code-overlay.hidden {
  display: none;
}

.login-code-box {
  text-align: center;
  padding: 48px 64px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.login-code-label {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  letter-spacing: 0.1em;
}

.login-code-value {
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.3em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 20px;
  text-shadow: 0 0 30px var(--accent-glow);
}

.login-code-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.login-code-progress {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  margin: 0 auto;
  overflow: hidden;
}

.login-code-progress-bar {
  width: 100%;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 1s linear;
}

/* ===== 切换账号 / 虚拟键盘 ===== */
.switch-box {
  width: 360px;
}

.switch-hint {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.numpad-display {
  text-align: center;
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.4em;
  font-variant-numeric: tabular-nums;
  padding: 12px;
  margin-bottom: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 56px;
}

.numpad-cursor {
  animation: blink 1s step-end infinite;
  color: var(--accent);
}

@keyframes blink {
  50% { opacity: 0; }
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.numpad-key {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 500;
  padding: 14px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  -webkit-user-select: none;
  user-select: none;
}

.numpad-key:hover {
  background: var(--bg-hover);
}

.numpad-key:active {
  background: var(--accent);
  color: #fff;
}

.numpad-key.numpad-action {
  font-size: 1rem;
  color: var(--text-muted);
}

.numpad-submit {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.numpad-submit:hover {
  background: #2563eb;
}

.numpad-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch-msg {
  text-align: center;
  font-size: 0.85rem;
  margin-top: 10px;
  min-height: 1.2em;
}

.switch-msg.error {
  color: #ef4444;
}

.switch-msg.success {
  color: #22c55e;
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
