/**
 * 贺简云物联iot 广告系统
 */

/* ===== 设计变量 ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-sub: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, .1);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .15);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 230px;
  --header-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --text-sub: #94a3b8;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  --primary-light: #1e3a8a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
img { max-width: 100%; }

/* ===== 播放端 ===== */
.stage {
  position: fixed; inset: 0;
  background: #000;
  overflow: hidden;
  color: #fff;
  font-family: var(--font);
}
.stage-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
}
.stage-bg video {
  width: 100%; height: 100%; object-fit: cover;
  background: #000;
}
.stage-web { position: absolute; inset: 0; }
.stage-layers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.layer-text {
  position: absolute;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
  white-space: pre-wrap;
  pointer-events: none;
}
.layer-image { position: absolute; pointer-events: none; }
.stage-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .55);
  color: #fff; font-size: 28px; text-align: center; padding: 24px;
  z-index: 20;
}
.status-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 6px 14px;
  background: rgba(0, 0, 0, .45);
  color: rgba(255, 255, 255, .9);
  font-size: 13px;
  z-index: 30;
  text-align: center;
  letter-spacing: .5px;
}
.stage-watermark {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0;
  display: flex; flex-wrap: wrap;
  align-content: space-around; justify-content: space-around;
  z-index: 31; pointer-events: none; overflow: hidden;
  padding: 4vh 2vw;
}
.stage-watermark .wm-item {
  color: rgba(255, 255, 255, .22);
  font-size: 42px; font-weight: 700;
  letter-spacing: 6px; white-space: nowrap;
  transform: rotate(-20deg);
  text-shadow: 0 0 8px rgba(0, 0, 0, .45), 1px 1px 2px rgba(0, 0, 0, .6);
  user-select: none;
}
.stage-corner {
  position: absolute; top: 14px; left: 14px;
  background: rgba(0, 0, 0, .5);
  color: #fff; font-size: 12px;
  padding: 4px 10px; border-radius: 20px;
  z-index: 31; pointer-events: none;
}
.expire-notice {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  background: var(--warning); color: #fff;
  padding: 10px 22px; border-radius: 24px;
  font-size: 16px; z-index: 40;
  box-shadow: var(--shadow-lg);
  animation: fadeSlide .4s ease;
}
.click-play {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .4);
  color: #fff; font-size: 26px; cursor: pointer;
}
.click-play::after {
  content: '▶'; position: absolute; left: 50%; top: 38%;
  transform: translate(-50%, -50%);
  width: 84px; height: 84px; line-height: 84px;
  border: 3px solid rgba(255, 255, 255, .8);
  border-radius: 50%; text-align: center;
  font-size: 34px; padding-left: 8px;
}
.fallback-qr {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .88);
}
.qr-box {
  background: #fff; color: #1e293b;
  border-radius: 14px; padding: 26px 30px;
  text-align: center;
  max-width: 320px;
}
.qr-text { margin-top: 14px; font-size: 15px; word-break: break-all; }
.bind-input-box { margin-top: 14px; text-align: center; }
.bind-hint { font-size: 13px; color: rgba(255, 255, 255, .85); margin-bottom: 8px; }
.bind-input-box input {
  width: 200px; max-width: 90%; height: 40px; border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 8px; padding: 0 12px; font-size: 15px; box-sizing: border-box;
  background: rgba(255, 255, 255, .95); color: #1e293b;
}
.bind-input-box button {
  margin-top: 10px; width: 200px; max-width: 90%; height: 42px;
  border: none; border-radius: 8px; font-size: 15px; cursor: pointer;
  background: #2563eb; color: #fff;
}
.bind-input-box .bind-scan-btn {
  margin-top: 8px; background: #0f172a; border: 1px solid rgba(255, 255, 255, .35);
}
.scan-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, .92);
  display: flex; align-items: center; justify-content: center;
}
.scan-box { width: 86vw; max-width: 380px; text-align: center; }
.scan-box video { width: 100%; border-radius: 12px; background: #000; }
.scan-tip { color: #e2e8f0; font-size: 15px; margin: 12px 0; }
.scan-box button {
  width: 100%; height: 44px; border: none; border-radius: 8px;
  font-size: 15px; cursor: pointer; background: #475569; color: #fff;
}
.camera-video {
  position: absolute; right: 12px; bottom: 52px;
  width: 180px; height: 120px;
  border-radius: 10px; object-fit: cover;
  z-index: 32; opacity: .85;
}
.camera-canvas { display: none; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ===== 通用组件（后台共用） ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card); color: var(--text);
  font-size: 14px; cursor: pointer;
  transition: all .15s;
  min-height: 36px;
  user-select: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card); color: var(--text);
  font-size: 14px; font-family: var(--font);
  min-height: 38px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.textarea { min-height: 90px; resize: vertical; }
.label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.badge {
  display: inline-block; padding: 2px 10px;
  border-radius: 20px; font-size: 12px;
  background: var(--border); color: var(--text-sub);
}
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-err { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #cffafe; color: #0e7490; }
html[data-theme="dark"] .badge-ok { background: #14532d; color: #bbf7d0; }
html[data-theme="dark"] .badge-warn { background: #78350f; color: #fde68a; }
html[data-theme="dark"] .badge-err { background: #7f1d1d; color: #fecaca; }
html[data-theme="dark"] .badge-info { background: #164e63; color: #a5f3fc; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 10px 12px;
  background: var(--border); color: var(--text-sub);
  font-weight: 600; white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: rgba(37, 99, 235, .04); }
.table-wrap { overflow-x: auto; }

.empty {
  text-align: center; color: var(--text-sub);
  padding: 40px 10px; font-size: 14px;
}

/* ===== 后台布局 ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 60;
  transition: transform .25s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  font-size: 17px; font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
}
.sidebar .brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.sidebar nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.sidebar nav .nav-group {
  font-size: 12px; color: var(--text-sub);
  padding: 12px 12px 4px; letter-spacing: 1px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  transition: all .15s;
  cursor: pointer;
}
.sidebar nav a:hover { background: var(--primary-light); color: var(--primary); }
.sidebar nav a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar nav a .icon { width: 18px; text-align: center; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 18px; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.topbar .menu-btn { display: none; font-size: 20px; cursor: pointer; padding: 4px 10px; }
.topbar .spacer { flex: 1; }
.topbar .user {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text);
}
.content { padding: 18px; flex: 1; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.page-desc { color: var(--text-sub); font-size: 13px; margin-bottom: 16px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--text-sub); }
.pager .btn { padding: 5px 12px; min-height: 30px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-card .num { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-card .label { margin: 0; }

.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeSlide .2s ease;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-head .title { font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-sub); padding: 0 4px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.actions { white-space: nowrap; }
.actions .btn { margin-right: 4px; }
.sub { font-size: 11px; color: var(--text-sub); }

.drawer-mask { position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, .4); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 91;
  width: min(420px, 92vw);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideIn .25s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card); color: var(--text);
  border-left: 4px solid var(--primary);
  padding: 12px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 14px;
  animation: fadeSlide .2s ease;
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }

.skeleton { background: linear-gradient(90deg, var(--border) 25%, var(--card) 50%, var(--border) 75%); background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.spin {
  width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: rot .8s linear infinite;
  margin: 40px auto;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* 移动端优先（44px 触控） */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: block; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .btn { min-height: 44px; padding: 11px 16px; }
  .input, .select, .textarea { min-height: 44px; }
  .modal { max-width: 100%; height: 100%; max-height: 100vh; border-radius: 0; }
  .table-cards .table { display: none; }
  .content { padding: 12px; }
}

/* 平板/电视（大屏远距离可读） */
@media (min-width: 769px) and (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1600px) {
  body { font-size: 16px; }
}

/* 表格转卡片（手机端） */
.card-list { display: none; }
@media (max-width: 768px) {
  .table-cards .table-wrap { display: none; }
  .card-list { display: block; }
  .card-list .c-item {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
  }
  .card-list .c-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 14px; }
  .card-list .c-row .k { color: var(--text-sub); flex-shrink: 0; }
}

/* 骨架屏占位 */
.skel-row { height: 48px; margin-bottom: 10px; border-radius: var(--radius-sm); }

/* 无 WebSocket/摄像头降级提示已在播放端处理 */

/* ===== 文字广告（播放端） ===== */
.text-ad { position: absolute; inset: 0; pointer-events: none; }
.text-ad-inner {
  position: absolute;
  white-space: pre-wrap;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
  line-height: 1.35;
  pointer-events: none;
}
/* 文字广告动画 */
@keyframes adFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes adZoomIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes adSlideInLeft { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: translateX(0); } }
@keyframes adSlideInRight { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: translateX(0); } }
@keyframes adSlideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
@keyframes adBounceIn { 0% { opacity: 0; transform: scale(.3); } 55% { transform: scale(1.08); } 75% { transform: scale(.96); } 100% { opacity: 1; transform: scale(1); } }
