/* Dynamic WBS themes. Default theme: Light. */
html[data-theme="light"] {
  color-scheme: light;
  --theme-primary: #4f46e5;
  --theme-primary-hover: #4338ca;
  --theme-accent: #818cf8;
  --theme-bg: #f8fafc;
  --theme-surface: #ffffff;
  --theme-surface-alt: #f8fafc;
  --theme-soft: #eef2ff;
  --theme-border: #e2e8f0;
  --theme-border-strong: #cbd5e1;
  --theme-text: #0f172a;
  --theme-muted: #64748b;
  --theme-sidebar-start: #ffffff;
  --theme-sidebar-end: #f8fafc;
  --theme-sidebar-text: #334155;
  --theme-sidebar-muted: #94a3b8;
  --theme-sidebar-active-bg: #eef2ff;
  --theme-sidebar-active-border: #4f46e5;
  --theme-sidebar-active-text: #3730a3;
  --theme-login-bg: linear-gradient(135deg, #eef2ff 0%, #f8fafc 48%, #e0e7ff 100%);
  --theme-shadow: rgba(15, 23, 42, .08);
}

html[data-theme="aqua"] {
  color-scheme: light;
  --theme-primary: #0891b2;
  --theme-primary-hover: #0e7490;
  --theme-accent: #22d3ee;
  --theme-bg: #ecfeff;
  --theme-surface: #ffffff;
  --theme-surface-alt: #f0fdfa;
  --theme-soft: #cffafe;
  --theme-border: #a5f3fc;
  --theme-border-strong: #67e8f9;
  --theme-text: #164e63;
  --theme-muted: #52727d;
  --theme-sidebar-start: #0e7490;
  --theme-sidebar-end: #155e75;
  --theme-sidebar-text: #ecfeff;
  --theme-sidebar-muted: #a5f3fc;
  --theme-sidebar-active-bg: rgba(255,255,255,.14);
  --theme-sidebar-active-border: #67e8f9;
  --theme-sidebar-active-text: #ffffff;
  --theme-login-bg: linear-gradient(135deg, #cffafe 0%, #ecfeff 45%, #a5f3fc 100%);
  --theme-shadow: rgba(8, 145, 178, .12);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --theme-primary: #a78bfa;
  --theme-primary-hover: #8b5cf6;
  --theme-accent: #c4b5fd;
  --theme-bg: #111827;
  --theme-surface: #1f2937;
  --theme-surface-alt: #273449;
  --theme-soft: #312e81;
  --theme-border: #374151;
  --theme-border-strong: #4b5563;
  --theme-text: #f9fafb;
  --theme-muted: #cbd5e1;
  --theme-sidebar-start: #030712;
  --theme-sidebar-end: #111827;
  --theme-sidebar-text: #f3f4f6;
  --theme-sidebar-muted: #9ca3af;
  --theme-sidebar-active-bg: rgba(167,139,250,.16);
  --theme-sidebar-active-border: #a78bfa;
  --theme-sidebar-active-text: #ffffff;
  --theme-login-bg: linear-gradient(135deg, #030712 0%, #111827 55%, #1f2937 100%);
  --theme-shadow: rgba(0,0,0,.35);
}

html[data-theme="lofi"] {
  color-scheme: light;
  --theme-primary: #111111;
  --theme-primary-hover: #333333;
  --theme-accent: #555555;
  --theme-bg: #f5f5f4;
  --theme-surface: #ffffff;
  --theme-surface-alt: #fafaf9;
  --theme-soft: #e7e5e4;
  --theme-border: #d6d3d1;
  --theme-border-strong: #a8a29e;
  --theme-text: #1c1917;
  --theme-muted: #78716c;
  --theme-sidebar-start: #171717;
  --theme-sidebar-end: #262626;
  --theme-sidebar-text: #fafafa;
  --theme-sidebar-muted: #a3a3a3;
  --theme-sidebar-active-bg: rgba(255,255,255,.10);
  --theme-sidebar-active-border: #ffffff;
  --theme-sidebar-active-text: #ffffff;
  --theme-login-bg: linear-gradient(135deg, #e7e5e4 0%, #fafaf9 52%, #d6d3d1 100%);
  --theme-shadow: rgba(28,25,23,.10);
}

html[data-theme="pastel"] {
  color-scheme: light;
  --theme-primary: #a855f7;
  --theme-primary-hover: #9333ea;
  --theme-accent: #f9a8d4;
  --theme-bg: #fdf4ff;
  --theme-surface: #ffffff;
  --theme-surface-alt: #fff7ed;
  --theme-soft: #fae8ff;
  --theme-border: #f5d0fe;
  --theme-border-strong: #e9d5ff;
  --theme-text: #3b2748;
  --theme-muted: #7c647f;
  --theme-sidebar-start: #f5d0fe;
  --theme-sidebar-end: #ddd6fe;
  --theme-sidebar-text: #4c1d5f;
  --theme-sidebar-muted: #7e608d;
  --theme-sidebar-active-bg: rgba(255,255,255,.55);
  --theme-sidebar-active-border: #a855f7;
  --theme-sidebar-active-text: #6b21a8;
  --theme-login-bg: linear-gradient(135deg, #fae8ff 0%, #fdf4ff 45%, #fce7f3 100%);
  --theme-shadow: rgba(168,85,247,.10);
}

html[data-theme="corporate"] {
  color-scheme: light;
  --theme-primary: #1d4ed8;
  --theme-primary-hover: #1e40af;
  --theme-accent: #60a5fa;
  --theme-bg: #f1f5f9;
  --theme-surface: #ffffff;
  --theme-surface-alt: #f8fafc;
  --theme-soft: #dbeafe;
  --theme-border: #cbd5e1;
  --theme-border-strong: #94a3b8;
  --theme-text: #0f172a;
  --theme-muted: #64748b;
  --theme-sidebar-start: #172554;
  --theme-sidebar-end: #1e3a8a;
  --theme-sidebar-text: #e0e7ff;
  --theme-sidebar-muted: #bfdbfe;
  --theme-sidebar-active-bg: rgba(255,255,255,.12);
  --theme-sidebar-active-border: #93c5fd;
  --theme-sidebar-active-text: #ffffff;
  --theme-login-bg: linear-gradient(135deg, #dbeafe 0%, #eff6ff 48%, #bfdbfe 100%);
  --theme-shadow: rgba(30,58,138,.12);
}

html[data-theme="emerald"] {
  color-scheme: light;
  --theme-primary: #059669;
  --theme-primary-hover: #047857;
  --theme-accent: #34d399;
  --theme-bg: #ecfdf5;
  --theme-surface: #ffffff;
  --theme-surface-alt: #f0fdf4;
  --theme-soft: #d1fae5;
  --theme-border: #a7f3d0;
  --theme-border-strong: #6ee7b7;
  --theme-text: #064e3b;
  --theme-muted: #52766d;
  --theme-sidebar-start: #064e3b;
  --theme-sidebar-end: #065f46;
  --theme-sidebar-text: #ecfdf5;
  --theme-sidebar-muted: #a7f3d0;
  --theme-sidebar-active-bg: rgba(255,255,255,.12);
  --theme-sidebar-active-border: #6ee7b7;
  --theme-sidebar-active-text: #ffffff;
  --theme-login-bg: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 48%, #a7f3d0 100%);
  --theme-shadow: rgba(5,150,105,.12);
}

html[data-theme="night"] {
  color-scheme: dark;
  --theme-primary: #38bdf8;
  --theme-primary-hover: #0ea5e9;
  --theme-accent: #818cf8;
  --theme-bg: #0f172a;
  --theme-surface: #172033;
  --theme-surface-alt: #1e293b;
  --theme-soft: #1e3a5f;
  --theme-border: #334155;
  --theme-border-strong: #475569;
  --theme-text: #e2e8f0;
  --theme-muted: #94a3b8;
  --theme-sidebar-start: #020617;
  --theme-sidebar-end: #0f172a;
  --theme-sidebar-text: #e2e8f0;
  --theme-sidebar-muted: #64748b;
  --theme-sidebar-active-bg: rgba(56,189,248,.14);
  --theme-sidebar-active-border: #38bdf8;
  --theme-sidebar-active-text: #ffffff;
  --theme-login-bg: linear-gradient(135deg, #020617 0%, #0f172a 50%, #172554 100%);
  --theme-shadow: rgba(0,0,0,.38);
}

html[data-theme] {
  --primary-red: var(--theme-primary);
  --primary-red-light: var(--theme-primary-hover);
  --primary-red-dark: var(--theme-primary-hover);
  --accent-gold: var(--theme-accent);
  --accent-gold-dark: var(--theme-primary-hover);
  --accent-gold-light: var(--theme-soft);
  --dark-burgundy: var(--theme-text);
  --light-bg: var(--theme-bg);
  --white: #ffffff;
  --neutral-50: var(--theme-surface-alt);
  --neutral-100: var(--theme-bg);
  --neutral-200: var(--theme-border);
  --neutral-300: var(--theme-border-strong);
  --neutral-400: var(--theme-muted);
  --neutral-600: var(--theme-muted);
  --neutral-800: var(--theme-text);
  --neutral-900: var(--theme-text);
  --shadow-sm: 0 2px 8px var(--theme-shadow);
  --shadow-md: 0 10px 28px var(--theme-shadow);
  --shadow-lg: 0 20px 46px var(--theme-shadow);
}

html[data-theme] body {
  background-color: var(--theme-bg);
  color: var(--theme-text);
}

html[data-theme] input,
html[data-theme] select,
html[data-theme] textarea {
  color: var(--theme-text);
}

/* Theme switcher */
.theme-switcher {
  position: relative;
  display: inline-flex;
  z-index: 1200;
  font-family: var(--font-sans, Arial, sans-serif);
}

.theme-switcher-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--theme-border);
  background: var(--theme-surface);
  color: var(--theme-text);
  font: inherit;
  font-size: .875rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--theme-shadow);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.theme-switcher-button:hover {
  border-color: var(--theme-primary);
  box-shadow: 0 4px 14px var(--theme-shadow);
}

.theme-current-swatch,
.theme-option-swatch {
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  border-radius: 6px;
  border: 1px solid rgba(127,127,127,.20);
  background: conic-gradient(from 90deg, var(--theme-primary) 0 25%, var(--theme-accent) 25% 50%, var(--theme-surface) 50% 75%, var(--theme-text) 75% 100%);
}

.theme-chevron { transition: transform .15s ease; }
.theme-switcher.is-open .theme-chevron { transform: rotate(180deg); }

.theme-switcher-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 288px;
  padding: 12px;
  border: 1px solid var(--theme-border);
  border-radius: 12px;
  background: var(--theme-surface);
  box-shadow: 0 18px 44px var(--theme-shadow);
  color: var(--theme-text);
}

.theme-switcher-title {
  padding: 2px 6px 9px;
  color: var(--theme-muted);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.theme-switcher-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--theme-text);
  font: inherit;
  font-size: .88rem;
  text-align: left;
  cursor: pointer;
}

.theme-option:hover {
  background: var(--theme-surface-alt);
  border-color: var(--theme-border);
}

.theme-option.is-active {
  background: var(--theme-soft);
  border-color: var(--theme-primary);
  color: var(--theme-primary);
  font-weight: 800;
}

.swatch-light { background: conic-gradient(#4f46e5 0 25%, #818cf8 0 50%, #ffffff 0 75%, #0f172a 0); }
.swatch-aqua { background: conic-gradient(#0891b2 0 25%, #22d3ee 0 50%, #ffffff 0 75%, #164e63 0); }
.swatch-dark { background: conic-gradient(#a78bfa 0 25%, #1f2937 0 50%, #111827 0 75%, #f9fafb 0); }
.swatch-lofi { background: conic-gradient(#111111 0 25%, #777777 0 50%, #ffffff 0 75%, #e7e5e4 0); }
.swatch-pastel { background: conic-gradient(#a855f7 0 25%, #f9a8d4 0 50%, #ffffff 0 75%, #ddd6fe 0); }
.swatch-corporate { background: conic-gradient(#1d4ed8 0 25%, #60a5fa 0 50%, #ffffff 0 75%, #172554 0); }
.swatch-emerald { background: conic-gradient(#059669 0 25%, #34d399 0 50%, #ffffff 0 75%, #064e3b 0); }
.swatch-night { background: conic-gradient(#38bdf8 0 25%, #818cf8 0 50%, #172033 0 75%, #e2e8f0 0); }

.theme-switcher-floating {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1400;
}

@media (max-width: 680px) {
  .theme-switcher-menu { width: min(288px, calc(100vw - 32px)); }
  .theme-switcher-button [data-theme-label] { display: none; }
  .theme-switcher-button { padding-left: 9px; padding-right: 9px; }
}


/* Theme-aware common form controls and buttons */
html[data-theme] .form-control,
html[data-theme] .form-select {
  background-color: var(--theme-surface);
  border-color: var(--theme-border-strong);
  color: var(--theme-text);
}
html[data-theme] .form-control::placeholder,
html[data-theme] textarea::placeholder,
html[data-theme] input::placeholder { color: var(--theme-muted); opacity: .78; }
html[data-theme] .form-label { color: var(--theme-text); }
html[data-theme] .form-control:focus,
html[data-theme] .form-select:focus {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-primary) 18%, transparent);
}
html[data-theme] .btn-primary,
html[data-theme] .btn-gold { color: #ffffff; }
