/* ============================================================
   ZXSPRD AI — MASTER DESIGN SYSTEM (Final Demo)
   Dark + Light themes, sidebar menus, responsive shell.
   ============================================================ */

:root {
  --blue: #3B82F6; --indigo: #6366F1; --green: #10B981;
  --amber: #F59E0B; --red: #EF4444; --cyan: #22D3EE;
  --tenant-accent: #3B82F6;
  --radius: 14px; --radius-lg: 20px; --radius-xl: 28px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

html[data-theme="dark"] {
  --bg: #090D16; --panel: #0F172A; --panel-2: #111C30; --inset: #0B1220;
  --line: #1E293B; --line-soft: #182235;
  --text: #E2E8F0; --muted: #94A3B8; --dim: #64748B;
  --shadow-sm: 0 4px 14px rgba(0,0,0,.25); --shadow-md: 0 12px 32px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.55);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #F1F5F9; --panel: #FFFFFF; --panel-2: #F8FAFC; --inset: #EEF2F7;
  --line: #E2E8F0; --line-soft: #EDF1F6;
  --text: #0F172A; --muted: #475569; --dim: #94A3B8;
  --shadow-sm: 0 2px 8px rgba(15,23,42,.08); --shadow-md: 0 10px 28px rgba(15,23,42,.12);
  --shadow-lg: 0 20px 48px rgba(15,23,42,.16);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font-sans);
  font-size: 14px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
button:disabled { cursor: not-allowed; opacity: .45; }
img { max-width: 100%; display: block; }
::selection { background: var(--tenant-accent); color: #fff; }
:focus-visible { outline: 2px solid var(--tenant-accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); } .dim { color: var(--dim); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
svg.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 40; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--blue), var(--indigo)); display: grid; place-items: center; color: #fff; }
.brand-name { font-weight: 800; letter-spacing: -.02em; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.role-switch { display: flex; gap: 4px; padding: 4px; background: var(--inset); border: 1px solid var(--line); border-radius: 11px; flex-wrap: wrap; }
.role-btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); transition: all .18s; }
.role-btn:hover { color: var(--text); background: var(--panel-2); }
.role-btn.active, .role-btn[aria-pressed="true"] { background: var(--tenant-accent); color: #fff; }
.chrome-controls { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--tenant-accent); }
.mini-select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; font-size: 11px; color: var(--text); max-width: 120px; }
.impersonate-bar { background: repeating-linear-gradient(45deg, var(--amber), var(--amber) 12px, #b45309 12px, #b45309 24px); color: #1c1200; font-weight: 800; padding: 8px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; letter-spacing: .04em; }
.impersonate-bar button { background: #1c1200; color: var(--amber); padding: 5px 12px; border-radius: 8px; font-weight: 700; font-size: 11px; }

/* ---------- APP SHELL WITH SIDEBAR MENU ---------- */
.app-shell { display: flex; flex: 1; min-height: 0; }
.side-nav {
  width: 240px; flex-shrink: 0; border-right: 1px solid var(--line); background: var(--panel);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
  position: sticky; top: 63px; height: calc(100vh - 63px);
}
.side-nav-title { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); padding: 10px 12px 6px; font-weight: 700; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-align: left; width: 100%; transition: all .15s; }
.side-link:hover { background: var(--panel-2); color: var(--text); }
.side-link.active { background: var(--tenant-accent); color: #fff; }
.side-link svg.icon { width: 16px; height: 16px; }
.side-badge { margin-left: auto; font-style: normal; font-size: 10px; background: var(--red); color: #fff; border-radius: 20px; padding: 1px 7px; font-weight: 700; }
.side-link.active .side-badge { background: rgba(255,255,255,.25); }
.content-area { flex: 1; padding: 24px; min-width: 0; overflow-x: hidden; }
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .side-nav { position: static; height: auto; width: 100%; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 10px; }
  .side-nav-title { display: none; }
  .side-link { white-space: nowrap; }
  .content-area { padding: 14px; }
}

/* ---------- PANELS / CARDS ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; margin-bottom: 22px; }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.panel-title svg.icon { color: var(--tenant-accent); }
.panel-subtitle { font-size: 12px; color: var(--muted); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 22px; }
.stat-card { background: var(--inset); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.stat-value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; margin-top: 6px; }

/* ---------- BUTTONS / BADGES ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 10px; font-size: 12.5px; font-weight: 700; border: 1px solid transparent; transition: all .16s; }
.btn-blue { background: var(--tenant-accent); color: #fff; }
.btn-blue:hover { filter: brightness(1.12); }
.btn-green { background: var(--green); color: #04110b; }
.btn-red { background: var(--red); color: #fff; }
.btn-amber { background: var(--amber); color: #221600; }
.btn-ghost { background: var(--panel-2); border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--tenant-accent); }
.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: 8px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; border: 1px solid transparent; }
.badge-green { background: rgba(16,185,129,.13); color: var(--green); border-color: rgba(16,185,129,.3); }
.badge-red { background: rgba(239,68,68,.13); color: var(--red); border-color: rgba(239,68,68,.3); }
.badge-amber { background: rgba(245,158,11,.13); color: var(--amber); border-color: rgba(245,158,11,.3); }
.badge-blue { background: rgba(59,130,246,.13); color: var(--blue); border-color: rgba(59,130,246,.3); }
.badge-slate { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.status-dot.offline { background: var(--red); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ---------- TABLES ---------- */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tr:hover td { background: var(--inset); }

/* ---------- FORMS ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.form-input, .form-select, .form-textarea { background: var(--inset); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--text); width: 100%; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--tenant-accent); outline: none; }
.form-textarea { resize: vertical; min-height: 80px; }
input[type="range"] { accent-color: var(--tenant-accent); width: 100%; }
input[type="color"] { width: 46px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--inset); padding: 2px; }

/* Toggle switch */
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--line); border-radius: 24px; transition: .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.flag-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--inset); margin-bottom: 8px; }
.flag-row .flag-name { font-weight: 700; font-size: 13px; }
.flag-row .flag-desc { font-size: 11px; color: var(--muted); }

