/* ==========================================================================
   WATCHROOM GLOBAL THEME ARCHITECTURE & TOKEN SYSTEM
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap');

/* --------------------------------------------------------------------------
   1. GLOBAL THEME DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root,
html.dark,
body.dark,
[data-theme="dark"] {
  --theme-mode: dark;
  --bg-app-rgb: 20, 22, 29;
  --bg-app: #14161d;
  --bg-header: rgba(20, 22, 29, 0.92);
  --bg-footer: rgba(20, 22, 29, 0.95);
  --bg-modal: #181a22;
  --bg-inset: #13141b;
  --bg-input: #13141b;
  --bg-card: linear-gradient(145deg, #1c1f2a, #161821);
  --bg-convex: linear-gradient(145deg, #202330, #161821);
  --bg-flat: #181a22;
  --bg-btn: linear-gradient(145deg, #1e212c, #15171f);

  --text-primary: #ffffff;
  --text-secondary: #e2e8f0;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-brand: #ffffff;
  --text-accent: #38bdf8;
  --text-input: #ffffff;

  --border-subtle: rgba(255, 255, 255, 0.035);
  --border-card: rgba(255, 255, 255, 0.03);
  --border-nav: rgba(255, 255, 255, 0.04);
  --border-modal: rgba(255, 255, 255, 0.04);

  --shadow-flat: 7px 7px 16px rgba(0, 0, 0, 0.65), -5px -5px 12px rgba(255, 255, 255, 0.035);
  --shadow-card: 10px 10px 22px rgba(0, 0, 0, 0.7), -7px -7px 16px rgba(255, 255, 255, 0.035);
  --shadow-convex: 6px 6px 14px rgba(0, 0, 0, 0.6), -4px -4px 10px rgba(255, 255, 255, 0.04);
  --shadow-inset: inset 4px 4px 10px rgba(0, 0, 0, 0.75), inset -3px -3px 8px rgba(255, 255, 255, 0.025);
  --shadow-btn: 6px 6px 14px rgba(0, 0, 0, 0.7), -4px -4px 10px rgba(255, 255, 255, 0.04);
  --shadow-btn-hover: 8px 8px 18px rgba(0, 0, 0, 0.8), -5px -5px 12px rgba(255, 255, 255, 0.06);
  --shadow-btn-active: inset 3px 3px 8px rgba(0, 0, 0, 0.85), inset -2px -2px 6px rgba(255, 255, 255, 0.03);

  --pill-bg: linear-gradient(135deg, #0284c7, #0369a1);
  --pill-shadow: 0 0 20px rgba(2, 132, 199, 0.5), inset 1px 1px 2px rgba(255, 255, 255, 0.35);
  --power-btn-bg: radial-gradient(circle at 35% 30%, #38bdf8, #0284c7 60%, #0369a1 100%);
  --power-btn-shadow: 0 0 25px rgba(2, 132, 199, 0.65), 5px 5px 15px rgba(0, 0, 0, 0.7), -3px -3px 10px rgba(255, 255, 255, 0.1);

  --scrubber-head: linear-gradient(to right, #0284c7, #38bdf8, #67e8f9);
  --scrubber-well: #13141b;
  --scrubber-buffer: rgba(51, 65, 85, 0.5);

  --toast-bg: rgba(20, 22, 29, 0.95);
  --toast-border: rgba(56, 189, 248, 0.3);
  --modal-backdrop: rgba(10, 11, 16, 0.75);
}

html.light,
body.light,
[data-theme="light"] {
  --theme-mode: light;
  --bg-app-rgb: 230, 235, 242;
  --bg-app: #e6ebf2;
  --bg-header: rgba(230, 235, 242, 0.94);
  --bg-footer: rgba(230, 235, 242, 0.96);
  --bg-modal: #e6ebf2;
  --bg-inset: #dfe5ee;
  --bg-input: #dfe5ee;
  --bg-card: #e6ebf2;
  --bg-convex: linear-gradient(145deg, #f0f5fc, #dbe2ed);
  --bg-flat: #e6ebf2;
  --bg-btn: #e6ebf2;

  --text-primary: #0f172a;
  --text-secondary: #1e293b;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --text-brand: #0f172a;
  --text-accent: #2563eb;
  --text-input: #0f172a;

  --border-subtle: rgba(255, 255, 255, 0.75);
  --border-card: rgba(255, 255, 255, 0.85);
  --border-nav: rgba(203, 213, 225, 0.8);
  --border-modal: rgba(255, 255, 255, 0.9);

  --shadow-flat: 6px 6px 14px #c2c9d6, -6px -6px 14px #ffffff;
  --shadow-card: 8px 8px 18px #bcc5d3, -8px -8px 18px #ffffff;
  --shadow-convex: 5px 5px 12px #c2c9d6, -5px -5px 12px #ffffff;
  --shadow-inset: inset 4px 4px 8px #c2c8d4, inset -4px -4px 8px #ffffff;
  --shadow-btn: 4px 4px 10px #c2c9d6, -4px -4px 10px #ffffff;
  --shadow-btn-hover: 6px 6px 14px #b8c0cf, -6px -6px 14px #ffffff;
  --shadow-btn-active: inset 3px 3px 6px #bcc4d2, inset -3px -3px 6px #ffffff;

  --pill-bg: linear-gradient(135deg, #3b82f6, #2563eb);
  --pill-shadow: 4px 4px 12px rgba(37, 99, 235, 0.35), -2px -2px 6px #ffffff, inset 1px 1px 2px rgba(255, 255, 255, 0.4);
  --power-btn-bg: linear-gradient(135deg, #3b82f6, #2563eb);
  --power-btn-shadow: 5px 5px 14px rgba(37, 99, 235, 0.4), -5px -5px 14px #ffffff, inset 1px 1px 2px rgba(255, 255, 255, 0.5);

  --scrubber-head: linear-gradient(to right, #2563eb, #3b82f6);
  --scrubber-well: #dfe5ee;
  --scrubber-buffer: #cbd5e1;

  --toast-bg: rgba(230, 235, 242, 0.96);
  --toast-border: rgba(37, 99, 235, 0.4);
  --modal-backdrop: rgba(15, 23, 42, 0.45);
}

/* --------------------------------------------------------------------------
   2. BASE RESET & SCROLLBAR
   -------------------------------------------------------------------------- */
