/* ==========================================================================
   FUNDISHA — Sleek Interface Theme
   Clean, Modern, Accessible CSS for Uganda's Digital Learning Platform
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties / Theming Variables (Sleek Interface)
   -------------------------------------------------------------------------- */
:root {
  /* Sleek Cobalt / Royal Blue Palette & Slate Neutral Foundation */
  --brand-primary: #1d4ed8;         /* Blue 700 */
  --brand-primary-hover: #1e40af;   /* Blue 800 */
  --brand-primary-light: #eff6ff;   /* Blue 50 */
  --brand-primary-border: #bfdbfe;  /* Blue 200 */
  --brand-accent: #f97316;          /* Orange 500 */
  --brand-accent-hover: #ea580c;    /* Orange 600 */
  --brand-accent-light: #fff7ed;    /* Orange 50 */
  
  --color-success: #16a34a;         /* Emerald 600 */
  --color-success-light: #f0fdf4;   /* Emerald 50 */
  --color-warning: #f59e0b;         /* Amber 500 */
  --color-warning-light: #fffbeb;   /* Amber 50 */
  --color-danger: #ef4444;          /* Red 500 */
  --color-danger-light: #fef2f2;    /* Red 50 */
  --color-info: #0284c7;            /* Sky 600 */
  --color-info-light: #f0f9ff;      /* Sky 50 */
  --color-purple: #9333ea;          /* Purple 600 */
  --color-purple-light: #faf5ff;    /* Purple 50 */

  /* Surfaces & Backgrounds - Light Mode */
  --bg-body: #f8fafc;               /* Slate 50 */
  --bg-surface: #ffffff;            /* Pure White */
  --bg-surface-elevated: #ffffff;
  --bg-surface-secondary: #f1f5f9;  /* Slate 100 */
  --bg-input: #f8fafc;              /* Slate 50 */
  --bg-hover: #f1f5f9;              /* Slate 100 */
  --bg-active: #e2e8f0;             /* Slate 200 */
  --bg-card-dark: #0f172a;          /* Slate 900 */

  /* Text & Typography */
  --text-primary: #0f172a;          /* Slate 900 */
  --text-secondary: #475569;        /* Slate 600 */
  --text-muted: #94a3b8;            /* Slate 400 */
  --text-inverse: #ffffff;
  --text-accent: #1d4ed8;

  /* Borders & Dividers */
  --border-subtle: #e2e8f0;         /* Slate 200 */
  --border-medium: #cbd5e1;         /* Slate 300 */
  --border-focus: #2563eb;          /* Blue 600 */

  /* Sleek Minimal Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.08), 0 6px 12px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 32px -6px rgba(15, 23, 42, 0.1), 0 10px 16px -5px rgba(15, 23, 42, 0.04);

  /* Border Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Layout & Spacing */
  --header-height: 68px;
  --max-content-width: 1240px;
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);

  /* Typography Font Stack */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

/* --------------------------------------------------------------------------
   Dark Mode Theme Overrides (Sleek Deep Slate)
   -------------------------------------------------------------------------- */
[data-theme="dark"] {
  --brand-primary: #3b82f6;
  --brand-primary-hover: #60a5fa;
  --brand-primary-light: rgba(59, 130, 246, 0.15);
  --brand-primary-border: rgba(59, 130, 246, 0.3);
  --brand-accent: #fb923c;
  --brand-accent-hover: #f97316;
  --brand-accent-light: rgba(251, 146, 60, 0.15);

  --bg-body: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-surface-secondary: #162032;
  --bg-input: #131d2e;
  --bg-hover: #1e293b;
  --bg-active: #334155;
  --bg-card-dark: #020617;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --text-inverse: #0f172a;
  --text-accent: #60a5fa;

  --border-subtle: #1e293b;
  --border-medium: #334155;
  --border-focus: #3b82f6;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 32px -6px rgba(0, 0, 0, 0.7);

  --color-success: #22c55e;
  --color-success-light: rgba(34, 197, 94, 0.15);
  --color-warning: #fbbf24;
  --color-warning-light: rgba(251, 191, 36, 0.15);
  --color-danger: #f87171;
  --color-danger-light: rgba(248, 113, 113, 0.15);
  --color-info: #38bdf8;
  --color-info-light: rgba(56, 189, 248, 0.15);
  --color-purple: #c084fc;
  --color-purple-light: rgba(192, 132, 252, 0.15);
}

