/* StudioFlow — theme UI (toggle + return chip) + sunlit (default) app surfaces */

/* --- Sunlit design tokens (aligned with marketing: warm neutrals, softer depth) --- */
html[data-sf-theme="sunlit"] {
  --sf-bg: #f5f4f1;
  --sf-bg-soft: #eeede8;
  --sf-panel: #fefdfb;
  --sf-panel-2: #f7f6f2;
  --sf-line: #dcd8cf;
  --sf-line-strong: #c4bfb4;
  --sf-text: #0f172a;
  --sf-muted: #5c6678;
  --sf-muted-2: #475569;
  --sf-accent: #0f766e;
  --sf-accent-2: #0d9488;
  --sf-danger: #be123c;
  --sf-radius: 20px;
  --sf-radius-sm: 14px;
  --sf-shadow: 0 10px 40px rgba(26, 22, 18, 0.06), 0 1px 0 rgba(255, 255, 255, 0.65) inset;
  --sf-space-section: 1.5rem;
}

/* --- Sunlit: global app shell (all sf-* pages) --- */
html[data-sf-theme="sunlit"] body[data-page^="sf-"] {
  background:
    radial-gradient(920px 440px at 14% -6%, rgba(45, 212, 191, 0.1), transparent 54%),
    radial-gradient(720px 400px at 96% 4%, rgba(201, 151, 63, 0.05), transparent 52%),
    var(--sf-bg);
  color: var(--sf-text);
  line-height: 1.5;
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] .panel,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] .card {
  background: linear-gradient(165deg, #fefdfb 0%, #f6f4ef 100%);
  border: 1px solid var(--sf-line);
  border-radius: var(--sf-radius);
  color: var(--sf-text);
  box-shadow: var(--sf-shadow);
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] .header {
  border-radius: var(--sf-radius);
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] h1,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] h2,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] h3,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] h4 {
  color: var(--sf-text);
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] .eyebrow {
  color: var(--sf-accent);
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] p,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] .meta {
  color: var(--sf-muted);
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] .text-slate-900 {
  color: var(--sf-text) !important;
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] .text-slate-700,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] .text-slate-800 {
  color: #334155 !important;
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] .text-slate-400 {
  color: #64748b !important;
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] input,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] select,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] textarea {
  background: #fefdfb;
  border: 1px solid var(--sf-line-strong);
  border-radius: var(--sf-radius-sm);
  color: var(--sf-text);
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] input:focus,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] select:focus,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] textarea:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2);
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] .btn-primary,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] .btn-link.btn-primary {
  background: var(--sf-accent);
  color: #ffffff;
  border: 1px solid rgba(13, 148, 136, 0.32);
  border-radius: var(--sf-radius-sm);
  box-shadow: 0 6px 22px rgba(15, 118, 110, 0.16);
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] .btn-secondary,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] .btn-link.btn-secondary,
html[data-sf-theme="sunlit"] body[data-page^="sf-"] .links a {
  background: rgba(254, 253, 251, 0.95);
  border: 1px solid var(--sf-line);
  border-radius: var(--sf-radius-sm);
  color: var(--sf-muted-2);
}

