/* ==========================================================================
   IB Study OS — Shared Design System

   This file defines all visual styles shared across the application:
   design tokens (CSS variables), base resets, auth page layout,
   form elements, buttons, notification banners, and the dashboard
   skeleton shared across all pages.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens (CSS Custom Properties)
   -------------------------------------------------------------------------- */

:root {
  /* Colour palette — IB Study OS warm editorial aesthetic */
  --color-bg: #f5f2eb;          /* parchment — used for all page backgrounds */
  --color-surface: #ffffff;     /* card / form / sidebar backgrounds */
  --color-ink: #1a1a1a;         /* primary text — dark ink */
  --color-ink-muted: #6b6b6b;   /* secondary/helper text */
  --color-border: #d4cfc6;      /* input borders, card dividers */

  /* IB Group colour coding (also used as semantic state colours) */
  --color-accent: #1a4b8c;      /* IB Mathematics blue — primary CTA */
  --color-accent-hover: #163d73;
  --color-success: #065f46;     /* IB Sciences green — success states */
  --color-error: #7c2d12;       /* IB Languages red — error states */
  --color-warning: #92400e;     /* IB Arts amber — warning states */

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;

  /* Layout helpers */
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.10);
}

/* --------------------------------------------------------------------------
   2. Base / Reset Styles
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-ink);
  margin: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  margin-top: 0;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   3. Auth Page Layout (centred card used by login, signup, reset-password)
   -------------------------------------------------------------------------- */

/* Full-viewport centring wrapper */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

/* The white card that contains the form */
.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

/* Product name in display font, accent blue */
.auth-logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--color-accent);
  text-align: center;
  margin-bottom: 0.25rem;
}

/* One-line value prop below the logo */
.auth-tagline {
  text-align: center;
  color: var(--color-ink-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

/* --------------------------------------------------------------------------
   3b. Auth Split Layout — Login page redesign
       Left panel: IB blue with subject chips + feature list
       Right panel: clean white form
       Signup + reset-password keep the original .auth-card layout
   -------------------------------------------------------------------------- */

body.auth-split-page {
  background: white;
  padding: 0;
}

.auth-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

/* Left marketing panel */
.auth-split__left {
  background: #1a4b8c;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}

/* Subtle dot grid overlay */
.auth-split__left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

/* Large decorative watermark */
.auth-split__left::after {
  content: 'IB';
  position: absolute;
  bottom: -80px;
  right: -30px;
  font-family: var(--font-display);
  font-size: 22rem;
  font-weight: 700;
  color: rgba(255,255,255,0.04);
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.auth-split__left-inner {
  position: relative;
  padding: 4rem 3.5rem;
}

.auth-split__brand {
  font-family: var(--font-display);
  font-size: 1rem;
  font-style: italic;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.02em;
  margin-bottom: 2.25rem;
}

.auth-split__headline {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1.1;
  color: white;
  margin: 0 0 1.25rem;
  font-weight: 700;
}

.auth-split__sub {
  font-size: 0.975rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.72);
  margin: 0 0 2rem;
  max-width: 380px;
}

.auth-split__features {
  list-style: none;
  padding: 0;
  margin: 0 0 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.auth-split__features li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
}

.auth-split__check {
  width: 20px;
  height: 20px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
}

/* Subject group chips */
.auth-split__subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.auth-split__chip {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: 100px;
  border: 1.5px solid;
  letter-spacing: 0.01em;
}

.auth-split__chip--lang {
  color: #fca5a5;
  border-color: rgba(252,165,165,0.35);
  background: rgba(252,165,165,0.08);
}

.auth-split__chip--hum {
  color: #c4b5fd;
  border-color: rgba(196,181,253,0.35);
  background: rgba(196,181,253,0.08);
}

.auth-split__chip--sci {
  color: #6ee7b7;
  border-color: rgba(110,231,183,0.35);
  background: rgba(110,231,183,0.08);
}

.auth-split__chip--math {
  color: #bfdbfe;
  border-color: rgba(191,219,254,0.35);
  background: rgba(191,219,254,0.08);
}

/* Right form panel */
.auth-split__right {
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
}

.auth-split__form-wrap {
  width: 100%;
  max-width: 380px;
}

/* Mobile-only brand mark shown above form when left panel is hidden */
.auth-split__mobile-brand {
  display: none;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--color-accent);
  font-style: italic;
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-split__form-title {
  font-family: var(--font-display);
  font-size: 1.875rem;
  color: var(--color-ink);
  margin: 0 0 0.3rem;
  font-weight: 700;
}

.auth-split__form-sub {
  font-size: 0.875rem;
  color: var(--color-ink-muted);
  margin: 0 0 1.75rem;
}

/* Mobile: hide left panel, full-width form on parchment */
@media (max-width: 768px) {
  .auth-split {
    grid-template-columns: 1fr;
  }

  .auth-split__left {
    display: none;
  }

  .auth-split__right {
    min-height: 100vh;
    background: var(--color-bg);
    padding: 2.5rem 1.5rem;
  }

  .auth-split__mobile-brand {
    display: block;
  }

  .auth-split__form-title,
  .auth-split__form-sub {
    text-align: center;
  }
}

/* --------------------------------------------------------------------------
   4. Form Elements
   -------------------------------------------------------------------------- */

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--color-ink);
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"],
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  box-sizing: border-box;
  background: #ffffff;
  color: var(--color-ink);
  transition: border-color 0.2s, outline 0.2s;
}

.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  border-color: var(--color-accent);
  outline: 2px solid rgba(26, 75, 140, 0.2);
  outline-offset: 0;
}

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s, opacity 0.2s;
  text-decoration: none;
}