html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-app) !important;
  color: var(--text-secondary);
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: background-color 0.25s ease, color 0.25s ease;
}

html.light,
html.light body,
body.light,
html[data-theme="light"],
body[data-theme="light"] {
  background-color: #e6ebf2 !important;
  color: #1e293b !important;
}

html.dark,
html.dark body,
body.dark,
html[data-theme="dark"],
body[data-theme="dark"] {
  background-color: #14161d !important;
  color: #e2e8f0 !important;
}

::-webkit-scrollbar {
  width: 6px;
}
html.dark ::-webkit-scrollbar-track {
  background: #14161d;
}
html.dark ::-webkit-scrollbar-thumb {
  background: #252938;
  border-radius: 9999px;
}
html.light ::-webkit-scrollbar-track {
  background: #e6ebf2;
}
html.light ::-webkit-scrollbar-thumb {
  background: #c7d0de;
  border-radius: 9999px;
}

/* --------------------------------------------------------------------------
   3. UNIFIED NEUMORPHIC COMPONENT CLASSES
   -------------------------------------------------------------------------- */
.nm-flat, .nm-clay-flat {
  background: var(--bg-flat) !important;
  box-shadow: var(--shadow-flat) !important;
  border-color: var(--border-subtle) !important;
}

.nm-card, .nm-clay-card {
  background: var(--bg-card) !important;
  box-shadow: var(--shadow-card) !important;
  border-color: var(--border-card) !important;
}

.nm-convex, .nm-clay-convex {
  background: var(--bg-convex) !important;
  box-shadow: var(--shadow-convex) !important;
  border-color: var(--border-card) !important;
}

.nm-inset, .nm-clay-inset, .nm-clay-inset-deep {
  background: var(--bg-inset) !important;
  box-shadow: var(--shadow-inset) !important;
}