/* ---------- MODAL / TOAST ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(4,7,15,.72); backdrop-filter: blur(6px); z-index: 100; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-xl); width: 92%; max-width: 620px; padding: 28px; box-shadow: var(--shadow-lg); max-height: 92vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 17px; font-weight: 800; }
.close-btn { color: var(--muted); padding: 6px; border-radius: 8px; }
.close-btn:hover { color: var(--text); background: var(--panel-2); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); z-index: 200; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: all .25s var(--ease); max-width: 92vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- TRANSCRIPT ---------- */
.transcript-body { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 6px; }
.t-line { background: var(--inset); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px 14px; font-size: 13px; }
.t-meta { display: flex; gap: 10px; font-size: 10.5px; color: var(--dim); margin-bottom: 4px; font-family: var(--font-mono); }
.t-speaker { color: var(--tenant-accent); font-weight: 700; }

/* ---------- KIOSK ---------- */
.kiosk-shell { min-height: 100vh; display: flex; flex-direction: column; }
.kiosk-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 28px; background: linear-gradient(90deg, var(--panel), var(--panel-2)); border-bottom: 2px solid var(--tenant-accent); flex-wrap: wrap; gap: 10px; }
.kiosk-title { font-size: 22px; font-weight: 800; }
.kiosk-clock { font-family: var(--font-mono); font-size: 26px; font-weight: 700; color: var(--tenant-accent); }
.kiosk-main { flex: 1; display: grid; place-items: center; padding: 26px; }
.kiosk-card { width: min(860px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 34px; box-shadow: var(--shadow-md); }
.state-icon { width: 74px; height: 74px; border-radius: 50%; background: var(--tenant-accent-soft, rgba(59,130,246,.14)); display: grid; place-items: center; margin: 0 auto 18px; animation: pulse 2.4s infinite; }
.state-icon svg { width: 34px; height: 34px; color: var(--tenant-accent); }
.idle-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 18px; border-radius: 16px; font-size: 16px; font-weight: 800; margin-top: 14px; }
.idle-btn-primary { background: var(--tenant-accent); color: #fff; }
.idle-btn-secondary { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); }
.audio-meter { height: 10px; background: var(--inset); border: 1px solid var(--line-soft); border-radius: 8px; overflow: hidden; margin-top: 8px; }
.audio-meter-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--amber), var(--red)); transition: width .2s; border-radius: 8px; }
.meter-label { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--dim); font-family: var(--font-mono); margin-top: 4px; }
.ctrl-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px; border-radius: 12px; font-weight: 800; font-size: 13px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: pulse 1.2s infinite; display: inline-block; }
.broadcast-banner { background: var(--amber); color: #221600; font-weight: 800; padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.broadcast-close { color: #221600; }

/* ---------- SIGNAGE / PUBLIC DISPLAY ---------- */
.signage { min-height: 100vh; display: flex; flex-direction: column; }
.signage-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 34px; border-bottom: 1px solid var(--line); }
.signage-event { font-size: clamp(18px, 2vw, 30px); font-weight: 800; }
.signage-clock { font-family: var(--font-mono); font-size: clamp(20px, 2.4vw, 36px); color: var(--tenant-accent); font-weight: 700; }
.signage-slides { flex: 1; position: relative; overflow: hidden; }
.slide { position: absolute; inset: 0; padding: clamp(18px, 3vw, 44px); display: none; flex-direction: column; gap: 18px; opacity: 0; transition: opacity .6s; }
.slide.active { display: flex; opacity: 1; }
.trend-list { display: flex; flex-direction: column; gap: 12px; }
.trend-item { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; }
.trend-bar { flex: 1; height: 8px; background: var(--inset); border-radius: 8px; overflow: hidden; }
.trend-bar > div { height: 100%; background: linear-gradient(90deg, var(--tenant-accent), var(--cyan)); border-radius: 8px; transition: width 1s var(--ease); }
.countdown { display: flex; gap: 14px; }
.countdown-unit { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 20px; text-align: center; min-width: 90px; }
.countdown-num { font-family: var(--font-mono); font-size: clamp(28px, 4vw, 56px); font-weight: 800; color: var(--tenant-accent); }
.countdown-label { font-size: 11px; text-transform: uppercase; color: var(--dim); letter-spacing: .1em; }
.sponsor-strip { display: flex; gap: 18px; overflow: hidden; white-space: nowrap; }
.sponsor-chip { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px; display: inline-flex; gap: 10px; align-items: center; animation: slidein 12s linear infinite alternate; }
@keyframes slidein { from { transform: translateX(30px); } to { transform: translateX(-30px); } }
.ticker { border-top: 1px solid var(--line); background: var(--panel); overflow: hidden; white-space: nowrap; padding: 10px 0; }
.ticker-text { display: inline-block; animation: marquee 30s linear infinite; font-size: 14px; color: var(--muted); }
@keyframes marquee { from { transform: translateX(100vw); } to { transform: translateX(-100%); } }
.signage-progress { height: 3px; background: var(--inset); }
.signage-progress > div { height: 100%; background: var(--tenant-accent); width: 0; transition: width .2s linear; }