/* Primary — accent blue, used for all main CTAs */
.btn-primary {
  background-color: var(--color-accent);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--color-accent-hover);
  text-decoration: none;
  color: #ffffff;
}

/* Full-width variant — used in auth forms */
.btn-full {
  width: 100%;
}

/* Disabled state — also applied via JS during fetch in-flight */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   6. Notification Banners
   -------------------------------------------------------------------------- */

/* Base banner — hidden by default, shown by adding .banner--visible */
.banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  display: none;   /* JavaScript adds .banner--visible to show */
  line-height: 1.5;
}

.banner--visible {
  display: block;
}

/* Success — green (IB Sciences palette) */
.banner--success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

/* Error — red (IB Languages palette) */
.banner--error {
  background: #fee2e2;
  color: #7c2d12;
  border: 1px solid #fca5a5;
}

/* Info — blue (IB Mathematics palette) */
.banner--info {
  background: #dbeafe;
  color: #1e3a5f;
  border: 1px solid #93c5fd;
}

/* --------------------------------------------------------------------------
   7. Auth Footer Links (below the form card)
   -------------------------------------------------------------------------- */

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--color-ink-muted);
}

.auth-footer a {
  color: var(--color-accent);
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   8. Dashboard Layout Skeleton

   Used by views/dashboard.html and all pages.
   Sidebar + main content area pattern.
   -------------------------------------------------------------------------- */

.dashboard-layout {
  min-height: 100vh;
  display: flex;
}

/* Left sidebar navigation */
.sidebar {
  width: 260px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 1.5rem;
  flex-shrink: 0;
  transition: width 0.25s ease, padding 0.25s ease, opacity 0.2s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Collapsed state — sidebar slides away */
.dashboard-layout.sidebar-collapsed .sidebar {
  width: 0;
  padding: 0;
  opacity: 0;
  border-right: none;
}

/* Button inside sidebar to collapse it */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-ink-muted);
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover {
  background: var(--color-border);
  color: var(--color-ink);
}

/* Floating button to re-open sidebar when collapsed */
.sidebar-expand-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 50;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-ink-muted);
  font-size: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.sidebar-expand-btn:hover {
  background: var(--color-bg);
  color: var(--color-ink);
}
.dashboard-layout.sidebar-collapsed .sidebar-expand-btn {
  display: flex;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.dashboard-layout.sidebar-collapsed .sidebar-expand-btn:hover {
  opacity: 1;
}

/* Main scrollable content area */
.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

/* Top bar inside main content */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

/* --------------------------------------------------------------------------
   8b. Google OAuth Button
   -------------------------------------------------------------------------- */

/* Divider between email form and OAuth buttons */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--color-ink-muted);
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #d1cfc9;
}

