/* ==========================================================================
   Kinect Tray Capture — 统一样式
   分区：1 基础变量  2 登录遮罩  3 实时预览页  4 管理后台  5 公网引导页
   ========================================================================== */

/* ---------- 1 基础 ---------- */
:root {
  --bg: #070b11;
  --bg-soft: #0d141d;
  --panel: rgba(17, 25, 36, .55);
  --panel-solid: #121b26;
  --stroke: rgba(255, 255, 255, .16);
  --stroke-soft: rgba(255, 255, 255, .08);
  --text: #eef4fb;
  --muted: #92a3b7;
  --accent: #24d6a8;
  --accent-2: #38bdf8;
  --danger: #ff5064;
  --warn: #ffc05c;
  --shadow: 0 12px 36px rgba(0, 0, 0, .42);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", -apple-system,
               BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.glass {
  background: var(--panel);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .10);
}

.btn {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .07);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 11px;
  font-size: 13px;
  transition: .18s ease;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .15); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #17a98a);
  border-color: transparent;
  color: #05231b;
  font-weight: 700;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255, 80, 100, .4); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid var(--stroke);
  background: rgba(4, 9, 15, .55);
  color: var(--text);
  outline: none;
  font-size: 14px;
  transition: .18s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 214, 168, .15); }
.input::placeholder { color: #64748b; }

.muted { color: var(--muted); }
.mono { font-family: "JetBrains Mono", Consolas, "SF Mono", monospace; }

/* ---------- 2 登录遮罩（实时页 / 管理页共用） ---------- */
.login-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 30%, rgba(28, 60, 66, .55), rgba(4, 8, 13, .94) 70%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.login-mask.hidden { display: none; }
.login-card {
  width: min(400px, 100%);
  padding: 34px 30px 30px;
  border-radius: 22px;
}
.login-logo {
  width: 52px; height: 52px; border-radius: 15px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06231d; font-size: 25px; font-weight: 800;
  margin-bottom: 18px;
}
.login-card h1 { margin: 0 0 6px; font-size: 21px; letter-spacing: .3px; }
.login-card .sub { margin: 0 0 26px; font-size: 13px; color: var(--muted); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.login-card .btn.primary { width: 100%; padding: 12px; margin-top: 8px; font-size: 14px; }
.login-error {
  min-height: 18px; margin-top: 10px; font-size: 12px;
  color: var(--danger); text-align: center;
}
.login-hint {
  margin-top: 18px; padding-top: 16px; font-size: 11.5px;
  border-top: 1px solid var(--stroke-soft); color: #6f8196; line-height: 1.7;
}

/* ---------- 3 实时预览页 ---------- */
body.live { overflow: hidden; }

.stage { position: fixed; inset: 0; overflow: hidden; background: #04070b; }

.viewport {
  position: absolute;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: #04070b;
  transform-origin: top left;
  transition: transform .35s cubic-bezier(.22, .8, .3, 1);
}
/* 顺时针旋转 90°：宽高互换 + 左移到 100vw，旋转后正好铺满屏幕 */
.stage.rotated .viewport {
  width: 100vh; height: 100vw;
  left: 100vw; top: 0;
  transform: rotate(90deg);
}
#stream {
  display: block; width: 100%; height: 100%;
  object-fit: contain;             /* 保证中央 640x640 ROI 完整可见，不被裁切 */
  background: #04070b;
}

/* 中央 ROI 红框：前端 SVG 叠加。
   SVG 的 viewBox + preserveAspectRatio="xMidYMid meet" 与上面
   object-fit: contain 的缩放/居中规则完全一致，红框不会因屏幕比例或旋转而错位。
   服务端只推原始画面、不画框，性能更好，截图也不含红框。 */
.roi-overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* 控制层不随画面旋转，按钮始终保持正向可读 */
.ui-layer { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.ui-layer > * { pointer-events: auto; }

.hud {
  position: absolute; display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: 999px; font-size: 12px;
  letter-spacing: .2px;
}
.hud.brand { top: 16px; left: 16px; font-weight: 700; }
.hud.status { top: 16px; right: 16px; }
.hud .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
.hud .dot.off { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.hud .sep { width: 1px; height: 14px; background: var(--stroke); }
.hud .brand-mark { color: var(--accent); }

.side-controls {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 12px;
}
.icon-btn {
  width: 50px; height: 50px; border-radius: 16px;
  display: grid; place-items: center;
  color: var(--text); font-size: 19px; line-height: 1;
  transition: .18s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, .18); transform: scale(1.05); }
.icon-btn.active { color: var(--accent); border-color: rgba(36, 214, 168, .55); }
.icon-btn .cap { display: block; font-size: 9px; margin-top: 3px; color: var(--muted); }

.bottom-bar {
  position: absolute; left: 0; right: 0; bottom: 22px;
  display: flex; align-items: center; justify-content: center; gap: 20px;
}
.capture-btn {
  position: relative;
  width: 86px; height: 86px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .88);
  background: rgba(16, 24, 34, .38);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .48), inset 0 1px 0 rgba(255, 255, 255, .2);
  display: grid; place-items: center;
  transition: transform .15s ease, box-shadow .2s ease;
}
.capture-btn::after {
  content: ""; width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(150deg, #ff6b7a, var(--danger));
  box-shadow: 0 4px 16px rgba(255, 80, 100, .5);
}
.capture-btn:hover { transform: scale(1.06); }
.capture-btn:active { transform: scale(.94); }
.capture-btn.busy { animation: capPulse .7s ease-in-out infinite; }
.capture-btn .label {
  position: absolute; bottom: -22px; font-size: 11px;
  color: rgba(255, 255, 255, .8); text-shadow: 0 1px 6px #000;
}
@keyframes capPulse {
  0%, 100% { box-shadow: 0 10px 34px rgba(0, 0, 0, .48); }
  50% { box-shadow: 0 0 0 12px rgba(255, 80, 100, .18), 0 10px 34px rgba(0, 0, 0, .48); }
}

.mini-link {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center; font-size: 16px;
  color: var(--text);
}
.mini-link:hover { background: rgba(255, 255, 255, .18); }

.keytip {
  position: absolute; left: 16px; bottom: 20px;
  font-size: 11px; color: rgba(255, 255, 255, .48);
  text-shadow: 0 1px 4px #000; line-height: 1.7;
}

/* 截图成功提示 */
.toast {
  position: absolute; top: 76px; left: 50%; transform: translate(-50%, -14px);
  display: flex; align-items: center; gap: 13px;
  padding: 11px 16px 11px 11px; border-radius: 15px;
  opacity: 0; visibility: hidden; transition: .28s ease;
  min-width: 250px;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.toast img {
  width: 56px; height: 56px; border-radius: 9px; object-fit: cover;
  border: 1px solid var(--stroke); background: #111;
}
.toast .t-title { font-size: 13px; font-weight: 700; color: var(--accent); }
.toast .t-sub { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.toast.error .t-title { color: var(--danger); }

/* ---------- 4 管理后台 ---------- */
body.admin { overflow: auto; background: var(--bg); }
.admin-wrap { max-width: 1280px; margin: 0 auto; padding: 26px 24px 70px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 26px;
}
.topbar .brandline { display: flex; align-items: center; gap: 13px; }
.brand-badge {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05231b; font-weight: 800; font-size: 19px;
}
.topbar h1 { margin: 0; font-size: 19px; }
.topbar .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 8px 13px;
  border-radius: 999px; font-size: 12px;
}
.user-chip b { color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { padding: 18px 20px; border-radius: var(--radius); }
.stat-card .k { font-size: 11.5px; color: var(--muted); }
.stat-card .v { font-size: 27px; font-weight: 750; margin-top: 8px; letter-spacing: -.5px; }
.stat-card .v small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }

.panel { border-radius: var(--radius); overflow: hidden; margin-bottom: 22px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--stroke-soft);
  flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 9px; }
.panel-head h2::before {
  content: ""; width: 3px; height: 15px; border-radius: 2px; background: var(--accent);
}
.panel-tools { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.panel-tools .input { width: 220px; padding: 8px 12px; font-size: 12.5px; }

.grid-imgs {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 16px; padding: 20px;
}
.img-card {
  border: 1px solid var(--stroke-soft); border-radius: 13px; overflow: hidden;
  background: rgba(255, 255, 255, .025); transition: .18s ease;
}
.img-card:hover { transform: translateY(-3px); border-color: rgba(36, 214, 168, .45); }
.img-card .thumb {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  background: #0b1219; cursor: zoom-in;
}
.img-card .meta { padding: 10px 12px 12px; }
.img-card .fname {
  font-size: 11px; color: var(--text); word-break: break-all; line-height: 1.4;
  font-family: Consolas, monospace;
}
.img-card .line { font-size: 10.5px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; gap: 6px; }
.img-card .line b { color: var(--accent-2); font-weight: 600; }
.img-card .ops { display: flex; gap: 6px; margin-top: 10px; }
.img-card .ops .btn { flex: 1; padding: 5px 6px; font-size: 11px; text-align: center; border-radius: 8px; }

.empty { padding: 54px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 12px; opacity: .5; }

.log-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.log-table th, .log-table td {
  padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--stroke-soft);
  white-space: nowrap;
}
.log-table th { color: var(--muted); font-weight: 600; font-size: 11px; background: rgba(255, 255, 255, .02); }
.log-table td { color: #cbd7e5; }
.log-table tr:last-child td { border-bottom: none; }
.log-table .u { color: var(--accent); font-weight: 600; }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 10.5px;
  background: rgba(56, 189, 248, .13); color: #8dd6fb;
}
.tag.capture, .tag.upload, .tag.login { background: rgba(36, 214, 168, .14); color: #63e6c2; }
.tag.warn { background: rgba(255, 192, 92, .14); color: var(--warn); }
.tag.del { background: rgba(255, 80, 100, .14); color: #ff8b98; }
.table-scroll { overflow-x: auto; max-height: 430px; overflow-y: auto; }

/* 预览弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(3, 7, 12, .84); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 24px;
}
.modal.hidden { display: none; }
.modal-box { max-width: min(720px, 92vw); width: 100%; border-radius: 18px; overflow: hidden; }
.modal-box img { width: 100%; display: block; background: #0b1219; }
.modal-info { padding: 14px 18px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--stroke-soft); font-size: 13px; }

/* ---------- 5 公网引导页 ---------- */
body.bridge {
  display: grid; place-items: center; padding: 24px; overflow: auto;
  background:
    radial-gradient(circle at 20% 15%, rgba(36, 214, 168, .13), transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(56, 189, 248, .12), transparent 45%),
    var(--bg);
}
.bridge-card { width: min(560px, 100%); padding: 34px 32px 30px; border-radius: 22px; }
.bridge-card h1 { font-size: 22px; margin: 0 0 8px; }
.bridge-card .lead { color: var(--muted); font-size: 13px; line-height: 1.8; margin: 0 0 22px; }
.bridge-card .lead b { color: var(--accent); font-weight: 600; }
.flow {
  display: flex; align-items: center; gap: 8px; margin: 0 0 24px;
  font-size: 11.5px; color: var(--muted); flex-wrap: wrap;
}
.flow span { padding: 6px 10px; border: 1px solid var(--stroke-soft); border-radius: 8px; background: rgba(255,255,255,.03); }
.flow i { font-style: normal; color: var(--accent); }
.bridge-field { display: flex; gap: 9px; }
.bridge-field .input { flex: 1; }
.bridge-actions { display: flex; gap: 9px; margin-top: 12px; flex-wrap: wrap; }
.bridge-actions .btn.primary { flex: 1; min-width: 150px; padding: 12px; font-size: 14px; }
.bridge-status { min-height: 20px; font-size: 12px; margin-top: 14px; line-height: 1.6; color: var(--muted); }
.bridge-status.ok { color: var(--accent); }
.bridge-status.err { color: var(--warn); }
.history { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--stroke-soft); }
.history h3 { font-size: 12px; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 12px; border-radius: 9px; font-size: 11.5px;
  border: 1px solid var(--stroke-soft); background: rgba(255,255,255,.04);
  color: #cbd7e5;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.notice {
  margin-top: 22px; padding: 13px 15px; border-radius: 11px;
  background: rgba(255, 192, 92, .08); border: 1px solid rgba(255, 192, 92, .22);
  font-size: 11.5px; color: #d6c29c; line-height: 1.8;
}
.notice b { color: var(--warn); }
.notice a { color: var(--accent-2); text-decoration: underline; }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hud.status { top: auto; bottom: 118px; right: 12px; font-size: 11px; }
  .hud.brand { top: 12px; left: 12px; font-size: 11px; }
  .side-controls { right: 12px; gap: 8px; }
  .icon-btn { width: 44px; height: 44px; font-size: 17px; }
  .bottom-bar { bottom: 18px; gap: 12px; }
  .capture-btn { width: 74px; height: 74px; }
  .capture-btn::after { width: 51px; height: 51px; }
  .keytip { display: none; }
  .panel-tools .input { width: 100%; }
  .grid-imgs { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 11px; padding: 14px; }
  .bridge-card { padding: 26px 20px; }
}