/* Staff layouts */
html[data-sf-theme="sunlit"] body[data-page="sf-staff"] .sidebar,
html[data-sf-theme="sunlit"] body[data-page="sf-staff"] aside.sidebar {
  background: #ffffff !important;
  border-right: 1px solid var(--sf-line) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-staff"] .sidebar-link {
  color: var(--sf-muted-2) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-staff"] .sidebar-link.active {
  background: linear-gradient(130deg, #ccfbf1, #99f6e4) !important;
  color: #0f172a !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-staff"] .header,
html[data-sf-theme="sunlit"] body[data-page="sf-admin"] .header,
html[data-sf-theme="sunlit"] body[data-page="sf-portal"] .header,
html[data-sf-theme="sunlit"] body[data-page="sf-student"] .header {
  background: rgba(254, 253, 251, 0.94) !important;
  border: 1px solid var(--sf-line) !important;
  box-shadow: 0 8px 28px rgba(26, 22, 18, 0.04);
}

html[data-sf-theme="sunlit"] body[data-page^="sf-"] .nav a {
  border-color: var(--sf-line);
  background: rgba(254, 253, 251, 0.96);
  border-radius: 12px;
  color: var(--sf-muted-2);
}

/* Public splash (index) — tailwind tokens */
html[data-sf-theme="sunlit"] body[data-page="sf-public"].hero-gradient {
  background: linear-gradient(180deg, #f8faf9 0%, #eef2ef 100%) !important;
  color: #0f172a !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"] .border-slate-100 {
  border-color: #e2e8f0 !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"] .text-slate-900,
html[data-sf-theme="sunlit"] body[data-page="sf-public"] .text-teal-800,
html[data-sf-theme="sunlit"] body[data-page="sf-public"] .text-teal-700 {
  color: #0f172a !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"] .text-slate-800,
html[data-sf-theme="sunlit"] body[data-page="sf-public"] .text-slate-700,
html[data-sf-theme="sunlit"] body[data-page="sf-public"] .text-slate-600,
html[data-sf-theme="sunlit"] body[data-page="sf-public"] .text-slate-500 {
  color: #475569 !important;
}

/* Auth/register inline pages — override dark block in page <style> */
html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) {
  background: linear-gradient(185deg, #f0f4f1 0%, #e8eeea 50%, #f4f6f4 100%) !important;
  color: var(--sf-text) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) .card {
  background: linear-gradient(165deg, #fefdfb 0%, #f6f4ef 100%) !important;
  border: 1px solid var(--sf-line) !important;
  border-radius: var(--sf-radius) !important;
  box-shadow: var(--sf-shadow) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) h1 {
  color: var(--sf-text) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) p {
  color: var(--sf-muted) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) label {
  color: var(--sf-muted-2) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) input {
  background: #ffffff !important;
  border: 1px solid var(--sf-line-strong) !important;
  color: var(--sf-text) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) .tab {
  border-color: var(--sf-line);
  color: var(--sf-muted);
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) .tab[aria-selected="true"] {
  background: rgba(15, 118, 110, 0.1);
  border-color: rgba(15, 118, 110, 0.35);
  color: var(--sf-text);
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) .links a {
  background: #ffffff;
  color: var(--sf-muted-2);
  border-color: var(--sf-line);
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) .btn-primary {
  background: var(--sf-accent) !important;
  color: #fff !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-public"]:not(.hero-gradient) .password-toggle {
  background: #f1f5f3 !important;
  color: var(--sf-text) !important;
  border-color: var(--sf-line) !important;
}

/* --- Floating theme control --- */
.sf-theme-toggle {
  position: fixed !important;
  z-index: 2147483000 !important;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px)) !important;
  right: calc(16px + env(safe-area-inset-right, 0px)) !important;
  left: auto !important;
  top: auto !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  height: auto !important;
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 2px !important;
  padding: 4px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  border-radius: 999px !important;
  border: 1px solid rgba(15, 23, 42, 0.1) !important;
  background: rgba(255, 255, 255, 0.82) !important;
  backdrop-filter: blur(14px) !important;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.1) !important;
}

html[data-sf-theme="dark"] .sf-theme-toggle {
  border-color: rgba(148, 163, 184, 0.25) !important;
  background: rgba(15, 23, 42, 0.78) !important;
}

.sf-theme-toggle__btn {
  appearance: none !important;
  -webkit-appearance: none !important;
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 34px !important;
  width: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: rgba(15, 23, 42, 0.48) !important;
  font: inherit !important;
  line-height: 1 !important;
  text-align: center !important;
  text-decoration: none !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
  transition: background 0.22s ease, color 0.22s ease, opacity 0.22s ease;
}

html[data-sf-theme="dark"] .sf-theme-toggle__btn {
  color: rgba(226, 232, 240, 0.62) !important;
}

.sf-theme-toggle__btn[aria-pressed="true"] {
  background: rgba(15, 118, 110, 0.14) !important;
  color: #0f766e !important;
}

html[data-sf-theme="dark"] .sf-theme-toggle__btn[aria-pressed="true"] {
  background: rgba(94, 234, 212, 0.13) !important;
  color: #5eead4 !important;
}

.sf-theme-toggle__btn svg {
  display: block !important;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  pointer-events: none !important;
}

.sf-theme-toggle__btn:focus-visible {
  outline: 2px solid #0f766e;
  outline-offset: 2px;
}

.sf-theme-toggle__sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* --- Return chip --- */
.sf-return-chip {
  position: fixed;
  z-index: 90;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: calc(16px + env(safe-area-inset-left, 0px));
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px 9px 11px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: rgba(15, 23, 42, 0.76);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(15, 23, 42, 0.09);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.055);
  max-width: min(52vw, 220px);
  min-height: 44px;
  box-sizing: border-box;
}

html[data-sf-theme="dark"] .sf-return-chip {
  color: rgba(241, 245, 249, 0.9);
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.25);
}

.sf-return-chip:hover {
  border-color: rgba(15, 118, 110, 0.35);
  color: #0f766e;
}

html[data-sf-theme="dark"] .sf-return-chip:hover {
  color: #5eead4;
}

.sf-return-chip:focus-visible {
  outline: 2px solid #0f766e;
  outline-offset: 2px;
}

.sf-return-chip__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sf-return-chip svg {
  flex-shrink: 0;
  opacity: 0.85;
}

@media (max-width: 480px) {
  .sf-return-chip__text {
    max-width: 7rem;
  }
}

/* Student pages with inline dark <style> (packages, shop, etc.) */
html[data-sf-theme="sunlit"] body[data-page="sf-student"] {
  background:
    radial-gradient(800px 360px at 10% -10%, rgba(45, 212, 191, 0.12), transparent 55%),
    var(--sf-bg) !important;
  color: var(--sf-text) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-student"] .card {
  background: linear-gradient(165deg, #fefdfb 0%, #f6f4ef 100%) !important;
  border: 1px solid var(--sf-line) !important;
  border-radius: var(--sf-radius) !important;
  box-shadow: var(--sf-shadow) !important;
}

html[data-sf-theme="sunlit"] body[data-page="sf-student"] .nav a {
  color: var(--sf-muted-2) !important;
}

/* Dark mode — slightly softer depth (still professional; matches marketing restraint) */
html[data-sf-theme="dark"] body[data-page^="sf-"] .panel,
html[data-sf-theme="dark"] body[data-page^="sf-"] .card {
  border-radius: 20px;
  box-shadow: 0 14px 38px rgba(2, 6, 23, 0.38);
}

html[data-sf-theme="dark"] body[data-page^="sf-"] input,
html[data-sf-theme="dark"] body[data-page^="sf-"] select,
html[data-sf-theme="dark"] body[data-page^="sf-"] textarea {
  border-radius: 14px;
}