/* --------------------------------------------------------------------------
   2. Reset & Global Styles
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

img, svg, video {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* --------------------------------------------------------------------------
   3. Base Layout Containers & Global Resets
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--max-content-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.main-content {
  flex: 1;
  padding-top: calc(var(--header-height) + 1.75rem);
  padding-bottom: 5rem;
  width: 100%;
}

/* Page Views */
.view-section {
  display: none;
  animation: sleekFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-section.active {
  display: block;
}

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

/* --------------------------------------------------------------------------
   4. Header & Navigation (Sleek Frosted Bar)
   -------------------------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-xs);
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

[data-theme="dark"] .site-header {
  background-color: rgba(15, 23, 42, 0.92);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: 100%;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.logo-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--brand-primary), #2563eb);
  color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.28);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  line-height: 1.1;
  font-weight: 800;
  color: var(--text-primary);
}

.logo-tagline {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.nav-link.active {
  color: var(--brand-primary);
  background-color: var(--brand-primary-light);
  font-weight: 700;
}

[data-theme="dark"] .nav-link.active {
  color: var(--brand-primary);
  background-color: rgba(59, 130, 246, 0.15);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  transition: all var(--transition-fast);
  position: relative;
}

.header-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.header-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: var(--brand-accent);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-surface);
}

.student-class-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 700;
  border: 1px solid var(--brand-primary-border);
  transition: all var(--transition-fast);
}

.student-class-chip:hover {
  background-color: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

.mobile-menu-btn {
  display: none;
}

/* Animated Hamburger Icon */
.hamburger-box {
  width: 20px;
  height: 14px;
  position: relative;
  display: inline-block;
}

.hamburger-bar {
  display: block;
  position: absolute;
  height: 2px;
  width: 100%;
  background-color: currentColor;
  border-radius: 2px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

.bar-top { top: 0; }
.bar-mid { top: 6px; }
.bar-bot { top: 12px; }

.mobile-menu-btn.open .bar-top,
.mobile-menu-btn.active .bar-top {
  transform: translateY(6px) rotate(45deg);
}

.mobile-menu-btn.open .bar-mid,
.mobile-menu-btn.active .bar-mid {
  opacity: 0;
  transform: scaleX(0);
}

.mobile-menu-btn.open .bar-bot,
.mobile-menu-btn.active .bar-bot {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile Navigation Backdrop & Slide-out Drawer */
.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 190;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-nav-backdrop.open,
.mobile-nav-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: calc(100vw - 3rem);
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xl);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

.mobile-nav-drawer.open,
.mobile-nav-drawer.active {
  transform: translateX(0);
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-drawer-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.mobile-drawer-search-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.mobile-drawer-search-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.search-kbd-chip {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.mobile-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.mobile-nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.mobile-nav-item.active {
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
  font-weight: 700;
}

.mobile-drawer-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.mobile-drawer-profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-drawer-copyright {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  z-index: 90;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .mobile-bottom-nav {
  background-color: rgba(15, 23, 42, 0.95);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--text-muted);
  font-size: 0.725rem;
  font-weight: 500;
  flex: 1;
  height: 100%;
}

.bottom-nav-item.active {
  color: var(--brand-primary);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   5. Buttons, Badges, Inputs & Form Elements (Sleek Craft)
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.25;
  cursor: pointer;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.btn-outline {
  background-color: transparent;
  color: var(--brand-primary);
  border: 1.5px solid var(--brand-primary);
}

.btn-outline:hover {
  background-color: var(--brand-primary-light);
}

.btn-accent {
  background-color: var(--brand-accent);
  color: #ffffff;
}

.btn-accent:hover {
  background-color: var(--brand-accent-hover);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 1.65rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.725rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge-blue { background-color: var(--brand-primary-light); color: var(--brand-primary); }
.badge-amber { background-color: var(--brand-accent-light); color: var(--brand-accent); }
.badge-emerald { background-color: var(--color-success-light); color: var(--color-success); }
.badge-purple { background-color: var(--color-purple-light); color: var(--color-purple); }
.badge-gray { background-color: var(--bg-surface-secondary); color: var(--text-secondary); }

/* Form Controls */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  font-size: 0.925rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

/* --------------------------------------------------------------------------
   6. Hero Section (Homepage Sleek)
   -------------------------------------------------------------------------- */
.hero-section {
  padding: 2.5rem 0 3.5rem 0;
  text-align: center;
  position: relative;
}

.hero-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  background-color: var(--brand-accent-light);
  color: var(--brand-accent);
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(249, 115, 22, 0.2);
}

.hero-title {
  font-size: clamp(2rem, 4.2vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.035em;
  color: var(--text-primary);
  max-width: 820px;
  margin: 0 auto 1.25rem auto;
}

.hero-subtitle {
  font-size: clamp(1.05rem, 2vw, 1.2rem);
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto 2rem auto;
  line-height: 1.6;
}

.hero-cta-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}

/* Hero Live Search Box */
.hero-search-wrapper {
  max-width: 740px;
  margin: 0 auto 2rem auto;
  position: relative;
}

.hero-search-bar {
  display: flex;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: 0.4rem 0.5rem 0.4rem 1.25rem;
  box-shadow: var(--shadow-lg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.hero-search-bar:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15), var(--shadow-xl);
}

.hero-search-icon {
  color: var(--text-muted);
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
}

.hero-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}

.hero-search-btn {
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-full);
}

/* Quick Class Select Pills */
.class-quick-pills {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.class-pill-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.class-pill {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.class-pill:hover, .class-pill.active {
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
  border-color: var(--brand-primary-border);
}

/* --------------------------------------------------------------------------
   7. Featured Stats Strip
   -------------------------------------------------------------------------- */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin: 2.5rem 0 3.5rem 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow-xs);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.stat-item:not(:last-child)::after {
  content: '';
  position: absolute;
  right: -0.625rem;
  top: 15%;
  height: 70%;
  width: 1px;
  background-color: var(--border-subtle);
}

.stat-number {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--brand-primary);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   8. Section Headers & Grids
   -------------------------------------------------------------------------- */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.section-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.section-action-link {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.section-action-link:hover {
  text-decoration: underline;
}

/* Resource Format Cards (Horizontal Grid) */
.formats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 0.85rem;
  margin-bottom: 3.5rem;
}

.format-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.15rem 0.85rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}

.format-card:hover {
  border-color: var(--brand-primary-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  background-color: var(--brand-primary-light);
}

.format-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface-secondary);
  color: var(--brand-primary);
  font-size: 1.25rem;
}

.format-title {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.format-count {
  font-size: 0.725rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   9. Subject Cards Grid
   -------------------------------------------------------------------------- */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3.5rem;
}

.subject-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all var(--transition-fast);
  position: relative;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
}

.subject-card:hover {
  border-color: var(--brand-primary-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.subject-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.subject-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
}

.subject-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 0.4rem;
  letter-spacing: -0.02em;
}

.subject-card-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.subject-topics-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.topic-chip {
  font-size: 0.725rem;
  padding: 0.2rem 0.55rem;
  background-color: var(--bg-surface-secondary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.subject-card-footer {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand-primary);
}

/* --------------------------------------------------------------------------
   10. Resource Cards Grid (The Sleek Core Experience)
   -------------------------------------------------------------------------- */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.25rem;
}

.resource-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
  position: relative;
}

.resource-card:hover {
  border-color: var(--brand-primary-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.resource-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.resource-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bookmark-btn {
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.bookmark-btn:hover {
  background-color: var(--bg-hover);
  color: var(--brand-accent);
}

.bookmark-btn.bookmarked {
  color: var(--brand-accent);
  background-color: var(--brand-accent-light);
}

.resource-title {
  font-size: 1.025rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
  letter-spacing: -0.015em;
}

.resource-title:hover {
  color: var(--brand-primary);
}

.resource-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.resource-tags {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.resource-meta-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.775rem;
  color: var(--text-muted);
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.resource-author {
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.resource-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

/* --------------------------------------------------------------------------
   11. Resource Library Discovery Layout (Filters + Grid)
   -------------------------------------------------------------------------- */
.library-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.75rem;
  align-items: flex-start;
}

.filter-sidebar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.35rem;
  box-shadow: var(--shadow-xs);
  position: sticky;
  top: calc(var(--header-height) + 1.5rem);
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.filter-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-reset-btn {
  font-size: 0.8rem;
  color: var(--brand-primary);
  font-weight: 600;
}

.filter-reset-btn:hover {
  text-decoration: underline;
}

.filter-section {
  margin-bottom: 1.35rem;
}

.filter-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.filter-pill-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.3rem;
}

.filter-pill-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-pill-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.filter-pill-item.active {
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
  font-weight: 700;
}

.filter-count {
  font-size: 0.75rem;
  background-color: var(--bg-surface-secondary);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

/* Library Toolbar (Search + Sort + View Toggles) */
.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.library-search-box {
  flex: 1;
  min-width: 260px;
  position: relative;
}

.library-search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.library-search-input {
  width: 100%;
  padding: 0.65rem 0.9rem 0.65rem 2.4rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  color: var(--text-primary);
}

.library-sort-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.active-filter-chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.active-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.active-chip-remove {
  cursor: pointer;
  color: var(--text-muted);
}

.active-chip-remove:hover {
  color: var(--color-danger);
}

/* --------------------------------------------------------------------------
   12. Dedicated Resource Detail Page
   -------------------------------------------------------------------------- */
.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.breadcrumb-nav a:hover {
  color: var(--brand-primary);
  text-decoration: underline;
}

.resource-detail-header {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.75rem 2rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-xs);
}

.resource-detail-title {
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-primary);
  margin: 0.75rem 0 0.85rem 0;
}

.resource-detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin: 1rem 0;
}

.meta-detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.meta-detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.meta-detail-value {
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text-primary);
}

.resource-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
}