/* Google Sign-In button — matches Google's official brand guidelines */
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.72rem 1.5rem;
  background: #ffffff;
  color: #3c4043;
  border: 1.5px solid #dadce0;
  border-radius: var(--radius);
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
  box-shadow: 0 1px 2px rgba(60,64,67,0.08);
}

.btn-google:hover {
  background: #f8f9fa;
  border-color: #c6c9cc;
  box-shadow: 0 2px 6px rgba(60,64,67,0.15);
  text-decoration: none;
  color: #3c4043;
}

.btn-google:active {
  background: #f1f3f4;
}

.btn-google svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* --------------------------------------------------------------------------
   9. Mobile Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  /* Reduce auth card padding on small screens */
  .auth-card {
    padding: 2rem 1.25rem;
  }

  /* Hide sidebar on mobile — hamburger menu below handles this */
  .sidebar {
    display: none;
  }
}

/* ==========================================================================
   Syllabus and Progress UI Components
   ========================================================================== */

/* --------------------------------------------------------------------------
   IB Group Color Tokens (extends the base palette in Section 1)
   -------------------------------------------------------------------------- */

:root {
  /* Humanities (Group 3 — History, Economics, Psychology, Geography, Business Management) */
  --color-humanities: #4c1d95;      /* purple */
  --color-humanities-light: #ede9fe;

  /* Language Acquisition (Group 2 — French B, Spanish B) */
  --color-language: #7c2d12;        /* red — same token as --color-error for semantic clarity */
  --color-language-light: #fee2e2;

  /* Sciences (Group 4) — alias for readability */
  --color-science: #065f46;
  --color-science-light: #d1fae5;

  /* Mathematics (Group 5) — alias for readability */
  --color-math: #1a4b8c;
  --color-math-light: #dbeafe;

  /* Literature / Group 1 */
  --color-literature: #7c2d12;
  --color-literature-light: #fee2e2;
}

/* Group color helper classes — applied to .subject-card based on group number */
.group-1 { --group-color: var(--color-literature); --group-color-light: var(--color-literature-light); }
.group-2 { --group-color: var(--color-language);   --group-color-light: var(--color-language-light); }
.group-3 { --group-color: var(--color-humanities); --group-color-light: var(--color-humanities-light); }
.group-4 { --group-color: var(--color-science);    --group-color-light: var(--color-science-light); }
.group-5 { --group-color: var(--color-math);       --group-color-light: var(--color-math-light); }

/* --------------------------------------------------------------------------
   Mobile Hamburger Menu (sidebar toggle on small screens)
   -------------------------------------------------------------------------- */

.hamburger-btn {
  display: none;           /* hidden on desktop — shown via media query below */
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem;
  cursor: pointer;
  color: var(--color-ink);
  line-height: 1;
  font-size: 1.25rem;
}

.hamburger-btn:hover {
  background: var(--color-bg);
}

/* Sidebar open state — toggled by JS on mobile */
.sidebar.is-open {
  display: flex;
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Hide sidebar by default on mobile; show only when .is-open */
  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 100;
    box-shadow: var(--shadow-card);
    overflow-y: auto;
  }

  /* Overlay behind open sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
  }

  .sidebar-overlay.is-visible {
    display: block;
  }

  /* Main content fills full width on mobile */
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Overall Coverage Banner (shown at top of main content area)
   -------------------------------------------------------------------------- */

.coverage-banner {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.coverage-banner__label {
  font-size: 0.875rem;
  color: var(--color-ink-muted);
  white-space: nowrap;
}

.coverage-banner__percent {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--color-accent);
  white-space: nowrap;
}

.coverage-banner__bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--color-bg);
  border-radius: 4px;
  overflow: hidden;
}

