/* ============================================================================
   MUN Suite — shared design system
   An institutional, UN-document-inspired theme: deep navy, a restrained
   brass/gold accent used sparingly for primary actions and emphasis, a
   serif wordmark/display face paired with a clean sans for dense UI, and a
   single reusable "globe" emblem as the brand mark throughout.
   Built entirely as CSS variables so a conference can restyle
   (theme_color from the conferences table) without touching structure —
   and every class name below is referenced from the page scripts, so keep
   the names stable even if you retune the values.
   ============================================================================ */

:root {
  /* ---- Ink & brand ---- */
  --navy-950: #0a1830;
  --navy-900: #0f2039;
  --navy-850: #122647;
  --navy-800: #14294d;
  --navy-700: #1b3760;
  --navy-600: #25497f;
  --blue-500: #3268ac;
  --blue-100: #e9eff8;

  --gold-600: #9c7a1f;
  --gold-500: #c49a2f;
  --gold-400: #d7b556;
  --gold-100: #f7eed2;

  --green-600: #1c7a52;
  --green-100: #e1f3ea;
  --red-600: #b83c3c;
  --red-100: #fbeaea;
  --amber-600: #a8711a;
  --amber-100: #faf0da;

  /* ---- Neutrals (cool, museum-paper undertone) ---- */
  --gray-25: #fbfbfc;
  --gray-50: #f5f6f8;
  --gray-100: #ebedf1;
  --gray-200: #dde1e7;
  --gray-300: #c4cad4;
  --gray-400: #9aa3b2;
  --gray-500: #6b7482;
  --gray-600: #4c5563;
  --gray-700: #364152;
  --gray-900: #161b24;
  --white: #ffffff;

  --ink: #161b24;

  /* ---- Type ---- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 11.5px;
  --text-sm: 12.5px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 21px;
  --text-2xl: 26px;
  --text-3xl: 34px;

  /* ---- Shape & elevation ---- */
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(10, 24, 48, 0.06), 0 1px 1px rgba(10, 24, 48, 0.04);
  --shadow-md: 0 6px 20px rgba(10, 24, 48, 0.10);
  --shadow-lg: 0 16px 40px rgba(10, 24, 48, 0.20);
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

* { box-sizing: border-box; }
/* Some components below (e.g. .modal-backdrop, .timer-controls) set an
   unconditional `display: flex`, which ties in CSS specificity with the
   browser's default `[hidden]{display:none}` rule — and author styles win
   ties over user-agent styles, so `el.hidden = true` would silently fail to
   hide them without this override. Keep this rule so `hidden` always wins. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--gray-50);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: var(--text-base);
  line-height: 1.5;
}

a { color: var(--blue-500); }
h1, h2, h3, h4 { font-weight: 700; margin: 0 0 0.4em; letter-spacing: -0.012em; color: var(--ink); }
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0 0 0.75em; line-height: 1.55; }
code { font-family: var(--font-mono); background: var(--gray-100); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }
::selection { background: var(--gold-100); color: var(--navy-900); }
:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.container-narrow { max-width: 580px; margin: 0 auto; padding: 24px 20px; }

/* ---- Small labels & brand mark -------------------------------------------- */
.eyebrow {
  display: block; font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--gold-600); margin-bottom: 6px;
}
.brand-word { font-family: var(--font-serif); font-weight: 600; letter-spacing: 0.01em; }
.brand-mark { color: var(--gold-400); flex-shrink: 0; display: inline-flex; }
.brand-mark svg { display: block; }

/* ---- App shell (chair / delegate / admin) ------------------------------ */
.app-shell { display: flex; min-height: 100vh; }
.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 22px; background: var(--navy-900); color: var(--white);
  box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 40;
  border-bottom: 2px solid var(--gold-500);
}
.app-topbar .brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: var(--text-lg); }
.app-topbar .brand .badge-mode { background: rgba(212, 178, 86, 0.16); color: var(--gold-400); border: 1px solid rgba(212, 178, 86, 0.35); }
.app-topbar .meta { font-size: var(--text-sm); color: var(--gray-300); }
.app-main { flex: 1; padding: 22px; max-width: 1400px; margin: 0 auto; width: 100%; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-main-side { grid-template-columns: 2.1fr 1fr; align-items: start; }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-main-side { grid-template-columns: 1fr; }
}

/* ---- Cards -------------------------------------------------------------- */
.card {
  background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  padding: 19px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; }
.card-subtitle { color: var(--gray-500); font-size: var(--text-sm); margin-top: -6px; margin-bottom: 12px; }

