/* StudyStreak admin. Colour tokens are RGB triples so Tailwind can add opacity (see tailwind.config in index.html). */

:root {
  color-scheme: light;
  --c-bg: 255 251 243;          /* warm off-white */
  --c-surface: 255 255 255;
  --c-surface-2: 253 249 240;
  --c-surface-3: 248 241 226;
  --c-line: 241 228 207;
  --c-ink: 15 23 42;
  --c-muted: 91 100 114;
  --c-primary: 245 158 11;      /* streak amber */
  --c-primary-fg: 26 19 0;
  --c-primary-soft: 255 233 184;
  --c-primary-ink: 146 64 14;
  --c-success: 5 150 105;
  --c-success-ink: 4 120 87;
  --c-success-soft: 209 250 229;
  --c-info: 37 99 235;
  --c-info-ink: 29 78 216;
  --c-info-soft: 219 234 254;
  --c-danger: 220 38 38;
  --c-danger-ink: 185 28 28;
  --c-danger-soft: 254 226 226;
  --shadow-card: 0 1px 2px rgb(15 23 42 / 0.04), 0 8px 24px -12px rgb(15 23 42 / 0.14);
  --radius-card: 24px;
  --radius-ctl: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --c-bg: 15 17 21;
    --c-surface: 23 26 33;
    --c-surface-2: 28 32 40;
    --c-surface-3: 32 36 45;
    --c-line: 43 48 58;
    --c-ink: 243 244 246;
    --c-muted: 156 163 175;
    --c-primary: 251 191 36;
    --c-primary-fg: 26 19 0;
    --c-primary-soft: 66 47 10;
    --c-primary-ink: 253 214 110;
    --c-success: 52 211 153;
    --c-success-ink: 110 231 183;
    --c-success-soft: 6 53 40;
    --c-info: 96 165 250;
    --c-info-ink: 147 197 253;
    --c-info-soft: 22 40 72;
    --c-danger: 248 113 113;
    --c-danger-ink: 252 165 165;
    --c-danger-soft: 74 22 22;
    --shadow-card: 0 0 0 1px rgb(43 48 58 / 0.6);
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  background: rgb(var(--c-bg));
  color: rgb(var(--c-ink));
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 3px solid rgb(var(--c-info));
  outline-offset: 2px;
  border-radius: 8px;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- surfaces ---------- */

.card {
  background: rgb(var(--c-surface));
  border: 1px solid rgb(var(--c-line));
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px; }
@media (min-width: 768px) { .card-pad { padding: 24px; } }

.stat-value {
  font-size: 32px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.5px;
}
@media (min-width: 768px) { .stat-value { font-size: 36px; } }

.section-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.help { font-size: 12px; line-height: 1.4; color: rgb(var(--c-muted)); }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

/* ---------- form controls ---------- */

.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius-ctl);
  background: rgb(var(--c-surface-2));
  border: 1px solid rgb(var(--c-line));
  color: inherit;
  font: inherit;
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: rgb(var(--c-muted) / 0.8); }
.input:focus { outline: none; border-color: rgb(var(--c-primary)); box-shadow: 0 0 0 3px rgb(var(--c-primary) / 0.25); }
.input[aria-invalid="true"] { border-color: rgb(var(--c-danger)); }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.55; }
select.input { appearance: auto; }
input[type="color"].input { padding: 4px; min-width: 56px; max-width: 72px; height: 48px; cursor: pointer; }

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 50px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 999px;
  background: rgb(var(--c-surface-3));
  border: 1px solid rgb(var(--c-line));
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform 0.2s ease;
}
.switch:checked { background: rgb(var(--c-primary)); border-color: transparent; }
.switch:checked::after { transform: translateX(20px); background: rgb(var(--c-primary-fg)); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-ctl);
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg, .btn i { width: 18px; height: 18px; }
.btn-primary { background: rgb(var(--c-primary)); color: rgb(var(--c-primary-fg)); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-secondary { background: rgb(var(--c-surface)); color: rgb(var(--c-ink)); border-color: rgb(var(--c-line)); }
.btn-secondary:hover:not(:disabled) { background: rgb(var(--c-surface-3)); }
.btn-ghost { background: transparent; color: rgb(var(--c-ink)); }
.btn-ghost:hover:not(:disabled) { background: rgb(var(--c-surface-3)); }
.btn-danger { background: transparent; color: rgb(var(--c-danger-ink)); border-color: rgb(var(--c-danger) / 0.45); }
.btn-danger:hover:not(:disabled) { background: rgb(var(--c-danger-soft)); }
.btn-danger-solid { background: rgb(var(--c-danger)); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { filter: brightness(1.08); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 12px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: rgb(var(--c-ink));
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: rgb(var(--c-surface-3)); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn.danger { color: rgb(var(--c-danger-ink)); }
.icon-btn.danger:hover { background: rgb(var(--c-danger-soft)); }
.icon-btn svg, .icon-btn i { width: 20px; height: 20px; }

/* ---------- badges and chips ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  background: rgb(var(--c-surface-3));
  color: rgb(var(--c-muted));
}
.badge svg, .badge i { width: 14px; height: 14px; }
.badge-success { background: rgb(var(--c-success-soft)); color: rgb(var(--c-success-ink)); }
.badge-primary { background: rgb(var(--c-primary-soft)); color: rgb(var(--c-primary-ink)); }
.badge-info { background: rgb(var(--c-info-soft)); color: rgb(var(--c-info-ink)); }
.badge-danger { background: rgb(var(--c-danger-soft)); color: rgb(var(--c-danger-ink)); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.chip {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgb(var(--c-line));
  background: rgb(var(--c-surface));
  color: rgb(var(--c-ink));
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { background: rgb(var(--c-surface-3)); }
.chip[aria-pressed="true"] { background: rgb(var(--c-primary)); border-color: transparent; color: rgb(var(--c-primary-fg)); font-weight: 600; }
.chip .count { opacity: 0.7; margin-left: 4px; }

/* ---------- navigation ---------- */

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-ctl);
  color: rgb(var(--c-muted));
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.nav-link:hover { background: rgb(var(--c-surface-3)); color: rgb(var(--c-ink)); }
.nav-link[aria-current="page"] { background: rgb(var(--c-primary-soft)); color: rgb(var(--c-primary-ink)); font-weight: 600; }
.nav-link svg, .nav-link i { width: 20px; height: 20px; flex-shrink: 0; }

.tab-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  color: rgb(var(--c-muted));
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
}
.tab-link svg, .tab-link i { width: 22px; height: 22px; }
.tab-link[aria-current="page"] { color: rgb(var(--c-primary-ink)); font-weight: 700; }
.tab-link[aria-current="page"] .tab-pill { background: rgb(var(--c-primary-soft)); }
.tab-pill { padding: 4px 16px; border-radius: 999px; line-height: 0; }

/* ---------- tables and lists ---------- */

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgb(var(--c-muted));
  padding: 12px 16px;
  border-bottom: 1px solid rgb(var(--c-line));
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgb(var(--c-line));
  vertical-align: middle;
}
.data-table tbody tr { cursor: pointer; transition: background-color 0.12s ease; }
.data-table tbody tr:hover { background: rgb(var(--c-surface-2)); }
.data-table tbody tr:last-child td { border-bottom: none; }