.coverage-banner__bar {
  height: 100%;
  background: var(--color-accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* --------------------------------------------------------------------------
   Subject Selection Area — "Add Subject" button and group labels
   -------------------------------------------------------------------------- */

.subject-group-heading {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  margin: 1.25rem 0 0.5rem;
}

.subject-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-bg);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--color-ink-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.subject-add-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   Subject Cards (selected subjects shown as cards in the sidebar)
   -------------------------------------------------------------------------- */

.subject-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.subject-card:hover,
.subject-card.is-active {
  background: var(--group-color-light, var(--color-bg));
}

.subject-card__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--group-color, var(--color-ink-muted));
}

.subject-card__name {
  font-size: 0.875rem;
  color: var(--color-ink);
  flex: 1;
  line-height: 1.3;
}

.subject-card__level {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--group-color, var(--color-ink-muted));
  background: var(--group-color-light, var(--color-bg));
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.subject-card__remove {
  background: none;
  border: none;
  color: var(--color-ink-muted);
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.subject-card:hover .subject-card__remove {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Subject Selection Modal (full-screen overlay for adding subjects)
   -------------------------------------------------------------------------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2rem;
  width: min(560px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--color-ink);
}

.modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-ink-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.modal__close:hover {
  color: var(--color-ink);
}

.subject-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.subject-option:hover {
  background: var(--color-bg);
}

.subject-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--color-accent);
}

.subject-option__name {
  font-size: 0.9rem;
  color: var(--color-ink);
  flex: 1;
}

.subject-option__level-select {
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  background: var(--color-surface);
  color: var(--color-ink);
  display: none; /* shown only when subject is checked */
}

.subject-option.is-selected .subject-option__level-select {
  display: block;
}

/* --------------------------------------------------------------------------
   Topic Roadmap (chapter/topic list for a selected subject)
   -------------------------------------------------------------------------- */

.roadmap-container {
  padding: 0.5rem 0;
}

.chapter-block {
  margin-bottom: 1.25rem;
}

.chapter-block__name {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--color-border);
}

.topic-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Lesson card */
.topic-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.topic-item:hover {
  border-color: var(--group-color, var(--color-accent));
  border-left-color: var(--group-color, var(--color-accent));
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

/* Lesson icon — book emoji in a small pill */
.topic-item__icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border-radius: 6px;
  pointer-events: none;
}

/* Text block — title + subtitle */
.topic-item__body {
  flex: 1;
  min-width: 0;
  pointer-events: none;
}

.topic-item__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-ink);
  line-height: 1.3;
  display: block;
}

.topic-item__meta {
  font-size: 0.75rem;
  color: var(--color-ink-muted);
  margin-top: 0.15rem;
  display: block;
}

/* Checkbox — right side, stops click propagation */
.topic-item__checkbox {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  accent-color: var(--color-success);
  cursor: pointer;
}

/* Completed state — green tint, left border turns green */
.topic-item.is-complete {
  background: #f0fdf4;
  border-left-color: var(--color-success);
}

.topic-item.is-complete .topic-item__name {
  color: var(--color-ink-muted);
}

.topic-item.is-complete .topic-item__meta {
  color: var(--color-success);
  font-weight: 600;
}

.topic-item.is-complete .topic-item__icon {
  background: #d1fae5;
}

/* --------------------------------------------------------------------------
   Per-subject Progress Bar (shown above the roadmap)
   -------------------------------------------------------------------------- */

.subject-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.subject-progress__bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--color-bg);
  border-radius: 3px;
  overflow: hidden;
}

.subject-progress__bar {
  height: 100%;
  background: var(--group-color, var(--color-success));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.subject-progress__label {
  font-size: 0.8rem;
  color: var(--color-ink-muted);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Dashboard main content states
   -------------------------------------------------------------------------- */

/* Shown when no subjects selected yet */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  text-align: center;
  color: var(--color-ink-muted);
  gap: 1rem;
}

.empty-state__icon {
  font-size: 3rem;
  opacity: 0.4;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--color-ink);
}

.empty-state__body {
  font-size: 0.9rem;
  max-width: 320px;
}