/* ---------- GUEST PORTAL (mobile PWA) ---------- */
.guest-app { max-width: 480px; margin: 0 auto; width: 100%; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.guest-header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.guest-body { flex: 1; padding: 20px; overflow-y: auto; padding-bottom: 90px; }
.dock { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(480px, 100%); display: flex; background: var(--panel); border-top: 1px solid var(--line); z-index: 50; }
.dock-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px; font-size: 10px; font-weight: 700; color: var(--dim); }
.dock-item.active { color: var(--tenant-accent); }
.dock-item svg.icon { width: 20px; height: 20px; }
.qr-frame { width: 190px; height: 190px; margin: 0 auto; position: relative; border-radius: 18px; background: #fff; padding: 12px; }
.qr-frame svg { width: 100%; height: 100%; }
.qr-scanline { position: absolute; left: 8px; right: 8px; height: 3px; background: linear-gradient(90deg, transparent, var(--tenant-accent), transparent); border-radius: 3px; top: 12px; animation: scanmove 2.2s ease-in-out infinite alternate; box-shadow: 0 0 12px var(--tenant-accent); }
.qr-corner { position: absolute; width: 26px; height: 26px; border: 3px solid var(--tenant-accent); }
.qr-corner.tl { top: -6px; left: -6px; border-right: none; border-bottom: none; border-radius: 10px 0 0 0; }
.qr-corner.tr { top: -6px; right: -6px; border-left: none; border-bottom: none; border-radius: 0 10px 0 0; }
.qr-corner.bl { bottom: -6px; left: -6px; border-right: none; border-top: none; border-radius: 0 0 0 10px; }
.qr-corner.br { bottom: -6px; right: -6px; border-left: none; border-top: none; border-radius: 0 0 10px 0; }
@keyframes scanmove { from { top: 12px; } to { top: calc(100% - 15px); } }
.qr-pulse { animation: qrpulse 2.2s ease-in-out infinite; }
@keyframes qrpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }
.session-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.chat-bubble { max-width: 85%; padding: 12px 15px; border-radius: 16px; margin-bottom: 10px; font-size: 13.5px; }
.chat-user { background: var(--tenant-accent); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.chat-ai { background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.voice-orb { width: 84px; height: 84px; border-radius: 50%; margin: 18px auto; background: radial-gradient(circle at 35% 35%, var(--cyan), var(--tenant-accent)); display: grid; place-items: center; color: #fff; box-shadow: 0 0 0 0 rgba(59,130,246,.5); }
.voice-orb.listening { animation: orb 1.4s infinite; }
@keyframes orb { 0% { box-shadow: 0 0 0 0 rgba(59,130,246,.5); } 70% { box-shadow: 0 0 0 26px rgba(59,130,246,0); } 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); } }

/* ---------- INDEX LAUNCHER ---------- */
.launch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.launch-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; display: flex; flex-direction: column; gap: 10px; transition: all .22s var(--ease); }
.launch-card:hover { transform: translateY(-4px); border-color: var(--tenant-accent); box-shadow: var(--shadow-md); }
.card-icon { width: 46px; height: 46px; border-radius: 13px; background: var(--inset); border: 1px solid var(--line); display: grid; place-items: center; color: var(--tenant-accent); }
.launch-card h3 { font-size: 16px; font-weight: 800; }
.launch-card p { font-size: 12px; color: var(--muted); flex: 1; }
main.page { flex: 1; padding: 26px; max-width: 1400px; margin: 0 auto; width: 100%; }
