/* Unfrozen Stream - Glacial Frost + Arctic Northern Lights Control Portal
 * Zero external CDN/fonts, CSP-clean, WCAG AA dark contrast.
 */

:root {
  color-scheme: dark;
  --bg: #07111b;
  --bg-deep: #050c14;
  --bg-card: #0c1b29;
  --bg-card-hover: #102336;
  --bg-surface: #12263a;
  --bg-chip: #122d42;
  --bg-input: #081522;
  --border: #203c56;
  --border-strong: #477ca8;
  --frost-rim: rgba(184, 246, 255, 0.2);

  --text: #eef7ff;
  --text-muted: #a9c4dc;
  --text-subtle: #89abc8;

  --ice: #67e8f9;
  --ice-bright: #b8f6ff;
  --ice-on-btn: #06131f;
  --ice-btn-hover: #8ef0fc;

  --aurora-a: rgba(52, 242, 168, 0.14);
  --aurora-b: rgba(24, 210, 218, 0.12);
  --aurora-c: rgba(103, 232, 249, 0.08);
  --aurora-edge: rgba(68, 236, 184, 0.6);

  --live: #ff6b57;
  --live-bg: #c93122;
  --live-soft-bg: #2f161a;
  --live-soft-border: #ad5047;

  --ready-text: #7ef0a9;
  --ready-bg: #0f3024;
  --ready-border: #1e5e46;

  --warn-text: #ffd082;
  --warn-bg: #312511;
  --warn-border: #8c6828;

  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-card: 0 14px 36px rgba(2, 8, 16, 0.48);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 45% at 15% -10%, var(--aurora-a), transparent 65%),
    radial-gradient(ellipse 70% 40% at 85% -5%, var(--aurora-b), transparent 60%),
    radial-gradient(ellipse 60% 50% at 50% 100%, var(--aurora-c), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ice); text-decoration: none; }
a:hover { color: var(--ice-bright); text-decoration: underline; }
code, pre, .mono { font-family: var(--font-mono); }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ── Buttons & Inputs ──────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-card-hover); border-color: var(--ice); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--ice);
  border-color: var(--ice);
  color: var(--ice-on-btn);
}
.btn-primary:hover { background: var(--ice-btn-hover); border-color: var(--ice-btn-hover); color: var(--ice-on-btn); }

.btn-live {
  background: var(--live-bg);
  border-color: var(--live);
  color: #ffffff;
}
.btn-live:hover { background: #dc3a2a; border-color: #ff8b7a; }

.btn-danger {
  background: var(--live-soft-bg);
  border-color: var(--live-soft-border);
  color: #ffb4aa;
}
.btn-danger:hover { background: #461f25; border-color: var(--live); color: #ffffff; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-surface); color: var(--text); border-color: var(--border-strong); }

.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--ice);
  box-shadow: 0 0 0 2px rgba(103, 232, 249, 0.18);
}

input[readonly] { color: var(--ice-bright); background: #06101b; }

.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.input-copy-row { display: flex; gap: 8px; align-items: stretch; }
.input-copy-row input { flex: 1; font-family: var(--font-mono); font-size: 12px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 8px;
}
.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--ice);
  cursor: pointer;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
}
.chip-check input { width: 14px; height: 14px; accent-color: var(--ice); margin: 0; }

/* ── Badges & Alerts ───────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: var(--bg-chip);
  color: var(--text-muted);
}
.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-subtle);
}
.pill-live { background: var(--live-soft-bg); border-color: var(--live-soft-border); color: #ff9c8e; }
.pill-live .pill-dot { background: var(--live); box-shadow: 0 0 8px var(--live); }
.pill-ready { background: var(--ready-bg); border-color: var(--ready-border); color: var(--ready-text); }
.pill-ready .pill-dot { background: var(--ready-text); }
.pill-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.pill-warn .pill-dot { background: var(--warn-text); }
.pill-ice { background: rgba(103, 232, 249, 0.12); border-color: rgba(103, 232, 249, 0.35); color: var(--ice-bright); }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.alert-error { background: var(--live-soft-bg); border-color: var(--live-soft-border); color: #ffb4aa; }
.alert-ok { background: var(--ready-bg); border-color: var(--ready-border); color: var(--ready-text); }

/* ── Cards ─────────────────────────────────────────────────────────────── */

