/**
 * Global day/night bridge — keeps Teacher, Student, public tools in sync with Home.
 * data-theme="dark" | "light" on <html> (set by /js/theme.js from localStorage sc_theme)
 */

html[data-theme="light"],
html[data-theme="day"] { color-scheme: light; }
html[data-theme="dark"],
html[data-theme="night"]  { color-scheme: dark; }

/* ── Light mode: remap common portal tokens ── */
html[data-theme="light"],
html[data-theme="day"] {
  --bg: #F4F5FA;
  --bg2: #FFFFFF;
  --bg3: #EEF0F8;
  --bg4: #E4E7F2;
  --bg5: #D8DCEB;
  --border: rgba(0, 0, 0, 0.08);
  --border2: rgba(0, 0, 0, 0.14);
  --text: #12121F;
  --text2: #5A5A7A;
  --text3: #9A9AB0;
  --tx: #12121F;
  --tx2: #5A5A7A;
  --tx3: #9A9AB0;
  --P: #4F5FE8;
  --P2: #6B7AFF;
  --Pg: rgba(79, 95, 232, 0.12);
  --S: #C9A227;
  --Sg: rgba(201, 162, 39, 0.12);
  --ok: #16A34A;
  --info: #0284C7;
  --warn: #D97706;
  --err: #DC2626;
  --success: #16A34A;
  --danger: #DC2626;
  --warning: #D97706;
  --accent: #4F5FE8;
  --accent2: #6B7AFF;
  --accent-dim: rgba(79, 95, 232, 0.12);
  --gold: #C9A227;
  --gold-dim: rgba(201, 162, 39, 0.12);
  --success-dim: rgba(22, 163, 74, 0.1);
  --danger-dim: rgba(220, 38, 38, 0.1);
  --warning-dim: rgba(217, 119, 6, 0.1);
  --info-dim: rgba(2, 132, 199, 0.1);
  /* SchoolCore shell tokens */
  --sc-bg: #F4F5FA;
  --sc-bg-elevated: #FFFFFF;
  --sc-bg-card: #FFFFFF;
  --sc-bg-hover: #EEF0F8;
  --sc-bg-input: #EEF0F8;
  --sc-border: rgba(0, 0, 0, 0.08);
  --sc-border-strong: rgba(0, 0, 0, 0.14);
  --sc-text: #12121F;
  --sc-text-secondary: #5A5A7A;
  --sc-text-muted: #9A9AB0;
  --sc-nav-bg: rgba(255, 255, 255, 0.94);
  --sc-header-bg: rgba(244, 245, 250, 0.9);
  --sc-primary: #4F5FE8;
  --sc-primary-hover: #3D4CD0;
  --sc-primary-soft: rgba(79, 95, 232, 0.12);
  --sc-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --sc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] {
  --sc-bg: #06060F;
  --sc-bg-elevated: #0C0C1C;
  --sc-bg-card: #111122;
  --sc-bg-hover: #181830;
  --sc-bg-input: #1E1E38;
  --sc-border: rgba(255, 255, 255, 0.08);
  --sc-border-strong: rgba(255, 255, 255, 0.14);
  --sc-text: #E8E8F8;
  --sc-text-secondary: #8080A8;
  --sc-text-muted: #404060;
  --sc-nav-bg: rgba(12, 12, 28, 0.94);
  --sc-header-bg: rgba(6, 6, 15, 0.88);
  --sc-primary: #5B6EF5;
  --sc-primary-hover: #4A5CE0;
  --sc-primary-soft: rgba(91, 110, 245, 0.15);
}

/* Body surfaces that hardcode dark backgrounds */
html[data-theme="light"] body,
html[data-theme="day"] body {
  background: var(--bg, #F4F5FA) !important;
  color: var(--text, var(--tx, #12121F)) !important;
}

html[data-theme="dark"] body {
  background: var(--bg, #06060F);
  color: var(--text, var(--tx, #E8E8F8));
}

/* Floating theme FAB on module pages */
.sc-theme-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 99990;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 12, 28, 0.92);
  color: #E8E8F8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
  -webkit-tap-highlight-color: transparent;
}
html[data-theme="light"] .sc-theme-fab,
html[data-theme="day"] .sc-theme-fab {
  background: rgba(255, 255, 255, 0.95);
  color: #12121F;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
.sc-theme-fab:active { transform: scale(0.94); }

/* Cards / panels that often hardcode dark fills */
html[data-theme="light"] .card,
html[data-theme="day"] .card,
html[data-theme="light"] .sb-card,
html[data-theme="light"] .checker-card,
html[data-theme="light"] .panel,
html[data-theme="light"] .modal,
html[data-theme="light"] .overlay .modal {
  background: var(--bg2, #fff);
  color: var(--text, #12121F);
}

/* Inputs */
html[data-theme="light"] input,
html[data-theme="day"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  color: var(--text, #12121F);
}
