/* ============================================================
   Admin Console Styles
   Requires: tokens.css loaded first, Tailwind CDN
============================================================ */

/* Self-hosted Nunito Sans — primary admin UI font (TTFs in css/Nunito_Sans/) */
@font-face { font-family: 'Nunito Sans'; font-weight: 300; font-style: normal; font-display: swap; src: url('Nunito_Sans/NunitoSans-Light.ttf') format('truetype'); }
@font-face { font-family: 'Nunito Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('Nunito_Sans/NunitoSans-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Nunito Sans'; font-weight: 400; font-style: italic;  font-display: swap; src: url('Nunito_Sans/NunitoSans-Italic.ttf') format('truetype'); }
@font-face { font-family: 'Nunito Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('Nunito_Sans/NunitoSans-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Nunito Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('Nunito_Sans/NunitoSans-Bold.ttf') format('truetype'); }
@font-face { font-family: 'Nunito Sans'; font-weight: 700; font-style: italic;  font-display: swap; src: url('Nunito_Sans/NunitoSans-BoldItalic.ttf') format('truetype'); }
@font-face { font-family: 'Nunito Sans'; font-weight: 800; font-style: normal; font-display: swap; src: url('Nunito_Sans/NunitoSans-ExtraBold.ttf') format('truetype'); }

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html, body { background: var(--bg); color: var(--ink); font-family: 'Nunito Sans', sans-serif; }
body { font-feature-settings: "ss01", "cv11"; }

.font-serif { font-family: 'Nunito Sans', sans-serif; font-weight: 800; letter-spacing: -0.02em; }
.font-mono  { font-family: 'JetBrains Mono', monospace; }

/* ---- Sidebar ---- */
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.nav-item { color: var(--sidebar-dim); transition: color .18s ease, background .18s ease; }
.nav-item:hover { color: var(--sidebar-ink); background: rgba(255,255,255,0.03); }
.nav-item.active { color: var(--sidebar-ink); background: rgba(255,255,255,0.05); }
.nav-item.active .nav-ic { color: var(--accent); }
.nav-ic { width: 17px; height: 17px; flex-shrink: 0; }

/* ---- Collapsible sidebar ---- */
.layout { transition: grid-template-columns .18s ease; }
.layout.nav-collapsed { grid-template-columns: 64px 1fr; }
.layout.nav-collapsed .nav-label,
.layout.nav-collapsed .nav-section-label,
.layout.nav-collapsed .badge { display: none; }
.layout.nav-collapsed .nav-item { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
.layout.nav-collapsed .sidebar > div:first-child { text-align: center; }
.layout.nav-collapsed #sidebarToggleIc { transform: rotate(180deg); }

/* ---- Cards ---- */
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 4px; }

/* ---- Tables ---- */
table { border-collapse: collapse; width: 100%; }
th {
  text-align: left; font-weight: 500; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
td { padding: 16px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #FBF9F4; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 500;
  border-radius: 3px; transition: all .15s ease; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--ink); color: #F6F3EC; }
.btn-primary:hover { background: #000; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: #FBF9F4; border-color: var(--ink-3); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: #9F6530; }
/* Broadcasting state: solid red, and black-with-red on hover. */
.btn-recording { background: #e02424; color: #fff; border-color: #e02424; }
.btn-recording:hover { background: #000; color: #fff; border-color: #e02424; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---- Status pills ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase; border-radius: 999px;
}
.pill-live, .pill-active { background: var(--live-soft); color: var(--live); }
.pill-offline            { background: #ECE8DE; color: var(--ink-3); }
.pill-draft, .pill-invited { background: var(--warn-soft); color: var(--warn); }
.pill-suspended          { background: var(--danger-soft); color: var(--danger); }
.pill-admin              { background: var(--ink); color: #F6F3EC; }
.pill-user               { background: var(--accent-soft); color: var(--accent); }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-live .pill-dot, .pill-active .pill-dot { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ---- Form inputs ---- */
input[type="text"],
input[type="number"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
  background: var(--bg-elev); border: 1px solid var(--line-2); border-radius: 3px;
  padding: 8px 12px; font-size: 13px; color: var(--ink); width: 100%;
  transition: all .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20,19,15,0.06);
}
input.mono, .input-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* Preview navigation dropdown (Branding & Preview) — custom-styled to match the site */
.preview-nav-wrap { position: relative; flex: 1; }
.preview-nav-select {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: var(--bg-elev); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 9px 36px 9px 36px; font-size: 13px; font-weight: 600; color: var(--ink);
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.preview-nav-select:hover { border-color: var(--ink-3); }
.preview-nav-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.preview-nav-wrap .preview-nav-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; pointer-events: none; color: var(--ink-3); }
.preview-nav-wrap .preview-nav-chev { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; pointer-events: none; color: var(--ink-3); }

/* ---- Toggle switch ---- */
.toggle {
  position: relative; width: 32px; height: 18px;
  background: var(--line-2); border-radius: 999px; cursor: pointer;
  transition: background .2s ease; flex-shrink: 0;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; background: white; border-radius: 50%;
  transition: transform .2s ease; box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle.on { background: var(--ink); }
.toggle.on::after { transform: translateX(14px); }

/* ---- Color swatches ---- */
.swatch { width: 22px; height: 22px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.08); cursor: pointer; flex-shrink: 0; }
.swatch.selected { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 3px var(--ink); }

/* ---- Layout ---- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.main { padding: 32px 40px 64px; max-width: 1400px; }

/* ---- Tabs ---- */
.tab {
  padding: 10px 0; font-size: 13px; color: var(--ink-3);
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: all .15s ease; font-weight: 500;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ---- VU meter ---- */
.vu-bar { display: flex; gap: 1.5px; height: 100%; align-items: stretch; }
.vu-segment { flex: 1; background: rgba(255,255,255,0.1); border-radius: 1px; transition: background .04s linear; }
.vu-segment.active-low  { background: var(--live); }
.vu-segment.active-mid  { background: var(--warn); }
.vu-segment.active-high { background: var(--danger); }

/* ---- Audio player (booth preview) ---- */
.audio-player {
  background: linear-gradient(135deg, #1A1816 0%, #0F0E0C 100%);
  border-radius: 8px; padding: 32px; color: #E8E4DA;
}
.play-btn {
  width: 64px; height: 64px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s ease; border: none;
}
.play-btn:hover  { transform: scale(1.04); background: #C98950; }
.play-btn:active { transform: scale(0.98); }

/* ---- Volume / gain slider ---- */
.vol-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 3px; background: rgba(255,255,255,0.15); border-radius: 2px; outline: none; }
.vol-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; background: #E8E4DA; border-radius: 50%; cursor: pointer; }
.vol-slider::-moz-range-thumb    { width: 14px; height: 14px; background: #E8E4DA; border-radius: 50%; cursor: pointer; border: none; }

/* ---- Connection indicator ---- */
.conn-dot { width: 8px; height: 8px; border-radius: 50%; }
.conn-live { background: var(--live); box-shadow: 0 0 0 3px var(--live-soft); animation: pulse 1.6s ease-in-out infinite; }
.conn-off  { background: var(--ink-3); }

/* ---- Section eyebrow ---- */
.section-eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar       { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ---- View fade animation ---- */
.view { animation: fadeIn .25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Booth card (front-page preview) ---- */
.booth-card {
  border: 1px solid var(--line); border-radius: 6px; padding: 20px;
  cursor: pointer; transition: all .2s ease; background: var(--bg-elev);
}
.booth-card:hover { border-color: var(--ink-3); transform: translateY(-2px); box-shadow: 0 8px 24px -12px rgba(0,0,0,0.08); }

/* ---- Live waveform animation ---- */
.waveform { display: flex; align-items: center; gap: 2px; height: 24px; }
.wave-bar { width: 2px; background: var(--accent); border-radius: 1px; animation: wave 1.2s ease-in-out infinite; }
@keyframes wave {
  0%, 100% { height: 20%; }
  50%       { height: 90%; }
}

/* ---- Utilities ---- */
.hidden   { display: none !important; }
.div-line { height: 1px; background: var(--line); }

/* ---- Badge (sidebar count) ---- */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: rgba(255,255,255,0.08); font-size: 10px; font-weight: 500;
  color: var(--sidebar-ink);
}

/* ---- Stat tile ---- */
.stat-num { font-family: 'Nunito Sans', sans-serif; font-size: 44px; line-height: 1; color: var(--ink); font-weight: 800; letter-spacing: -0.02em; }

/* ---- Bandwidth bar ---- */
.bw-bar  { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bw-fill { height: 100%; background: var(--live); transition: width .4s ease; }

/* ---- Avatar ---- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500; color: white; flex-shrink: 0;
}

/* ---- Analytics chart ---- */
.chart-container { height: 220px; position: relative; width: 100%; }
.chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-grid-line { width: 100%; height: 1px; background: var(--line); opacity: 0.6; }
.chart-svg { width: 100%; height: 100%; overflow: visible; }

/* ---- Tag pills (admin tag manager) ---- */
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; font-size: 11px; font-weight: 500;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  cursor: pointer; border: 1px solid transparent; transition: all .15s;
}
.tag-pill:hover { border-color: var(--accent); }
.tag-pill .remove { cursor: pointer; opacity: 0.6; font-size: 13px; line-height: 1; }
.tag-pill .remove:hover { opacity: 1; }

/* ---- Upload button ---- */
.upload-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  border-radius: 3px; cursor: pointer;
  background: var(--bg); border: 1px dashed var(--line-2);
  color: var(--ink-2); transition: all .15s;
}
.upload-btn:hover { border-color: var(--ink-3); color: var(--ink); background: var(--bg-elev); }
.upload-btn input[type="file"] { display: none; }

/* ---- QR display ---- */
.qr-canvas-wrap { background: #fff; border-radius: 8px; padding: 12px; display: inline-block; }
.qr-canvas-wrap canvas, .qr-canvas-wrap img { display: block; border-radius: 4px; }

/* ---- Mobile phone preview frame ---- */
.phone-frame {
  width: 380px; max-width: 100%;
  border: 12px solid #15140f; border-radius: 42px;
  box-shadow: 0 16px 46px rgba(0,0,0,0.30);
  overflow: hidden; background: #000; position: relative;
}
.phone-frame iframe { width: 100%; height: 700px; border: none; display: block; background: #fff; }

/* ---- Branding accordion ---- */
#branding-tab-container .acc-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
#branding-tab-container .acc-chev { font-size: 12px; color: var(--ink-3); transition: transform .2s ease; }
#branding-tab-container .acc-collapsed .acc-chev { transform: rotate(-90deg); }
#branding-tab-container .acc-collapsed .acc-header { margin-bottom: 0 !important; }
#branding-tab-container .acc-collapsed .acc-body { display: none; }

/* ---- Dark mode overrides ---- */
[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
[data-theme="dark"] .card { background: var(--bg-elev); border-color: var(--line); }
[data-theme="dark"] table tbody tr:hover { background: #2A2825; }
[data-theme="dark"] th { color: var(--ink-3); border-bottom-color: var(--line); }
[data-theme="dark"] td { border-bottom-color: var(--line); }
[data-theme="dark"] .btn-ghost { border-color: var(--line-2); color: var(--ink); }
[data-theme="dark"] .btn-ghost:hover { background: var(--line); }
/* In dark mode the primary button uses the brand accent (#00bdf6), not the
   light-mode ink fill (which would turn near-white on a dark background). */
[data-theme="dark"] .btn-primary { background: var(--accent); color: #002b36; }
[data-theme="dark"] .btn-primary:hover { background: #33ccf8; }
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: #1E1C1A; border-color: var(--line-2); color: var(--ink); }
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(232,228,218,0.06); }
[data-theme="dark"] .booth-card { background: var(--bg-elev); border-color: var(--line); }
[data-theme="dark"] .booth-card:hover { border-color: var(--ink-3); }
[data-theme="dark"] .div-line { background: var(--line); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--line-2); }
[data-theme="dark"] .section-eyebrow { color: var(--ink-3); }
[data-theme="dark"] .stat-num { color: var(--ink); }
[data-theme="dark"] .toggle { background: var(--line-2); }
[data-theme="dark"] .toggle.on { background: var(--sidebar-ink); }
[data-theme="dark"] .swatch.selected { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 3px var(--sidebar-ink); }
[data-theme="dark"] .upload-btn { background: var(--bg-elev); border-color: var(--line-2); color: var(--ink-2); }
[data-theme="dark"] .upload-btn:hover { border-color: var(--ink-3); color: var(--ink); background: var(--line); }
[data-theme="dark"] .tag-pill { background: var(--accent-soft); color: var(--accent); }

/* ============================================================
   RESPONSIVE — tablets & phones
   The admin shipped desktop-only (fixed 240px sidebar grid). These rules turn
   the sidebar into an off-canvas drawer, make tables scroll, collapse the stat
   grids, and fit modals to the screen.
============================================================ */
.mobile-nav-btn { display: none; }
#mobileNavScrim  { display: none; }

@media (max-width: 860px) {
  /* Single column; sidebar becomes an off-canvas drawer. */
  .layout,
  .layout.nav-collapsed { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 248px; max-width: 84vw; z-index: 80;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 2px 0 24px rgba(0,0,0,0.35);
    overflow-y: auto;
  }
  .layout.mobile-nav-open .sidebar { transform: translateX(0); }

  /* In the drawer, always show full labels even if the desktop "collapsed"
     state was saved in localStorage. */
  .layout.nav-collapsed .nav-label,
  .layout.nav-collapsed .nav-section-label,
  .layout.nav-collapsed .badge { display: revert; }
  .layout.nav-collapsed .nav-item { justify-content: flex-start; gap: .75rem; padding-left: .75rem; padding-right: .75rem; }
  .layout.nav-collapsed .sidebar > div:first-child { text-align: left; }
  /* The desktop collapse button is meaningless on mobile. */
  .sidebar [onclick="toggleSidebar()"] { display: none; }

  /* Dim backdrop behind the open drawer. */
  #mobileNavScrim {
    display: block; position: fixed; inset: 0; z-index: 70;
    background: rgba(0,0,0,0.5);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  .layout.mobile-nav-open #mobileNavScrim { opacity: 1; pointer-events: auto; }

  /* Hamburger in the top bar. */
  .mobile-nav-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 6px; flex-shrink: 0;
    background: var(--bg-elev); border: 1px solid var(--line);
    color: var(--ink); cursor: pointer;
  }

  /* Tighter chrome so content gets the width. */
  main > header { padding-left: 16px; padding-right: 16px; }
  .main { padding: 20px 16px 56px; }

  /* Collapse multi-column grids (stats, branding panels, etc.). */
  .grid-cols-5, .grid-cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr !important; }
  /* Two-column "main + side" splits stack. */
  .col-span-2 { grid-column: auto !important; }

  /* Wide tables scroll horizontally instead of crushing their columns. */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }

  /* Modals / sign-in card fit the viewport. */
  #modalRoot .card, #authRoot .card { width: 92vw !important; max-width: 92vw !important; }
}

@media (max-width: 520px) {
  .grid-cols-5, .grid-cols-4 { grid-template-columns: 1fr !important; }
  main > header { padding-top: 12px; padding-bottom: 12px; }
}