.card {
  background: rgba(12, 27, 41, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.card-subtitle { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }

/* ── Login Shell ───────────────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 430px;
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--frost-rim);
  background: rgba(12, 27, 41, 0.92);
  box-shadow: var(--shadow-card), 0 0 60px rgba(103, 232, 249, 0.08);
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-logo { width: 28px; height: 28px; flex-shrink: 0; }
.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ice);
}

.seg-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  margin: 20px 0 18px;
}
.seg-tab {
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.seg-tab.active {
  background: var(--bg-surface);
  color: var(--ice-bright);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* ── Portal Layout (Sidebar + Content) ─────────────────────────────────── */

.portal-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: rgba(5, 12, 20, 0.88);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.sidebar-brand {
  padding: 4px 10px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}
.nav-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-btn:hover { background: var(--bg-card); color: var(--text); }
.nav-btn.active {
  background: linear-gradient(135deg, rgba(103, 232, 249, 0.14), rgba(52, 242, 168, 0.08));
  border-color: rgba(103, 232, 249, 0.34);
  color: var(--ice-bright);
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
}
.sidebar-user {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
}

.main-area {
  padding: 24px 28px 48px;
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-heading { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.topbar-pills { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Telemetry KPI Grid & Scene Controls ───────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpi-card {
  background: rgba(12, 27, 41, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 4px;
  font-family: var(--font-mono);
}
.kpi-sub { font-size: 11px; color: var(--text-subtle); margin-top: 2px; }

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.scene-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.scene-btn {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.scene-btn:hover { border-color: var(--ice); color: var(--text); }
.scene-btn.active {
  background: rgba(103, 232, 249, 0.16);
  border-color: var(--ice);
  color: var(--ice-bright);
  box-shadow: 0 0 18px rgba(103, 232, 249, 0.16);
}

/* ── Live SVG Bitrate Chart ────────────────────────────────────────────── */

.chart-wrap {
  width: 100%;
  height: 170px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 8px;
}
.chart-svg { width: 100%; height: 100%; display: block; }
.chart-grid-line { stroke: rgba(71, 124, 168, 0.22); stroke-width: 1; }
.chart-line { fill: none; stroke: #67e8f9; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: rgba(103, 232, 249, 0.16); }
.chart-label { fill: #89abc8; font-size: 10px; font-family: var(--font-mono); }

/* ── QR Cards & Destinations ───────────────────────────────────────────── */

.qr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.qr-plate {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px;
  width: 220px;
  height: 220px;
  margin: 14px auto;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}
.qr-plate svg { width: 100%; height: 100%; display: block; }

.dest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.dest-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.dest-card.dest-enabled { border-color: rgba(68, 236, 184, 0.45); }

/* ── Lists (Events, Media, Layers, Moderators) ─────────────────────────── */

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  flex-wrap: wrap;
}
.item-meta { min-width: 0; flex: 1; }
.item-title { font-weight: 700; color: var(--text); font-size: 13px; }
.item-sub {
  font-size: 12px;
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.event-feed {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.event-row {
  display: flex;
  gap: 10px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid rgba(32, 60, 86, 0.65);
}
.event-ts { color: var(--ice); font-family: var(--font-mono); flex-shrink: 0; }

/* ── Standalone Shared Overlay Editor ──────────────────────────────────── */

.editor-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 24px 44px;
}
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}
.stage-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: #09131e;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.stage-layer {
  position: absolute;
  overflow: hidden;
  border: 1px dashed rgba(103, 232, 249, 0.45);
}
.stage-layer-selected {
  border: 2px solid var(--ice);
  box-shadow: 0 0 18px rgba(103, 232, 249, 0.25);
}
.stage-layer iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  pointer-events: none;
}
.stage-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.stage-layer-text {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(7, 17, 27, 0.78);
  border: 1px solid rgba(103, 232, 249, 0.45);
  color: #eef7ff;
  font-weight: 700;
  white-space: pre-wrap;
}

.preset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

/* ── Toast ─────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ice);
  background: rgba(7, 17, 27, 0.96);
  color: var(--ice-bright);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error { border-color: var(--live); color: #ffb4aa; }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.plan-price {
  font-size: 32px;
  font-weight: 800;
  color: var(--ice-bright);
  letter-spacing: -0.02em;
}
.feature-list {
  margin: 12px 0 18px;
  padding-left: 18px;
  color: var(--text-muted);
}
.feature-list li { margin-bottom: 6px; }

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .portal-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 14px;
  }
  .sidebar-brand { padding-bottom: 12px; margin-bottom: 10px; }
  .nav-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .nav-btn { width: auto; white-space: nowrap; }
  .sidebar-footer { display: none; }
  .main-area { padding: 18px 16px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .qr-grid, .editor-layout { grid-template-columns: 1fr; }
}
