/* =====================================================================
   Reporter Live System - Broadcast UI Theme
   Dark, professional television-control-room aesthetic.
   ===================================================================== */

:root {
  --bg:            #0b0e14;
  --bg-soft:       #10141d;
  --bg-card:       #151a25;
  --bg-card-hover: #1b2230;
  --bg-input:      #0e1219;
  --border:        #232c3d;
  --border-soft:   #1b2331;

  --text:          #e6ebf5;
  --text-dim:      #8b97ad;
  --text-faint:    #5d6880;

  --accent:        #2ea6ff;
  --accent-2:      #7c5cff;
  --ok:            #23d18b;
  --warn:          #f5a623;
  --danger:        #ff4d5e;
  --onair:         #ff2e3f;
  --tally-ready:   #23d18b;
  --tally-standby: #f5a623;

  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 8px 28px rgba(0, 0, 0, 0.45);
  --font-ui:       "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:     "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #7ec3ff; }

h1, h2, h3, h4, h5, h6 { font-weight: 650; letter-spacing: 0.2px; }

.mono { font-family: var(--font-mono); }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3548; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #3a4860; }

/* =====================================================================
   Layout shell
   ===================================================================== */
.rls-topbar {
  position: sticky;
  top: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 60px;
  padding: 0 18px;
  background: rgba(13, 17, 25, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.rls-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 16px;
  letter-spacing: 0.4px;
  color: var(--text);
}
.rls-brand .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--onair); box-shadow: 0 0 12px var(--onair); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.rls-sidebar {
  position: fixed;
  top: 60px;
  bottom: 0;
  left: 0;
  width: 240px;
  padding: 16px 12px;
  overflow-y: auto;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  transition: transform 0.22s ease;
}
.rls-sidebar .nav-group { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin: 18px 8px 8px; }
.rls-sidebar a.nav-link {
  display: flex; align-items: center; gap: 11px;
  color: var(--text-dim);
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.rls-sidebar a.nav-link i { width: 20px; text-align: center; font-size: 16px; }
.rls-sidebar a.nav-link:hover { color: var(--text); background: var(--bg-card); }
.rls-sidebar a.nav-link.active { color: #fff; background: linear-gradient(90deg, rgba(46,166,255,0.16), rgba(46,166,255,0.04)); border-left: 3px solid var(--accent); }

.rls-main {
  margin-left: 240px;
  padding: 24px;
  min-height: calc(100vh - 60px);
}

@media (max-width: 991.98px) {
  .rls-sidebar { transform: translateX(-100%); }
  .rls-sidebar.open { transform: translateX(0); }
  .rls-main { margin-left: 0; padding: 16px; }
}

.rls-topbar .search { background: var(--bg-input); border: 1px solid var(--border); color: var(--text); }

/* =====================================================================
   Components
   ===================================================================== */
.rls-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rls-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-card), var(--bg-soft));
  border: 1px solid var(--border);
}
.rls-stat .label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }
.rls-stat .value { font-size: 26px; font-weight: 750; }
.rls-stat .sub { color: var(--text-faint); font-size: 12px; }

