/* ============================================================
   Design tokens
   Concept: a broadcast control room. The call is "on air"; the
   tally light, mixing-console control bar, and mono readouts for
   timestamps/transcript are the signature elements.
   ============================================================ */
:root {
  --bg: #14151A;
  --panel: #1B1D24;
  --panel-raised: #22242D;
  --line: #2C2F3A;
  --text: #EDEEF0;
  --text-muted: #8B8D98;
  --accent: #FF5A36;      /* tally / on-air amber-red */
  --accent-dim: #99361F;
  --live: #3ECF8E;        /* connected / good status */
  --danger: #FF4D4D;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}
button { font-family: inherit; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }

/* ---------- shared ---------- */
.screen { min-height: 100vh; width: 100%; }
.btn {
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: #454857; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #17110D; }
.btn-primary:hover { background: #ff6d4c; border-color: #ff6d4c; }
.btn-ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.tally {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  box-shadow: none;
}
.tally.live {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,90,54,0.18);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255,90,54,0.18); }
  50% { box-shadow: 0 0 0 6px rgba(255,90,54,0.28); }
}
@media (prefers-reduced-motion: reduce) {
  .tally.live { animation: none; }
}

/* ============================================================
   Join screen
   ============================================================ */
.join-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(circle at 15% 10%, rgba(255,90,54,0.08), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(62,207,142,0.06), transparent 40%),
    var(--bg);
}
.join-card {
  width: 100%;
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px;
}
.brand-name {
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--text-muted);
}
.join-card h1 {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1.15;
  margin: 0 0 10px;
}
.sub { color: var(--text-muted); font-size: 14.5px; line-height: 1.55; margin: 0 0 28px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.field input {
  width: 100%;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }

.join-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.join-error {
  margin-top: 14px; color: var(--danger); font-size: 13px;
}

.device-check { margin-top: 28px; }
.device-check video {
  width: 100%; aspect-ratio: 16/10; object-fit: cover;
  background: #0C0D10; border-radius: 10px; border: 1px solid var(--line);
  transform: scaleX(-1);
}
.device-controls { display: flex; gap: 8px; margin-top: 10px; }

.pill-toggle {
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.pill-toggle[data-on="false"] {
  background: rgba(255,77,77,0.12);
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================================
   Call screen
   ============================================================ */
.call-screen { display: flex; flex-direction: column; height: 100vh; }

.call-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.room-label { font-size: 13px; letter-spacing: 0.04em; color: var(--text-muted); }
.header-right { display: flex; align-items: center; gap: 14px; }

.call-body { flex: 1; display: flex; overflow: hidden; }

.video-grid {
  flex: 1;
  display: grid;
  gap: 10px;
  padding: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-content: start;
  overflow-y: auto;
}
.video-tile {
  position: relative;
  background: #0C0D10;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 16/10;
}
.video-tile video {
  width: 100%; height: 100%; object-fit: cover;
}
.video-tile.mirrored video { transform: scaleX(-1); }
.video-tile .name-tag {
  position: absolute; left: 10px; bottom: 10px;
  background: rgba(12,13,16,0.72);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  display: flex; align-items: center; gap: 6px;
}
.video-tile .mute-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--danger);
  display: none;
}
.video-tile[data-muted="true"] .mute-dot { display: inline-block; }
.video-tile.speaking { border-color: var(--live); box-shadow: 0 0 0 2px rgba(62,207,142,0.25); }

.side-panel {
  width: 340px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.side-panel-tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab-btn {
  flex: 1; background: transparent; border: none; color: var(--text-muted);
  padding: 12px 8px; font-size: 12.5px; letter-spacing: 0.03em; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-panel { flex: 1; display: flex; flex-direction: column; padding: 14px; overflow: hidden; }
.scroll-log { flex: 1; overflow-y: auto; font-size: 13.5px; line-height: 1.5; }
.scroll-log .entry { margin-bottom: 10px; }
.scroll-log .entry .who { color: var(--accent); font-weight: 600; margin-right: 6px; }
.scroll-log .entry .ts { color: var(--text-muted); font-size: 11px; margin-left: 6px; }

.panel-input-row { display: flex; gap: 8px; margin-top: 10px; }
.panel-input-row input {
  flex: 1; background: var(--panel-raised); border: 1px solid var(--line);
  color: var(--text); padding: 10px 12px; border-radius: 8px; outline: none; font-size: 13.5px;
}
.panel-input-row input:focus { border-color: var(--accent); }

.hint { color: var(--text-muted); font-size: 12px; margin-top: 10px; line-height: 1.5; }
.notes-output {
  margin-top: 14px; font-size: 13.5px; line-height: 1.6; overflow-y: auto;
  white-space: pre-wrap;
}
.notes-output h2 { font-size: 14px; font-family: var(--font-display); margin: 16px 0 6px; }

/* ---------- control console ---------- */
.control-console {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.console-group { display: flex; gap: 10px; }
.console-btn {
  min-width: 64px; height: 56px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
}
.console-btn .icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
}
.console-btn .icon svg { width: 20px; height: 20px; display: block; }
.console-btn .btn-label {
  font-size: 10px;
  letter-spacing: 0.03em;
  color: inherit;
}
.console-btn:hover { border-color: #454857; }
.console-btn[data-on="false"] {
  background: rgba(255,77,77,0.14);
  border-color: var(--danger);
  color: var(--danger);
}
.console-btn.active-toggle {
  background: rgba(255,90,54,0.16);
  border-color: var(--accent);
  color: var(--accent);
}
.console-btn.leave {
  background: var(--danger);
  border-color: var(--danger);
  color: #1A0B0B;
  font-weight: 700;
}

@media (max-width: 860px) {
  .side-panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 20; }
  .console-btn { min-width: 52px; font-size: 11px; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   Device settings modal
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10,11,14,0.6);
  display: flex; align-items: center; justify-content: center;
}
.settings-modal {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px;
}
.settings-modal h2 {
  font-family: var(--font-display); font-size: 18px; margin: 0 0 18px;
}
.settings-modal select {
  width: 100%;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.settings-modal select:focus { border-color: var(--accent); }
.settings-modal .btn { margin-top: 8px; width: 100%; }

/* ============================================================
   Reactions
   ============================================================ */
.reactions-popover {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
}
.reaction-emoji {
  background: transparent; border: none; font-size: 22px; cursor: pointer;
  border-radius: 8px; padding: 4px 6px; line-height: 1;
}
.reaction-emoji:hover { background: var(--panel-raised); }

.floating-reaction {
  position: absolute;
  bottom: 46px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 30px;
  animation: float-up 1.6s ease-out forwards;
  pointer-events: none;
}
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .floating-reaction { animation: none; opacity: 0; }
}

/* ============================================================
   Raised hand badge
   ============================================================ */
.hand-badge {
  position: absolute; top: 10px; right: 10px;
  background: var(--accent);
  color: #17110D;
  font-size: 16px;
  border-radius: 8px;
  padding: 4px 7px;
  display: none;
}
.video-tile[data-hand="true"] .hand-badge { display: inline-block; }

/* ============================================================
   Speaker / pinned view
   ============================================================ */
.video-grid.speaker-mode {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.video-grid.speaker-mode .video-tile {
  aspect-ratio: unset;
}
.video-grid.speaker-mode .filmstrip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-top: 10px;
  flex-shrink: 0;
}
.video-grid.speaker-mode .filmstrip .video-tile {
  flex: 0 0 180px;
  aspect-ratio: 16/10;
}
.video-grid.speaker-mode .main-stage {
  flex: 1;
  min-height: 0;
  display: flex;
}
.video-grid.speaker-mode .main-stage .video-tile {
  flex: 1;
  min-height: 0;
  width: 100%;
}
/* the pinned/main-stage tile is where screen shares land — show the
   whole share uncropped instead of zooming/cropping it */
.video-grid.speaker-mode .main-stage .video-tile video {
  object-fit: contain;
  background: #000;
}
.video-tile.pinned { border-color: var(--accent); }
.video-tile.pinned .fullscreen-btn { opacity: 1; } /* always visible on the focused tile, not just on hover */
.video-tile .pin-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(12,13,16,0.0);
  color: transparent;
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.video-tile:hover .pin-hint {
  background: rgba(12,13,16,0.25);
  color: var(--text);
}

/* ============================================================
   Side panel close button + mobile backdrop
   ============================================================ */
.side-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.side-panel-title {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  color: var(--text-muted); text-transform: uppercase;
}
.side-panel-close-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.side-panel-close-btn:hover { background: var(--danger); border-color: var(--danger); color: #1A0B0B; }
.side-panel-backdrop {
  display: none;
}
@media (max-width: 860px) {
  .side-panel { width: 100%; }
  .side-panel-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(10,11,14,0.5);
    z-index: 19;
  }
}

/* ============================================================
   Fullscreen button on tiles
   ============================================================ */
.video-tile .fullscreen-btn {
  position: absolute; top: 10px; left: 10px;
  background: rgba(12,13,16,0.72);
  border: none;
  color: var(--text);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.video-tile:hover .fullscreen-btn { opacity: 1; }
.video-tile:fullscreen { border-radius: 0; }
.video-tile:fullscreen video { object-fit: contain; background: #000; }

/* ============================================================
   Waiting room
   ============================================================ */
.admit-requests {
  position: fixed; top: 20px; right: 20px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px;
  width: 300px;
}
.admit-card {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
}
.admit-card .who {
  font-weight: 600; margin-bottom: 10px; font-size: 14px;
}
.admit-card .actions { display: flex; gap: 8px; }
.admit-card .actions .btn { flex: 1; padding: 8px 10px; font-size: 13px; }

/* ============================================================
   Breakout rooms panel
   ============================================================ */
.breakout-banner {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 45;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
}
.breakout-banner button {
  background: var(--accent); border: none; color: #17110D;
  font-weight: 600; font-size: 12px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
}

/* ============================================================
   Rooms overview (inside the breakout/rooms panel)
   ============================================================ */
.rooms-overview {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.rooms-overview-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.rooms-overview-header .btn { padding: 4px 10px; font-size: 11px; }
.rooms-overview-list {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 220px;
  overflow-y: auto;
}
.room-overview-item {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.room-overview-label {
  font-size: 13px; font-weight: 600; margin-bottom: 4px;
}
.room-overview-names {
  font-size: 12.5px; color: var(--text-muted); line-height: 1.5;
}

/* ============================================================
   View options menu
   ============================================================ */
.view-menu {
  position: fixed;
  bottom: 88px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 190px;
  z-index: 40;
}
.view-menu-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.view-menu-item:hover { background: var(--panel-raised); }
.view-menu-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.view-menu-item.active { color: var(--accent); }