/* ---- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: var(--text-base); font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 9px 16px; transition: filter 0.12s var(--ease), transform 0.05s var(--ease), box-shadow 0.12s var(--ease);
  background: var(--navy-700); color: var(--white);
}
.btn:hover { filter: brightness(1.12); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); filter: brightness(1.02); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; filter: none; box-shadow: none; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { padding: 12px 22px; font-size: var(--text-md); }
.btn-secondary { background: var(--white); color: var(--navy-700); border-color: var(--gray-300); }
.btn-secondary:hover { border-color: var(--navy-600); filter: none; background: var(--gray-50); }
.btn-ghost { background: transparent; color: var(--navy-700); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); filter: none; }
.btn-gold { background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); color: var(--navy-950); }
.btn-danger { background: var(--red-600); color: var(--white); }
.btn-success { background: var(--green-600); color: var(--white); }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; }

/* ---- Forms -------------------------------------------------------------- */
label { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--gray-700); margin-bottom: 5px; letter-spacing: 0.01em; }
input, select, textarea {
  font-family: inherit; font-size: var(--text-base); width: 100%;
  padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  background: var(--white); color: var(--ink); transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--gray-400); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(50, 104, 172, 0.15); }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }
.hint { font-size: var(--text-xs); color: var(--gray-500); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ---- Badges / pills ------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; background: var(--gray-100); color: var(--gray-600);
  border: 1px solid transparent;
}
.badge-blue { background: var(--blue-100); color: var(--navy-700); }
.badge-green { background: var(--green-100); color: var(--green-600); }
.badge-red { background: var(--red-100); color: var(--red-600); }
.badge-amber { background: var(--amber-100); color: var(--amber-600); }
.badge-gold { background: var(--gold-100); color: var(--gold-600); }
.badge-mode { background: var(--navy-800); color: var(--gold-400); font-family: var(--font-mono); letter-spacing: 0.04em; }

/* ---- Tabs ---------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--gray-200); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  padding: 10px 15px; font-size: var(--text-sm); font-weight: 600; color: var(--gray-500);
  cursor: pointer; border-bottom: 2px solid transparent; user-select: none;
  transition: color 0.12s var(--ease), background 0.12s var(--ease); border-radius: 6px 6px 0 0;
  letter-spacing: 0.01em;
}
.tab:hover { color: var(--navy-700); background: var(--gray-50); }
.tab.active { color: var(--navy-800); border-bottom-color: var(--gold-500); font-weight: 700; }
.tab-panel { display: none; animation: fade-in 0.15s var(--ease); }
.tab-panel.active { display: block; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- Tables --------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-500); font-weight: 700; padding: 9px 10px; border-bottom: 1px solid var(--gray-200); }
td { padding: 10px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tbody tr { transition: background 0.1s var(--ease); }
tbody tr:hover { background: var(--gray-50); }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }

/* ---- Lists (speakers / queues) -------------------------------------------- */
.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.queue-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm); background: var(--gray-25);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.queue-item.speaking { border-color: var(--gold-500); background: var(--gold-100); box-shadow: var(--shadow-sm); }
.queue-item .pos { font-family: var(--font-mono); font-size: 12px; color: var(--gray-500); width: 20px; }
.queue-item .name { flex: 1; font-weight: 600; }
.flag { width: 22px; height: 16px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.08); flex-shrink: 0; }

/* ---- Timer -------------------------------------------------------------- */
.timer-block {
  text-align: center; padding: 16px 10px; border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--navy-900), var(--navy-850)); color: var(--white);
}
.timer-label { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold-400); margin-bottom: 6px; }
.timer-digits {
  font-family: var(--font-mono); font-size: 52px; font-weight: 700; line-height: 1;
  color: var(--white); font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}
.timer-digits.warn { color: var(--gold-400); }
.timer-digits.danger { color: #ff8a80; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.timer-sub { font-size: var(--text-sm); color: var(--gray-300); margin-top: 7px; min-height: 1.2em; }
.timer-controls { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* ---- Empty / helper states ------------------------------------------------ */
.empty-state { text-align: center; padding: 28px 10px; color: var(--gray-400); font-size: var(--text-sm); }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 14px 0; }
.scroll-box { max-height: 320px; overflow-y: auto; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: var(--text-sm); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---- Presence (who's connected) ------------------------------------------- */
.role-dot { display: inline-flex; align-items: center; gap: 7px; }
.role-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--gray-400); }
.role-dot-chair::before { background: var(--gold-500); }
.role-dot-delegate::before { background: var(--blue-500); }
.role-dot-secretariat::before { background: var(--navy-700); }
.role-dot-press::before { background: var(--gray-400); }
.role-dot-tag { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-400); }