/* Loading skeleton for roadmap */
.skeleton-line {
  height: 16px;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-bg) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --------------------------------------------------------------------------
   Subjects Overview Page — /subjects
   -------------------------------------------------------------------------- */

/* 2–3 column responsive grid */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 0.5rem;
}

/* Individual subject card */
.subject-overview-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--group-color, var(--color-accent));
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
}

.subject-overview-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(-3px);
  text-decoration: none;
}

.subject-overview-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.subject-overview-card__name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--color-ink);
  line-height: 1.3;
  flex: 1;
}

.subject-overview-card__level {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--group-color, var(--color-accent));
  background: var(--group-color-light, #dbeafe);
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.subject-overview-card__group {
  font-size: 0.75rem;
  color: var(--color-ink-muted);
}

.subject-overview-card__progress-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-top: 0.25rem;
}

.subject-overview-card__bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--color-bg);
  border-radius: 3px;
  overflow: hidden;
}

.subject-overview-card__bar {
  height: 100%;
  background: var(--group-color, var(--color-accent));
  border-radius: 3px;
  transition: width 0.6s ease;
  position: relative;
  overflow: hidden;
}

.subject-overview-card__bar::after {
  content: '';
  position: absolute;
  top: 0; left: -60%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent);
  animation: barShimmer 2.2s ease-in-out infinite;
}

.subject-overview-card__pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--group-color, var(--color-accent));
  white-space: nowrap;
  min-width: 2.5rem;
  text-align: right;
}

.subject-overview-card__detail {
  font-size: 0.75rem;
  color: var(--color-ink-muted);
}

.subject-overview-card__cta {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--group-color, var(--color-accent));
}

/* ── AI Chat Bubble + Panel (Phase 4) ─── */

/* Floating chat bubble — fixed bottom-right, above all other UI */
#aiChatBubble {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(26, 75, 140, 0.35);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.2s, box-shadow 0.2s;
}

#aiChatBubble:hover {
  background: var(--color-accent-hover);
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(26, 75, 140, 0.45);
}

/* Chat panel — slides up from bubble when opened */
#aiChatPanel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 299;
  width: min(380px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 8rem));
  background: var(--color-surface);
  border: none;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

#aiChatPanel.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Panel header — accent background with avatar */
.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--color-accent);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: #ffffff;
  flex-shrink: 0;
}

.chat-panel__header-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
  min-width: 0;
}

.chat-panel__avatar {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.chat-panel__title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.chat-panel__subtitle {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.chat-panel__header button {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.1rem 0.2rem;
  transition: color 0.15s;
  flex-shrink: 0;
}

.chat-panel__header button:hover {
  color: #ffffff;
}

/* Message list — scrollable area */
#chatMessages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  background: var(--color-bg);
}

/* Message entrance animation */
.chat-msg {
  animation: msgIn 0.2s ease both;
}

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

/* User message bubble — right-aligned, accent background */
.chat-msg--user {
  align-self: flex-end;
  background: var(--color-accent);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 0.6rem 0.875rem;
  max-width: 80%;
  font-size: 0.875rem;
  white-space: pre-wrap;
  box-shadow: 0 1px 4px rgba(26, 75, 140, 0.2);
}

/* AI message bubble — left-aligned, surface with soft shadow */
.chat-msg--ai {
  align-self: flex-start;
  background: var(--color-surface);
  border: none;
  border-radius: 4px 16px 16px 16px;
  padding: 0.75rem 1rem;
  max-width: 90%;
  font-size: 0.875rem;
  line-height: 1.65;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

/* IB model answer — collapsible details block inside AI messages */
.chat-msg--ai details.ib-answer {
  margin-top: 0.5rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.5rem;
}

.chat-msg--ai details.ib-answer summary {
  cursor: pointer;
  color: var(--color-accent);
  font-size: 0.8rem;
  font-weight: 600;
}

/* Typing indicator — three animated dots */
#chatTyping {
  display: none;
  padding: 0.625rem 1rem;
  gap: 4px;
  align-items: center;
  background: var(--color-bg);
}

#chatTyping.is-visible {
  display: flex;
}

