/* ============================================================================
   Viibestream — base.css
   Shared design tokens, typography, buttons, forms, modals.
   All sizing in rem (1rem == 16px by default).
   ========================================================================= */

/* Inter is shipped locally — no third-party font request leaves the LAN.
   The variable woff2 covers weights 100–900 in a single file. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/Inter-Variable.woff2') format('woff2-variations'),
       url('/static/fonts/Inter-Variable.woff2') format('woff2');
}

/* Dark-mode only — there is no light theme to switch to. The previous
   :root / [data-theme="dark"] split has been collapsed into a single
   :root and any theme-toggle UI has been removed from the templates. */
:root {
  --bg:           #0b0d14;
  --bg-elev:      #11141d;
  --panel:        #141826;
  --panel-2:      #1a1f30;
  --text:         #e6e9f2;
  --text-strong:  #f7f8fb;
  --muted:        #8b93a9;
  --border:       #232838;
  --border-soft:  #1c2030;
  /* Brand palette — amber-yellow primary. White text on it is
     unreadable (contrast ~1.7:1), so anything that renders on a
     --brand background must use --brand-fg as its text color. */
  --brand:        #ffbc00;
  --brand-2:      #ff9e00;
  --brand-soft:   #3a2c00;
  --brand-fg:     #14110a;
  /* Sidebar nav active state — blue accent so navigation reads as
     navigation rather than competing with the primary brand color. */
  --nav-active-bg: #1f2750;
  --nav-active-fg: #6b7cff;
  --accent:       #38bdf8;
  --ok:           #10b981;
  --warn:         #f59e0b;
  --danger:       #ef4444;
  --danger-soft:  #3b1d22;
  --live:         #ef4356;
  --shadow-sm:    0 0.0625rem 0.125rem rgba(0, 0, 0, .35);
  --shadow-md:    0 0.625rem 1.5rem rgba(0, 0, 0, .35);
  --shadow-lg:    0 1.5rem 3rem rgba(0, 0, 0, .55);

  /* Layout tokens */
  --sidebar-w:        15.5rem;
  --radius-sm:        0.5rem;
  --radius-md:        0.75rem;
  --radius-lg:        1rem;
  --space-1:          0.25rem;
  --space-2:          0.5rem;
  --space-3:          0.75rem;
  --space-4:          1rem;
  --space-5:          1.5rem;
  --space-6:          2rem;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; }
/* Author-origin `display:` rules (e.g. img,svg,video { display: block }
   below) beat the user-agent [hidden] rule at equal specificity, so
   setting the `hidden` attribute would otherwise have no effect on
   elements that have an explicit display. This restores expected
   behavior for every element across both interfaces. */
[hidden] { display: none !important; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
button { font-family: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--text-strong); margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem;  font-weight: 600; }
h2 { font-size: 1.125rem; font-weight: 600; }
h3 { font-size: 1rem;    font-weight: 600; }

.muted { color: var(--muted); }
.ta-right { text-align: right; }
.dot-sep { color: var(--muted); margin: 0 0.5rem; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
}
.btn:hover { background: var(--panel); border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 85%, black));
  border-color: color-mix(in srgb, var(--brand) 60%, black);
  color: var(--brand-fg);
}
.btn-primary:hover { background: var(--brand); }
.btn-danger {
  background: linear-gradient(180deg, var(--danger), color-mix(in srgb, var(--danger) 80%, black));
  border-color: color-mix(in srgb, var(--danger) 60%, black);
  color: #fff;
}
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { height: 1.875rem; padding: 0 0.75rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.btn-icon { width: 2.25rem; padding: 0; }

.icon-btn {
  flex: 0 0 auto;
  width: 2.125rem;
  height: 2.125rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--brand-soft); }
.icon-btn-ghost { background: transparent; border-color: transparent; }
.icon-btn-ghost:hover { background: var(--panel-2); }
.icon-btn-inline {
  width: 2rem; height: 2rem;
  margin-left: auto;
}