/* ---- Toasts --------------------------------------------------------------- */
#toast-root { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: var(--navy-900); color: var(--white); padding: 11px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 340px; animation: toast-in 0.18s var(--ease);
  border-left: 3px solid var(--gold-500);
}
.toast.error { background: var(--red-600); border-left-color: #ffb4b4; }
.toast.success { background: var(--green-600); border-left-color: #b7f0d3; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---- Modal ------------------------------------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 20, 40, 0.6); display: flex;
  align-items: center; justify-content: center; z-index: 200; padding: 20px;
  backdrop-filter: blur(1.5px); animation: fade-in 0.12s var(--ease);
}
.modal {
  background: var(--white); border-radius: var(--radius-lg); padding: 24px; max-width: 480px; width: 100%;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
  border-top: 3px solid var(--gold-500); animation: modal-in 0.16s var(--ease);
}
@keyframes modal-in { from { transform: translateY(6px) scale(0.99); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Landing / join screen ------------------------------------------------ */
body.landing {
  background:
    radial-gradient(880px 480px at 50% -120px, rgba(196, 154, 47, 0.10), transparent 60%),
    radial-gradient(1000px 600px at 50% 0%, var(--navy-900), var(--navy-950) 70%);
  min-height: 100vh;
}
.landing-hero { text-align: center; padding: 52px 0 26px; color: var(--white); }
.landing-hero .hero-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px;
  border-radius: 50%; background: rgba(212, 178, 86, 0.12); border: 1px solid rgba(212, 178, 86, 0.4);
  color: var(--gold-400); margin-bottom: 18px;
}
.landing-hero .eyebrow { color: var(--gold-400); }
.landing-hero h1 { font-family: var(--font-serif); font-size: var(--text-3xl); color: var(--white); letter-spacing: -0.01em; }
.landing-hero p { color: var(--gray-300); max-width: 440px; margin-left: auto; margin-right: auto; }
.container-narrow > .card, .container-narrow > .role-cards { color: var(--ink); }

.role-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
@media (max-width: 760px) { .role-cards { grid-template-columns: repeat(2, 1fr); } }
.role-card {
  border: 1px solid var(--gray-200); border-radius: var(--radius-md); background: var(--white);
  padding: 18px 12px; text-align: center; cursor: pointer; transition: all 0.14s var(--ease);
}
.role-card:hover { border-color: var(--navy-600); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.role-card.active { border-color: var(--gold-500); background: var(--gold-100); box-shadow: var(--shadow-sm); }
.role-card .icon { color: var(--navy-700); margin-bottom: 8px; display: flex; justify-content: center; }
.role-card.active .icon { color: var(--gold-600); }
.role-card .title { font-weight: 700; font-size: var(--text-base); }
.role-card .desc { font-size: var(--text-xs); color: var(--gray-500); margin-top: 2px; }

/* ---- Connection status pill ------------------------------------------------ */
.conn-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--gray-300);
  padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gray-500); transition: background 0.2s var(--ease); }
.conn-dot.live { background: #45d68a; box-shadow: 0 0 0 3px rgba(69, 214, 138, 0.22); }
.conn-dot.down { background: #ff7a7a; }

/* ---- Display / projector view --------------------------------------------- */
.display-body {
  background: radial-gradient(1200px 700px at 50% -10%, var(--navy-850), var(--navy-950) 65%);
  color: var(--white); min-height: 100vh;
}
.display-wrap { max-width: 1100px; margin: 0 auto; padding: 48px 24px; text-align: center; }
.display-mark { color: var(--gold-400); opacity: 0.85; margin-bottom: 8px; display: flex; justify-content: center; }
.display-speaker { font-family: var(--font-serif); font-size: 38px; font-weight: 600; margin: 10px 0; }
.display-committee { color: var(--gold-400); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: var(--text-sm); }
.display-timer {
  font-family: var(--font-mono); font-size: 148px; font-weight: 700; line-height: 1; margin: 14px 0;
  font-variant-numeric: tabular-nums; text-shadow: 0 4px 40px rgba(212, 178, 86, 0.15);
}
.display-timer.warn { color: var(--gold-400); }
.display-timer.danger { color: #ff8a80; }
.display-gsl { text-align: left; max-width: 480px; margin: 34px auto 0; border-top: 1px solid rgba(255,255,255,0.12); padding-top: 16px; }
.display-gsl-item { display: flex; justify-content: space-between; padding: 7px 2px; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 15.5px; }

/* ---- Utility scroll for chat/notes ---------------------------------------- */
.note-bubble { border-radius: var(--radius-sm); padding: 9px 12px; background: var(--gray-25); border: 1px solid var(--gray-200); font-size: 13.5px; }
.note-bubble .meta { font-size: 11px; color: var(--gray-500); margin-bottom: 3px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 6px; }