.chat-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--color-ink-muted);
  border-radius: 50%;
  animation: chatDotPulse 1.2s infinite;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatDotPulse {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1;   }
}

/* Input row — pill textarea + circle send button */
.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-top: 1px solid var(--color-border);
  align-items: center;
  background: var(--color-surface);
}

#chatInput {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 0.5rem 0.875rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  background: var(--color-bg);
  color: var(--color-ink);
  resize: none;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#chatInput:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(26, 75, 140, 0.1);
}

/* Circle send button */
.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  padding: 0;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--color-accent-hover);
  box-shadow: 0 2px 8px rgba(26, 75, 140, 0.3);
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Mobile — reduce panel height on small screens */
@media (max-width: 480px) {
  #aiChatPanel { height: min(420px, calc(100vh - 7rem)); }
}

/* ==========================================================================
   Visual Enhancements — UI Polish
   Micro-animations, hover depth, and richer backgrounds.
   All additions — no existing rules removed.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Smooth scroll
   -------------------------------------------------------------------------- */

html {
  scroll-behavior: smooth;
}

/* --------------------------------------------------------------------------
   Auth Page — dot-grid background + card entrance animation
   -------------------------------------------------------------------------- */

.auth-page {
  background-color: var(--color-bg);
  background-image: radial-gradient(circle, rgba(26, 75, 140, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* Thin accent stripe at the top of the card */
.auth-card {
  border-top: 3px solid var(--color-accent);
  animation: authCardIn 0.35s ease both;
}

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

/* --------------------------------------------------------------------------
   Primary Button — shine sweep on hover, press on click
   -------------------------------------------------------------------------- */

.btn-primary {
  position: relative;
  overflow: hidden;
  transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
}

/* Shine sweep */
.btn-primary::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 55%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent,
    rgba(255, 255, 255, 0.22),
    transparent
  );
  transition: left 0.5s ease;
}

.btn-primary:hover:not(:disabled)::after {
  left: 150%;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(26, 75, 140, 0.3);
}

/* Press micro-animation on all buttons */
.btn:active:not(:disabled) {
  transform: scale(0.97);
}

/* --------------------------------------------------------------------------
   Inputs — box-shadow glow on focus (replaces outline)
   -------------------------------------------------------------------------- */

.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  border-color: var(--color-accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 75, 140, 0.12);
}

/* --------------------------------------------------------------------------
   Topic Cards — lift on hover
   -------------------------------------------------------------------------- */

.topic-item {
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s, background 0.15s;
  will-change: transform;
}

.topic-item:hover {
  border-color: var(--group-color, var(--color-accent));
  border-left-color: var(--group-color, var(--color-accent));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.09);
  transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   Progress Bars — animated shimmer on the fill
   -------------------------------------------------------------------------- */

.subject-progress__bar,
.coverage-banner__bar {
  position: relative;
  overflow: hidden;
}

.subject-progress__bar::after,
.coverage-banner__bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.45),
    transparent
  );
  animation: barShimmer 2.2s ease-in-out infinite;
}

@keyframes barShimmer {
  0%   { left: -60%; }
  100% { left: 160%; }
}

/* --------------------------------------------------------------------------
   Subject Cards — left accent border on active
   -------------------------------------------------------------------------- */

.subject-card.is-active {
  background: var(--group-color-light, var(--color-bg));
  border-left: 2px solid var(--group-color, var(--color-accent));
  padding-left: calc(0.75rem - 2px);
}

/* --------------------------------------------------------------------------
   Sidebar Upgrade Banner — gradient + hover lift
   -------------------------------------------------------------------------- */

#upgradeBanner {
  background: linear-gradient(135deg, #1a4b8c 0%, #2563a8 100%) !important;
  box-shadow: 0 2px 8px rgba(26, 75, 140, 0.25);
  transition: box-shadow 0.2s, transform 0.15s;
}

#upgradeBanner:hover {
  box-shadow: 0 4px 14px rgba(26, 75, 140, 0.4) !important;
  transform: translateY(-1px);
  text-decoration: none !important;
}