.nm-btn-circle, .nm-clay-btn {
  background: var(--bg-btn) !important;
  box-shadow: var(--shadow-btn) !important;
  border-color: var(--border-subtle) !important;
  color: var(--text-primary) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.nm-btn-circle:hover, .nm-clay-btn:hover {
  box-shadow: var(--shadow-btn-hover) !important;
  transform: translateY(-1px);
}
.nm-btn-circle:active, .nm-clay-btn:active {
  box-shadow: var(--shadow-btn-active) !important;
  transform: translateY(1px);
}

.nm-pill-active, .nm-clay-pill-active {
  background: var(--pill-bg) !important;
  box-shadow: var(--pill-shadow) !important;
  color: #ffffff !important;
}
.nm-pill-active *, .nm-clay-pill-active * {
  color: #ffffff !important;
}

.nm-power-btn, .nm-clay-power-btn {
  background: var(--power-btn-bg) !important;
  box-shadow: var(--power-btn-shadow) !important;
  color: #ffffff !important;
}
.nm-power-btn *, .nm-clay-power-btn * {
  color: #ffffff !important;
}

/* --------------------------------------------------------------------------
   4. LIGHT MODE GLOBAL THEME OVERRIDES
   -------------------------------------------------------------------------- */
/* Page Containers */
html.light .bg-nm-bg,
body.light .bg-nm-bg {
  background-color: var(--bg-app) !important;
}

html.light header {
  background-color: var(--bg-header) !important;
  border-bottom: 1px solid var(--border-nav) !important;
}

html.light footer {
  background-color: var(--bg-footer) !important;
  border-top: 1px solid var(--border-nav) !important;
}

/* Brand Name in Light Mode */
html.light header a .font-bold.text-xl {
  color: var(--text-primary) !important;
}

/* Typography Overrides in Light Mode (outside the cinematic video frame & blue pill buttons) */
html.light h1:not(.aspect-video *):not(.nm-pill-active *):not(.nm-power-btn *),
html.light h2:not(.aspect-video *):not(.nm-pill-active *):not(.nm-power-btn *),
html.light h3:not(.aspect-video *):not(.nm-pill-active *):not(.nm-power-btn *),
html.light h4:not(.aspect-video *):not(.nm-pill-active *):not(.nm-power-btn *),
html.light .text-white:not(.aspect-video *):not(.nm-pill-active *):not(.nm-power-btn *):not(.badge-fixed-white) {
  color: var(--text-primary) !important;
}

html.light .text-slate-200:not(.aspect-video *):not(.nm-pill-active *),
html.light .text-slate-300:not(.aspect-video *):not(.nm-pill-active *) {
  color: var(--text-secondary) !important;
}

html.light .text-slate-400:not(.aspect-video *):not(.nm-pill-active *) {
  color: var(--text-muted) !important;
}

html.light .text-slate-500:not(.aspect-video *):not(.nm-pill-active *) {
  color: var(--text-subtle) !important;
}

/* Borders in Light Mode */
html.light .border-white\/\[0\.02\],
html.light .border-white\/\[0\.03\],
html.light .border-white\/\[0\.04\],
html.light .border-white\/\[0\.05\] {
  border-color: var(--border-card) !important;
}

/* Top Navigation Rail in Light Mode */
html.light nav {
  background-color: var(--bg-inset) !important;
  box-shadow: var(--shadow-inset) !important;
}
html.light nav button.nm-convex {
  color: var(--text-primary) !important;
  background: var(--bg-convex) !important;
  box-shadow: var(--shadow-convex) !important;
}
html.light nav button:not(.nm-convex) {
  color: var(--text-muted) !important;
}
html.light nav button:not(.nm-convex):hover {
  color: var(--text-primary) !important;
}

/* Telemetry Pills in Light Mode */
html.light .nm-inset span.font-mono {
  color: var(--text-muted) !important;
}

/* Watch Room Sub-Nav Bar in Light Mode */
html.light #roomTitleDisplay {
  color: var(--text-primary) !important;
  font-weight: 800 !important;
}
html.light .telemetry-drift-label {
  color: var(--text-accent) !important;
}
html.light .viewer-count-label {
  color: var(--text-secondary) !important;
}

/* Scrubber & Video Controls in Light Mode */
html.light #scrubberTrack .nm-inset {
  background-color: var(--scrubber-well) !important;
}
html.light #scrubberTrack .bg-slate-700\/50 {
  background-color: var(--scrubber-buffer) !important;
}
html.light #scrubberProgress {
  background: var(--scrubber-head) !important;
}
html.light #currentTimeLabel {
  color: var(--text-primary) !important;
}
html.light #totalDurationLabel {
  color: var(--text-subtle) !important;
}
html.light .host-lock-indicator {
  color: var(--text-secondary) !important;
}
html.light .host-lock-indicator strong {
  color: var(--text-primary) !important;
}

/* Video Frame is ALWAYS cinematic dark in both themes */
.aspect-video {
  background-color: #000000 !important;
}
.aspect-video .text-white {
  color: #ffffff !important;
}