/* Document Reader & Preview Box */
.document-reader-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.reader-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background-color: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.reader-viewport {
  min-height: 480px;
  padding: 2.5rem 3rem;
  background-color: var(--bg-body);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  line-height: 1.7;
}

.document-sheet {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
  max-width: 840px;
  margin: 0 auto;
  width: 100%;
}

.sheet-header {
  border-bottom: 2px solid var(--brand-primary);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.sheet-watermark {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--brand-primary);
  text-transform: uppercase;
}

.sheet-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-top: 0.25rem;
}

.sheet-body {
  font-size: 0.95rem;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sheet-callout {
  background-color: var(--brand-primary-light);
  border-left: 4px solid var(--brand-primary);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   13. Student Dashboard (Sleek Overview)
   -------------------------------------------------------------------------- */
.dashboard-hero {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a 100%);
  color: #ffffff;
  border-radius: var(--radius-xl);
  padding: 2.25rem 2.5rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.dashboard-greeting {
  font-size: clamp(1.5rem, 3vw, 2.15rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.dashboard-user-meta {
  font-size: 0.95rem;
  opacity: 0.92;
  margin-top: 0.4rem;
  font-weight: 500;
}

.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.25rem;
}

.dash-stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.35rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.dash-stat-card:hover {
  border-color: var(--brand-primary-border);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.dash-stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.dash-stat-info {
  display: flex;
  flex-direction: column;
}

.dash-stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.dash-stat-title {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.dashboard-columns {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.75rem;
}

/* --------------------------------------------------------------------------
   14. Quizzes Engine (Sleek Testing View)
   -------------------------------------------------------------------------- */
.quiz-setup-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.25rem;
  max-width: 720px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
}

.quiz-runner-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.25rem;
  max-width: 800px;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
}

.quiz-progress-bar-bg {
  width: 100%;
  height: 8px;
  background-color: var(--bg-surface-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 1rem 0 1.5rem 0;
}

.quiz-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  transition: width 0.3s ease;
}

.quiz-question-prompt {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.45;
  margin-bottom: 1.75rem;
  letter-spacing: -0.015em;
}

.quiz-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.quiz-option-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.quiz-option-btn:hover {
  border-color: var(--border-medium);
  background-color: var(--bg-hover);
  transform: translateX(2px);
}

.quiz-option-btn.selected {
  border-color: var(--brand-primary);
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
  font-weight: 700;
}

[data-theme="dark"] .quiz-option-btn.selected {
  background-color: rgba(59, 130, 246, 0.15);
}

.quiz-option-letter {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.quiz-option-btn.selected .quiz-option-letter {
  background-color: var(--brand-primary);
  color: #ffffff;
}

/* Quiz Results Screen */
.quiz-results-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.score-circle {
  width: 130px;
  height: 130px;
  border-radius: var(--radius-full);
  background: conic-gradient(var(--brand-primary) calc(var(--percent, 80) * 1%), var(--bg-surface-secondary) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.5rem auto;
  position: relative;
}

.score-circle-inner {
  width: 106px;
  height: 106px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.uneb-grade-badge {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--brand-primary);
}

/* --------------------------------------------------------------------------
   15. AI Tutor Chat Interface (Sleek Clean Panel)
   -------------------------------------------------------------------------- */
.tutor-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  height: calc(100vh - var(--header-height) - 7rem);
  min-height: 540px;
}

.tutor-sidebar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.tutor-chat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tutor-chat-header {
  padding: 1rem 1.5rem;
  background-color: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tutor-messages-box {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.chat-message {
  display: flex;
  gap: 0.85rem;
  max-width: 85%;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.chat-avatar.tutor {
  background: linear-gradient(135deg, var(--brand-primary), #2563eb);
  color: #ffffff;
}

.chat-avatar.user {
  background-color: var(--brand-accent);
  color: #ffffff;
}

.chat-bubble {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: 0.925rem;
  line-height: 1.6;
}

.chat-message.tutor .chat-bubble {
  background-color: var(--bg-surface-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.chat-message.user .chat-bubble {
  background-color: var(--brand-primary);
  color: #ffffff;
}

.tutor-input-bar {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  display: flex;
  gap: 0.75rem;
}

/* Suggested chips */
.prompt-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.prompt-chip {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.prompt-chip:hover {
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
  border-color: var(--brand-primary-border);
}

/* --------------------------------------------------------------------------
   16. Modals (Onboarding, Search, Alerts)
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal-backdrop.active {
  display: flex;
  animation: sleekFadeIn 0.2s ease-in-out;
}

.modal-dialog {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  padding: 2.25rem;
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

/* Onboarding Choices Grid */
.class-select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin: 1.5rem 0;
}

.class-choice-card {
  padding: 1rem 0.75rem;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background-color: var(--bg-surface);
}

.class-choice-card:hover {
  border-color: var(--border-medium);
  background-color: var(--bg-hover);
}

.class-choice-card.selected {
  border-color: var(--brand-primary);
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
  font-weight: 700;
}

.subjects-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.65rem;
  max-height: 280px;
  overflow-y: auto;
  margin: 1.5rem 0;
  padding-right: 0.4rem;
}

.subject-choice-card {
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.subject-choice-card:hover {
  border-color: var(--border-medium);
  background-color: var(--bg-hover);
}

.subject-choice-card.selected {
  border-color: var(--brand-primary);
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
  font-weight: 700;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast-message {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background-color: var(--text-primary);
  color: var(--bg-surface);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

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

/* --------------------------------------------------------------------------
   16. Professional Site Footer
   -------------------------------------------------------------------------- */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  margin-top: 4rem;
  padding-top: 3.5rem;
  padding-bottom: 2.5rem;
  color: var(--text-secondary);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.footer-container {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 2.5rem;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-col-brand {
  max-width: 320px;
}

.footer-logo {
  margin-bottom: 0.25rem;
}

.footer-description {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

.footer-socials {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.social-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background-color: var(--bg-body);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.social-link-btn:hover {
  color: var(--brand-primary);
  background-color: var(--brand-primary-light);
  border-color: var(--brand-primary-border);
  transform: translateY(-2px);
}

.footer-col-title {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.footer-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.footer-nav-link {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.footer-nav-link:hover {
  color: var(--brand-primary);
  transform: translateX(2px);
}

.footer-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.825rem;
  color: var(--text-muted);
}

.footer-copyright-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer-dot-divider {
  opacity: 0.5;
}

.footer-tagline-text {
  font-weight: 600;
  color: var(--text-secondary);
}

.footer-curriculum-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-weight: 600;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   17. Comprehensive Responsive Architecture (320px to 1920px+)
   -------------------------------------------------------------------------- */

/* Safe global overflow prevention */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Base container responsive padding */
.container {
  width: 100%;
  max-width: var(--max-content-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(1rem, 3vw, 1.5rem);
  padding-right: clamp(1rem, 3vw, 1.5rem);
  box-sizing: border-box;
}

/* Ensure flex/grid children don't overflow due to min-width auto */
.hero-search-wrapper,
.hero-search-bar,
.hero-search-input,
.resource-card,
.subject-card,
.format-card,
.dash-stat-card,
.quiz-setup-card,
.quiz-runner-card,
.quiz-results-card,
.tutor-chat-card,
.tutor-sidebar,
.filter-sidebar,
.library-main,
.modal-dialog,
.document-sheet,
.breadcrumb-nav {
  min-width: 0;
}

/* --- Breakpoint: Extra Large / Desktop (1200px - 1920px+) --- */
@media (min-width: 1440px) {
  .hero-section {
    padding: 3.5rem 0 2.5rem 0;
  }
}

/* --- Breakpoint: Laptops & Tablets Landscape (max-width: 1024px) --- */
@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2rem;
  }

  .nav-links {
    gap: 0.2rem;
  }

  .nav-link {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
  }
}

/* --- Breakpoint: Medium Tablets & Small Laptops (max-width: 992px) --- */
@media (max-width: 992px) {
  .library-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .filter-sidebar {
    position: static;
    width: 100%;
  }

  .filter-pill-list {
    max-height: 180px;
  }

  .dashboard-columns {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  /* AI Tutor on tablet: Keep sidebar accessible with horizontal prompt scroll */
  .tutor-container {
    grid-template-columns: 1fr;
    height: auto;
    gap: 1rem;
  }

  .tutor-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .prompt-chips-wrap {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    -webkit-overflow-scrolling: touch;
  }

  .prompt-chip {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .tutor-chat-card {
    height: clamp(480px, 62vh, 650px);
  }
}

/* --- Breakpoint: Tablets Portrait & Phablets (max-width: 768px) --- */
@media (max-width: 768px) {
  /* Navigation switches to Mobile Drawer & Bottom Bar */
  .nav-links, 
  #header-search-trigger {
    display: none;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  /* Prevent bottom nav from obscuring page content or footer */
  .main-content {
    padding-bottom: calc(64px + 2rem);
  }

  .site-footer {
    margin-bottom: 64px; /* Clearance for fixed mobile bottom navigation */
    padding-top: 2.75rem;
    padding-bottom: 2rem;
  }

  .header-container {
    gap: 0.75rem;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    margin: 2rem 0 2.5rem 0;
  }

  .stat-item:nth-child(2)::after {
    display: none;
  }

  .class-select-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .toast-container {
    bottom: 5.5rem;
    right: 1rem;
    left: 1rem;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }

  .footer-col-brand {
    grid-column: 1 / -1;
    max-width: 100%;
  }

  .footer-bottom-bar {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.85rem;
  }

  .footer-copyright-wrap {
    justify-content: center;
  }

  .formats-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2.5rem;
  }

  .subjects-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
  }

  .resources-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
  }
}

/* --- Breakpoint: Standard Mobile Devices (max-width: 640px) --- */
@media (max-width: 640px) {
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .section-title {
    font-size: 1.25rem;
  }

  .dashboard-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.5rem;
  }

  .dashboard-hero > div:last-child {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }

  .dashboard-hero > div:last-child .btn {
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  .subjects-grid {
    grid-template-columns: 1fr;
  }

  .resources-grid {
    grid-template-columns: 1fr;
  }

  .library-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .library-search-box {
    width: 100%;
    min-width: 100%;
  }

  .library-sort-wrap {
    width: 100%;
    justify-content: space-between;
  }

  .library-sort-wrap .form-select {
    flex: 1;
  }

  .resource-detail-header {
    padding: 1.25rem;
  }

  .resource-detail-meta-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .resource-detail-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .resource-detail-toolbar > div:first-child {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.5rem !important;
  }

  .resource-detail-toolbar .btn {
    width: 100%;
    justify-content: center;
  }

  .reader-viewport {
    padding: 1.25rem 1rem;
    min-height: 320px;
  }

  .document-sheet {
    padding: 1.25rem 1rem;
  }
}

/* --- Breakpoint: Small Mobile Phones & Compact Screens (max-width: 480px) --- */
@media (max-width: 480px) {
  .container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .header-actions {
    gap: 0.35rem;
  }

  .header-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .logo-badge {
    width: 34px;
    height: 34px;
  }

  .logo-title {
    font-size: 1.15rem;
  }

  .logo-tagline {
    font-size: 0.58rem;
  }

  .student-class-chip {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    gap: 0.25rem;
  }

  .hero-section {
    padding: 1.75rem 0 1.25rem 0;
  }

  .hero-title {
    font-size: 1.65rem;
    line-height: 1.2;
  }

  .hero-subtitle {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .hero-search-bar {
    padding: 0.3rem 0.35rem 0.3rem 0.85rem;
  }

  .hero-search-input {
    font-size: 0.9rem;
  }

  .hero-search-btn {
    padding: 0.55rem 1rem;
    font-size: 0.825rem;
  }

  .class-pill-label {
    width: 100%;
    text-align: center;
    margin-bottom: 0.2rem;
  }

  .class-quick-pills {
    gap: 0.35rem;
  }

  .class-pill {
    padding: 0.28rem 0.6rem;
    font-size: 0.75rem;
  }

  .hero-cta-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.6rem;
  }

  .hero-cta-group .btn-lg {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.85rem;
    padding: 1.15rem 0.85rem;
  }

  .stat-item::after {
    display: none !important;
  }

  .stat-number {
    font-size: 1.45rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .formats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .format-card {
    padding: 0.95rem 0.65rem;
  }

  .format-icon-box {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .format-title {
    font-size: 0.78rem;
  }

  .resources-grid {
    grid-template-columns: 1fr;
  }

  .resource-card {
    padding: 1.15rem;
  }

  .resource-actions {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .resource-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }

  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .dash-stat-card {
    padding: 0.95rem 0.85rem;
    gap: 0.75rem;
  }

  .dash-stat-icon {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  .dash-stat-value {
    font-size: 1.35rem;
  }

  .quiz-setup-card,
  .quiz-runner-card,
  .quiz-results-card {
    padding: 1.25rem;
  }

  .quiz-option-btn {
    padding: 0.75rem 0.85rem;
    gap: 0.65rem;
    font-size: 0.875rem;
  }

  .quiz-runner-card > div:last-child {
    flex-direction: column-reverse;
    gap: 0.6rem;
  }

  .quiz-runner-card > div:last-child .btn {
    width: 100%;
    justify-content: center;
  }

  .quiz-results-card > div:nth-of-type(2) {
    flex-direction: column;
  }

  .quiz-results-card > div:nth-of-type(2) .btn {
    width: 100%;
    justify-content: center;
  }

  .tutor-chat-header {
    padding: 0.85rem 1rem;
  }

  .tutor-messages-box {
    padding: 1rem;
  }

  .chat-message {
    max-width: 94%;
  }

  .chat-bubble {
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
  }

  .tutor-input-bar {
    padding: 0.75rem;
    gap: 0.5rem;
  }

  .modal-dialog {
    padding: 1.35rem 1.15rem;
  }

  .modal-close-btn {
    top: 0.85rem;
    right: 0.85rem;
  }

  .class-select-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .class-choice-card {
    padding: 0.75rem 0.5rem;
    font-size: 0.825rem;
  }

  .subjects-select-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .footer-nav-link {
    min-height: 38px;
    display: flex;
    align-items: center;
  }
}

/* --- Breakpoint: Ultra-Small Mobile Phones (320px - 360px) --- */
@media (max-width: 360px) {
  .container {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .header-container {
    gap: 0.35rem;
  }

  .header-actions {
    gap: 0.25rem;
  }

  .logo-link {
    gap: 0.4rem;
  }

  .logo-title {
    font-size: 1.05rem;
  }

  .logo-tagline {
    display: none;
  }

  .student-class-chip {
    padding: 0.25rem 0.45rem;
    font-size: 0.7rem;
  }

  .student-class-chip svg {
    display: none;
  }

  .stats-strip {
    grid-template-columns: 1fr;
    gap: 0.65rem;
    padding: 1rem 0.75rem;
  }

  .dashboard-stats-grid {
    grid-template-columns: 1fr;
  }

  .formats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
  }

  .format-card {
    padding: 0.75rem 0.35rem;
  }

  .resource-detail-meta-grid {
    grid-template-columns: 1fr;
  }

  .class-choice-card {
    padding: 0.6rem 0.35rem;
  }
}

/* --------------------------------------------------------------------------
   Search Suggestions Dropdown & Live Query Styles
   -------------------------------------------------------------------------- */
.search-suggestions-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-height: 380px;
  overflow-y: auto;
  z-index: 100;
  padding: 0.5rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.search-clear-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  margin-right: 0.25rem;
}

.search-clear-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.9rem;
}

.suggestion-item:hover,
.suggestion-item.focused {
  background-color: var(--bg-hover);
  transform: translateX(2px);
}

.suggestion-item-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

.suggestion-item-icon {
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.suggestion-item-text {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-item-text mark {
  background: transparent;
  color: var(--brand-primary);
  font-weight: 700;
}

.suggestion-item-badge {
  font-size: 0.725rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.suggestion-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem 0.2rem 0.75rem;
}

/* --------------------------------------------------------------------------
   Interactive Micro-animations & Team Cards
   -------------------------------------------------------------------------- */
.team-card {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.team-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-primary-border);
}

/* Accessible focus rings */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* View transition fade-in */
.view-section.active {
  animation: fadeInView 0.25s ease-out forwards;
}

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

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