.row-link { cursor: pointer; }
.row-link:hover { background: rgb(var(--c-surface-2)); }

/* ---------- subjects accordion ---------- */

details.subject {
  border: 1px solid rgb(var(--c-line));
  border-radius: var(--radius-ctl);
  background: rgb(var(--c-surface));
  overflow: hidden;
}
details.subject + details.subject { margin-top: 12px; }
details.subject > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}
details.subject > summary::-webkit-details-marker { display: none; }
details.subject > summary:hover { background: rgb(var(--c-surface-2)); }
details.subject .chev { transition: transform 0.2s ease; flex-shrink: 0; }
details.subject[open] .chev { transform: rotate(180deg); }
details.subject .subject-body { padding: 4px 16px 16px; border-top: 1px solid rgb(var(--c-line)); }

/* ---------- skeletons, empty states, toasts, dialogs ---------- */

.skeleton {
  background: linear-gradient(90deg, rgb(var(--c-surface-3)) 25%, rgb(var(--c-surface-2)) 50%, rgb(var(--c-surface-3)) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 12px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.empty {
  text-align: center;
  padding: 40px 20px;
}
.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgb(var(--c-primary-soft));
  color: rgb(var(--c-primary-ink));
}
.empty-icon svg, .empty-icon i { width: 28px; height: 28px; }

.toast-stack {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 92px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
@media (min-width: 768px) {
  .toast-stack { left: auto; right: 24px; bottom: 24px; align-items: flex-end; }
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 480px;
  padding: 12px 16px;
  border-radius: var(--radius-ctl);
  background: rgb(var(--c-ink));
  color: rgb(var(--c-bg));
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / 0.4);
  animation: toast-in 0.2s ease-out;
}
.toast svg, .toast i { width: 20px; height: 20px; flex-shrink: 0; }
.toast-error { background: rgb(var(--c-danger)); color: #fff; }
.toast-out { opacity: 0; transform: translateY(6px); transition: opacity 0.2s ease, transform 0.2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(15 23 42 / 0.45);
  backdrop-filter: blur(3px);
  padding: 0;
  animation: fade-in 0.15s ease-out;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 24px; } }
.modal {
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: rgb(var(--c-surface));
  color: rgb(var(--c-ink));
  border: 1px solid rgb(var(--c-line));
  border-radius: 28px 28px 0 0;
  box-shadow: 0 24px 64px -16px rgb(0 0 0 / 0.4);
  animation: sheet-in 0.2s ease-out;
}
@media (min-width: 640px) { .modal { max-width: 560px; border-radius: 28px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 8px 24px; }
.modal-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.modal-body { padding: 8px 24px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 16px 24px 24px; border-top: 1px solid rgb(var(--c-line)); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* sticky bar sits above the mobile tab bar */
.sticky-bar {
  position: sticky;
  bottom: 84px;
  z-index: 20;
  margin-top: 24px;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  background: rgb(var(--c-surface));
  border: 1px solid rgb(var(--c-line));
  box-shadow: 0 12px 32px -12px rgb(15 23 42 / 0.25);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
@media (min-width: 768px) { .sticky-bar { bottom: 16px; } }

/* ---------- phone preview ---------- */

.phone {
  width: 270px;
  margin: 0 auto;
  padding: 10px;
  border-radius: 40px;
  background: #111827;
  box-shadow: 0 20px 40px -20px rgb(0 0 0 / 0.5);
}
.phone-screen {
  height: 480px;
  border-radius: 30px;
  overflow: hidden;
  background: #FFFBF3;
  color: #0F172A;
  font-size: 13px;
  display: flex;
  flex-direction: column;
}
.phone-screen.dark { background: #0F1115; color: #F3F4F6; }
.phone-appbar { padding: 34px 18px 18px; color: #1A1300; }
.phone-appbar .hello { font-size: 12px; opacity: 0.8; }
.phone-appbar .title { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; margin-top: 2px; }
.phone-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.phone-card { background: #FFFFFF; border-radius: 20px; padding: 14px; border: 1px solid #F1E4CF; }
.phone-screen.dark .phone-card { background: #171A21; border-color: #2B303A; }
.phone-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.phone-btn { border-radius: 14px; padding: 10px 12px; text-align: center; font-weight: 600; }
.phone-chip { display: inline-block; border-radius: 999px; padding: 4px 10px; font-size: 11px; font-weight: 600; }

/* ---------- misc ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.logo-badge {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgb(var(--c-primary));
  color: rgb(var(--c-primary-fg));
  flex-shrink: 0;
}
.logo-badge svg, .logo-badge i { width: 24px; height: 24px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- app layout (sidebar on desktop, bottom tabs on phones) ---------- */

.app-layout { min-height: 100vh; }
.main {
  padding: 20px 16px 120px;
  max-width: 1180px;
  margin: 0 auto;
  outline: none;
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 8px 0 24px;
}
.page-head h1 { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.5px; }
.page-head p { margin-top: 4px; font-size: 14px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-chip {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-chip svg, .icon-chip i { width: 18px; height: 18px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: rgb(var(--c-muted)); margin: 8px 0 4px; }
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: rgb(var(--c-ink)); text-decoration: underline; }
.crumbs span[aria-hidden] { opacity: 0.6; }

.sidebar { display: none; }
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgb(var(--c-surface));
  border-top: 1px solid rgb(var(--c-line));
}

@media (min-width: 768px) {
  .app-layout {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
  }
  .app-layout.sb-collapsed { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px 14px;
    gap: 20px;
    background: rgb(var(--c-surface));
    border-right: 1px solid rgb(var(--c-line));
    overflow: hidden;
  }
  .tabbar { display: none; }
  .main { padding: 32px 36px 64px; }
  .side-nav { display: flex; flex-direction: column; gap: 4px; }
  .sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
  .sb-collapsed .nav-label { display: none; }
  .sb-collapsed .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
  .sb-collapsed .brand-name { display: none; }
  .sb-collapsed .brand { justify-content: center; }
  .brand { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
  .brand-name { display: flex; flex-direction: column; line-height: 1.2; }
  .brand-name b { font-size: 16px; font-weight: 700; }
  .brand-name span { font-size: 12px; color: rgb(var(--c-muted)); }
}

.hide-sm { }
@media (max-width: 639px) { .hide-sm { display: none; } }

.data-table td.text-right { text-align: right; }
.overflow-x-auto { overflow-x: auto; }

@media (max-width: 480px) {
  .page-head h1 { font-size: 24px; }
  .modal-foot .btn { flex: 1 1 auto; }
}