/* Chat & Participants in Light Mode */
html.light #participantsList .nm-convex {
  color: var(--text-secondary) !important;
}
html.light #chatMessages .nm-convex {
  color: var(--text-secondary) !important;
  background: var(--bg-convex) !important;
  box-shadow: var(--shadow-convex) !important;
}
html.light #chatMessages .nm-card {
  color: var(--text-muted) !important;
  background: var(--bg-card) !important;
}
html.light #chatForm input {
  color: var(--text-primary) !important;
}
html.light #chatForm input::placeholder {
  color: #94a3b8 !important;
}

/* Inputs across all forms */
html.light input[type="text"],
html.light input[type="email"],
html.light input[type="password"],
html.light select {
  background-color: transparent !important;
  color: var(--text-primary) !important;
}
html.light input::placeholder {
  color: #94a3b8 !important;
}

/* Modals in Light Mode */
html.light .modal-backdrop {
  background: var(--modal-backdrop) !important;
}
html.light .modal-backdrop .nm-card {
  background: var(--bg-modal) !important;
  box-shadow: 12px 12px 28px #bfc6d3, -12px -12px 28px #ffffff !important;
  border-color: var(--border-modal) !important;
}
html.light .modal-backdrop h2 {
  color: var(--text-primary) !important;
}
html.light .modal-backdrop label {
  color: var(--text-secondary) !important;
}

/* Landing Page in Light Mode */
html.light #view-landing h1 {
  color: var(--text-primary) !important;
}
html.light #view-landing p {
  color: var(--text-secondary) !important;
}
html.light #view-landing .nm-convex button,
html.light #view-landing .nm-flat {
  color: var(--text-primary) !important;
}

/* Dashboard & History in Light Mode */
html.light #view-dashboard h1,
html.light #view-dashboard h2,
html.light #view-dashboard h3 {
  color: var(--text-primary) !important;
}
html.light #view-dashboard p {
  color: var(--text-muted) !important;
}
html.light #view-history h1,
html.light #view-history h3 {
  color: var(--text-primary) !important;
}
html.light #view-history span.text-xs {
  color: var(--text-muted) !important;
}

/* Empty & Error States in Light Mode */
html.light #view-empty-states h1,
html.light #view-empty-states h3 {
  color: var(--text-primary) !important;
}
html.light #view-empty-states p {
  color: var(--text-muted) !important;
}

/* Toast Notification */
#globalToast {
  background-color: var(--toast-bg) !important;
  border-color: var(--toast-border) !important;
  color: var(--text-primary) !important;
}

/* --------------------------------------------------------------------------
   5. FLOATING REACTIONS & ANIMATIONS
   -------------------------------------------------------------------------- */
@keyframes floatUpAndFade {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translateY(-10px) scale(1.1);
  }
  80% {
    opacity: 0.9;
    transform: translateY(-90px) scale(1) translateX(calc(var(--drift-x, 0) * 1px));
  }
  100% {
    opacity: 0;
    transform: translateY(-140px) scale(0.8) translateX(calc(var(--drift-x, 0) * 1.5px));
  }
}

.floating-reaction {
  position: absolute;
  pointer-events: none;
  font-size: 2rem;
  z-index: 50;
  animation: floatUpAndFade 2.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.view-panel {
  animation: fadeInView 0.25s ease-out forwards;
}

@keyframes fadeInView {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes syncPulseEffect {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
  70% { box-shadow: 0 0 0 20px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.sync-pulse {
  animation: syncPulseEffect 1.2s cubic-bezier(0, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   6. GLOBAL CHECKBOX STYLING & ACCESSIBILITY
   -------------------------------------------------------------------------- */
input[type="checkbox"] {
  cursor: pointer;
  accent-color: #0284c7;
  transition: all 0.15s ease-in-out;
}

input[type="checkbox"].nm-inset {
  background: var(--bg-inset) !important;
  box-shadow: var(--shadow-inset) !important;
  border: 1px solid var(--border-card) !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  display: inline-grid !important;
  place-content: center !important;
  cursor: pointer !important;
}

input[type="checkbox"].nm-inset:checked {
  background-color: #0284c7 !important;
  background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e") !important;
  background-size: 100% 100% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.5), var(--shadow-inset) !important;
}

html.light input[type="checkbox"].nm-inset:checked {
  background-color: var(--text-accent) !important;
  border-color: #2563eb !important;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.4) !important;
}

input[type="checkbox"].nm-inset:focus-visible {
  outline: 2px solid #38bdf8 !important;
  outline-offset: 2px !important;
}