.rls-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card-hover);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.rls-btn:hover { border-color: var(--accent); color: #fff; }
.rls-btn.primary { background: var(--accent); border-color: var(--accent); color: #04121f; }
.rls-btn.primary:hover { filter: brightness(1.1); color: #04121f; }
.rls-btn.danger { background: var(--onair); border-color: var(--onair); color: #fff; }
.rls-btn.success { background: var(--ok); border-color: var(--ok); color: #04120a; }
.rls-btn.ghost { background: transparent; }
.rls-btn.sm { padding: 6px 11px; font-size: 13px; }
.rls-btn.lg { padding: 13px 26px; font-size: 16px; }
.rls-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.rls-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 650;
  background: var(--bg-card-hover); border: 1px solid var(--border); color: var(--text-dim);
}
.rls-badge.ok { color: #b7ffdb; background: rgba(35,209,139,0.12); border-color: rgba(35,209,139,0.35); }
.rls-badge.warn { color: #ffd79b; background: rgba(245,166,35,0.12); border-color: rgba(245,166,35,0.35); }
.rls-badge.danger { color: #ffb3bb; background: rgba(255,77,94,0.14); border-color: rgba(255,77,94,0.4); }

/* status pills */
.pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.pill.live { background: var(--onair); color: #fff; box-shadow: 0 0 14px rgba(255,46,63,0.5); animation: blink 1.2s infinite; }
.pill.waiting { background: var(--warn); color: #241302; }
.pill.connecting { background: #2b7fff; color: #fff; }
.pill.ended, .pill.rejected, .pill.offline { background: #3a4457; color: #cfd6e4; }
@keyframes blink { 50% { opacity: 0.55; } }

/* tally lights */
.tally { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.tally.on_air { background: var(--onair); box-shadow: 0 0 12px var(--onair); animation: blink 1.4s infinite; }
.tally.ready { background: var(--tally-ready); box-shadow: 0 0 10px var(--tally-ready); }
.tally.standby { background: var(--tally-standby); box-shadow: 0 0 8px rgba(245,166,35,0.6); }

/* ---------- live tiles ---------- */
.tile {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.tile .tile-video { width: 100%; height: 100%; object-fit: cover; background: #05070b; }
.tile.split-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2px;
  aspect-ratio: auto;
  height: min(78vh, 760px);
  max-height: calc(100vh - 180px);
}
.tile.split-preview > #localPreview {
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
  object-fit: contain !important;
}
.tile.split-preview #returnFeedWrap {
  position: relative !important;
  inset: auto !important;
  width: auto !important;
  height: 100% !important;
  min-height: 0;
  display: flex !important;
  flex-direction: column;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.tile.split-preview #returnFeed {
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
  flex: 1;
  object-fit: contain;
}
.tile .tile-tally {
  position: absolute; top: 10px; left: 10px;
  display: flex; align-items: center; gap: 7px;
  background: rgba(0,0,0,0.55); padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff;
}
.tile-talkback {
  position: absolute; top: 10px; right: 10px; z-index: 4;
  border: 1px solid rgba(255,255,255,0.24); border-radius: 999px;
  padding: 5px 9px; color: #fff; background: rgba(5,8,14,0.78);
  font-size: 11px; font-weight: 700; cursor: pointer;
}
.tile-talkback:hover, .tile-talkback.active {
  background: rgba(220,50,65,0.9); border-color: #ff8792;
}
.tile-talkback-panel {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  padding-top: 8px; border-top: 1px solid var(--border-soft);
}
.tile-talkback-panel .tile-talkback {
  position: static; flex: 0 0 auto;
}
.talkback-status {
  min-width: 55px; color: var(--text-dim); font-size: 11px; font-weight: 700;
}
.talkback-meter {
  display: flex; align-items: end; gap: 2px; height: 22px; margin-left: auto;
}
.talkback-meter i {
  width: 4px; height: 4px; border-radius: 2px; background: var(--border);
  transition: height 80ms linear, background 80ms linear;
}
.talkback-meter i.active { background: var(--ok); }
.reporter-ifb-meter {
  display: flex; align-items: end; gap: 3px; height: 24px; margin-top: 9px;
  padding: 5px 7px; border-radius: 7px; background: var(--bg-input);
}
.reporter-ifb-meter i {
  width: 6px; height: 4px; border-radius: 2px; background: var(--border);
  transition: height 80ms linear, background 80ms linear;
}
.reporter-ifb-meter i.active { background: var(--ok); }
.reporter-ifb-meter span { margin-left: auto; color: var(--text-faint); font-size: 9px; font-weight: 700; }
.studio-inbox-list { display: flex; flex-direction: column; gap: 9px; }
.studio-inbox-card { padding: 10px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-card-hover); }
.studio-inbox-card.emergency { border-left: 3px solid var(--danger); }
.studio-inbox-card .inbox-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.studio-inbox-card .inbox-body { margin-top: 4px; color: var(--text-dim); font-size: 12px; white-space: pre-wrap; }
.studio-inbox-card .inbox-ignore { float: right; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; }
.tile-dashboard {
  margin-top: 7px; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); background: var(--bg-card);
  font-size: 10px;
}
.tile-analytics-head, .tile-bandwidth { display: flex; justify-content: space-between; gap: 6px; }
.tile-analytics-head { color: #9fc7ff; font-size: 10px; margin-bottom: 6px; }
.tile-analytics-head strong { color: #fff; font-variant-numeric: tabular-nums; }
.tile-bandwidth { color: #9eacbd; }
.tile-bandwidth strong { color: #70e6ad; }
.tile-bandwidth-graph { height: 22px; display: flex; align-items: end; gap: 2px; margin: 4px 0 7px; border-bottom: 1px solid rgba(255,255,255,0.14); }
.tile-bandwidth-graph i { flex: 1; min-height: 2px; border-radius: 2px 2px 0 0; background: linear-gradient(180deg, #55d6ff, #3984ff); }
.tile-analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 7px; color: #8999ad; }
.tile-analytics-grid .metric-wide { grid-column: 1 / -1; }
.tile-analytics-grid b { display: block; color: #f0f5ff; font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .tile-meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 26px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.88));
  color: #fff; font-size: 12.5px;
}
.tile .tile-meta .name { font-weight: 700; font-size: 13.5px; }
.tile .tile-ctrl {
  position: absolute; left: 8px; right: 8px; bottom: 42px;
  z-index: 3; display: flex; flex-wrap: wrap; gap: 6px;
}
.tile .tile-toolbar {
  position: absolute; top: 10px; right: 10px;
  display: flex; gap: 6px;
  opacity: 0; transition: opacity 0.15s;
}
.tile:hover .tile-toolbar { opacity: 1; }
.tile .tile-toolbar button {
  background: rgba(0,0,0,0.65); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
}
.tile .tile-toolbar button:hover { background: var(--accent); border-color: var(--accent); color: #04121f; }
.tile.empty { display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 13px; background: var(--bg-card); border-style: dashed; }

/* ---------- meters ---------- */
.meter { height: 8px; background: #1b2231; border-radius: 6px; overflow: hidden; position: relative; }
.meter > span { display: block; height: 100%; border-radius: 6px; background: var(--ok); transition: width 0.3s ease, background 0.3s ease; }
.meter.warn > span { background: var(--warn); }
.meter.danger > span { background: var(--danger); }

.vu { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.vu .bar { width: 8px; border-radius: 3px; background: linear-gradient(180deg, var(--ok), var(--warn)); transition: height 0.06s linear; }
.vu .bar.hot { background: linear-gradient(180deg, var(--warn), var(--danger)); }

/* ---------- progress ---------- */
.progress-thin { height: 5px; background: #1b2231; border-radius: 6px; overflow: hidden; }
.progress-thin > div { height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.4s ease; }

/* ---------- forms ---------- */
.rls-input, .rls-select, .rls-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 13px;
  font-size: 14px;
}
.rls-input:focus, .rls-select:focus, .rls-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,166,255,0.18); }
.rls-input::placeholder, .rls-textarea::placeholder { color: var(--text-faint); }

.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }

/* ---------- tables ---------- */
.rls-table { width: 100%; border-collapse: collapse; }
.rls-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.rls-table td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: middle; }
.rls-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ---------- flash / toasts ---------- */
.rls-toast {
  position: fixed; top: 74px; right: 18px; z-index: 2000;
  min-width: 300px; max-width: 420px;
  padding: 13px 16px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow); color: var(--text);
  animation: slideIn 0.25s ease;
  display: flex; gap: 10px; align-items: flex-start;
}
.rls-toast.success { border-left: 4px solid var(--ok); }
.rls-toast.danger { border-left: 4px solid var(--danger); }
.login-sequence { display: flex; justify-content: center; align-items: center; height: 112px; margin: -8px 0 16px; }
.login-sequence img { display: block; max-width: 220px; max-height: 112px; width: auto; height: auto; object-fit: contain; }
.rls-toast.warning { border-left: 4px solid var(--warn); }
.rls-toast.info { border-left: 4px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- live control bar ---------- */
.ctrl-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ctrl-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg-card-hover); border: 1px solid var(--border);
  padding: 8px 13px; border-radius: 10px; font-weight: 600; font-size: 13px;
  cursor: pointer; transition: all 0.15s; color: var(--text);
}
.ctrl-chip:hover { border-color: var(--accent); }
.ctrl-chip.active { background: rgba(46,166,255,0.15); border-color: var(--accent); color: #7ec3ff; }
.ctrl-chip.danger.active { background: rgba(255,46,63,0.16); border-color: var(--onair); color: #ffb3bb; }

/* ---------- misc ---------- */
.divider { border-top: 1px solid var(--border); margin: 16px 0; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--bg-card-hover); }
.avatar.lg { width: 72px; height: 72px; }
.onair-banner {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(90deg, rgba(255,46,63,0.18), rgba(255,46,63,0.05));
  border: 1px solid rgba(255,46,63,0.4);
  padding: 12px 18px; border-radius: var(--radius);
  font-weight: 700; color: #ffb3bb;
}
.onair-banner .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--onair); box-shadow: 0 0 14px var(--onair); animation: blink 1s infinite; }

.resizable { resize: both; overflow: auto; }

/* auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 600px at 70% -10%, rgba(46,166,255,0.12), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 34px; border-radius: 18px; background: var(--bg-card); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* status light row for studio */
.status-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 8px; background: var(--bg-card-hover); border: 1px solid var(--border); font-size: 12px; color: var(--text-dim); }

/* chat bubbles */
.chat-box { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 6px 2px; }
.chat-msg { max-width: 78%; padding: 10px 13px; border-radius: 12px; background: var(--bg-card-hover); border: 1px solid var(--border); font-size: 13.5px; }
.chat-msg.me { align-self: flex-end; background: rgba(46,166,255,0.14); border-color: rgba(46,166,255,0.35); }
.chat-msg .who { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.chat-msg .when { font-size: 10.5px; color: var(--text-faint); margin-top: 4px; text-align: right; }

/* print-friendly empty state */
.empty-state { text-align: center; padding: 46px 18px; color: var(--text-faint); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }

/* waveform meter header */
.rec-indicator { display: inline-flex; align-items: center; gap: 8px; color: var(--onair); font-weight: 700; }
.rec-indicator .rec { width: 11px; height: 11px; border-radius: 50%; background: var(--onair); animation: blink 1s infinite; }

/* map pin list */
.map-legend { font-size: 12px; color: var(--text-dim); }

@media print {
  .rls-sidebar, .rls-topbar { display: none !important; }
  .rls-main { margin: 0; }
}