/* ── Flash messages ────────────────────────────────────────────────────── */
.flash-stack { padding: 0.75rem 1.25rem 0; display: grid; gap: 0.5rem; }
.flash {
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.875rem;
}
.flash--success { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--panel)); }
.flash--error   { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--panel)); }
.flash--info    { border-color: var(--accent); }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.stacked-form { display: grid; gap: 0.75rem; }
.stacked-form label {
  display: grid;
  gap: 0.3125rem;
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}
.stacked-form label.checkbox {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text);
}
/* Text-like inputs get the full-width, uniform-height treatment. Checkboxes
   and radios are excluded — otherwise they'd be stretched into giant
   full-width boxes (they render via the .stacked-form checkbox rule below). */
.stacked-form input:not([type="checkbox"]):not([type="radio"]),
.stacked-form select,
.stacked-form textarea,
input.text-input, select.text-input {
  height: 2.375rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  width: 100%;
}
.stacked-form textarea { height: auto; padding: 0.5rem 0.75rem; }
/* Native checkbox / radio: compact, brand-tinted, vertically centered in
   its row by the `label.checkbox` flex rule above. */
.stacked-form input[type="checkbox"],
.stacked-form input[type="radio"] {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.stacked-form input:focus,
.stacked-form select:focus,
.stacked-form textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}
.field-group { display: grid; gap: 0.75rem; border: 0; padding: 0; margin: 0; }
.field-group > legend {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); margin-bottom: 0.25rem;
}
.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.inline-form { display: inline-block; }

/* ── Status / live indicators ──────────────────────────────────────────── */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}
.status-chip[data-state="live"]      { color: var(--live); border-color: color-mix(in srgb, var(--live) 45%, var(--border)); background: color-mix(in srgb, var(--live) 12%, var(--panel-2)); }
.status-chip[data-state="connected"] { color: var(--ok); }
.status-chip[data-state="error"]     { color: var(--danger); }

.live-dot {
  display: inline-block;
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 28%, transparent);
  flex: 0 0 auto;
}
.live-dot.is-live {
  background: var(--live);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent);
  animation: live-pulse 1.6s ease-out infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); }
  70%  { box-shadow: 0 0 0 0.5rem color-mix(in srgb, var(--live) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 0%, transparent); }
}

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-root {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
}
.modal-root[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) 50%, transparent);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}
.modal {
  position: relative;
  width: min(34rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 4rem);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-pop 160ms cubic-bezier(.2,.7,.2,1);
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(0.5rem) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)      scale(1); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-soft);
}
.modal-header h2 { font-size: 1.0625rem; }
.modal-tabs {
  display: flex; gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--border-soft);
}
.modal-tab {
  padding: 0.5rem 0.875rem;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
}
.modal-tab:hover { color: var(--text); }
.modal-tab.is-active { color: var(--text-strong); border-bottom-color: var(--brand); }
.modal-body { padding: 1.25rem; overflow: auto; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-soft);
}
.modal-panel { display: none; }
.modal-panel.is-active { display: block; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.card-header-meta { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.875rem; }
.card-eyebrow {
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 0.5rem;
}
.card-stat { display: flex; align-items: baseline; gap: 0.5rem; }
.card-stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-strong); }
.card-stat-unit { color: var(--muted); font-size: 0.8125rem; }
.card-sub { margin-top: 0.5rem; color: var(--muted); font-size: 0.875rem; }
.card--wide { grid-column: 1 / -1; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.action-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border-soft);
}
.data-table th { font-weight: 600; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tbody tr:hover { background: var(--panel-2); }

.user-cell { display: flex; align-items: center; gap: 0.625rem; }
.badge {
  display: inline-block;
  padding: 0.1875rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
}
.badge--admin    { color: var(--brand-fg); background: var(--brand); border-color: var(--brand); }
.badge--streamer { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent) 14%, var(--panel-2)); }
.badge--viewer   { color: var(--muted); }
.badge--ok       { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.badge--muted    { color: var(--muted); }
.badge--locked   { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: color-mix(in srgb, var(--danger) 12%, var(--panel-2)); }

/* ── Key-value list (settings, session info) ───────────────────────────── */
.kv { display: grid; gap: 0.375rem; margin: 0 0 0.75rem; }
.kv-row {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.375rem 0;
  border-bottom: 1px dashed var(--border-soft);
}
.kv-k { color: var(--muted); font-size: 0.8125rem; }
.kv-v { color: var(--text); font-size: 0.875rem; word-break: break-word; }

