/* ============================================================
   PrepLr - Main Design System
   Apple + Notion + Linear inspired
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  /* Brand */
  --accent:          #6366F1;
  --accent-hover:    #4F46E5;
  --accent-light:    rgba(99, 102, 241, 0.10);
  --accent-glow:     rgba(99, 102, 241, 0.20);

  /* Light Mode ONLY */
  --bg:              #F8F8FC;
  --bg-2:            #FFFFFF;
  --bg-3:            #F0F0F8;
  --bg-4:            #E8E8F4;
  --border:          #E0E0EE;
  --border-light:    #EBEBF5;
  --text-1:          #0A0A1A;
  --text-2:          #4A4A6A;
  --text-3:          #8A8AAA;
  --text-4:          #BBBBD0;

  /* Status Colors */
  --success:         #22C55E;
  --success-light:   rgba(34, 197, 94, 0.12);
  --warning:         #F59E0B;
  --warning-light:   rgba(245, 158, 11, 0.12);
  --danger:          #EF4444;
  --danger-light:    rgba(239, 68, 68, 0.12);
  --info:            #3B82F6;
  --info-light:      rgba(59, 130, 246, 0.12);

  /* Subject Colors */
  --physics:         #6366F1;
  --chemistry:       #22C55E;
  --maths:           #F59E0B;
  --biology:         #EC4899;

  /* Typography */
  --font:            'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:       'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-1:         4px;
  --space-2:         8px;
  --space-3:         12px;
  --space-4:         16px;
  --space-5:         20px;
  --space-6:         24px;
  --space-8:         32px;
  --space-10:        40px;
  --space-12:        48px;
  --space-16:        64px;

  /* Border Radius */
  --radius-sm:       6px;
  --radius:          10px;
  --radius-md:       12px;
  --radius-lg:       16px;
  --radius-xl:       20px;
  --radius-full:     9999px;

  /* Shadows */
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.4);
  --shadow:          0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.4);
  --shadow-accent:   0 4px 20px rgba(99,102,241,0.3);

  /* Transitions */
  --transition:      all 0.2s ease;
  --transition-slow: all 0.35s ease;

  /* Sidebar */
  --sidebar-width:   240px;
  --sidebar-collapsed: 64px;

  /* Header */
  --header-height:   60px;
}

/* ── Light Mode ───────────────────────────────────────────── */
[data-theme="light"] {
  --bg:              #F8F8FC;
  --bg-2:            #FFFFFF;
  --bg-3:            #F0F0F8;
  --bg-4:            #E8E8F4;
  --border:          #E0E0EE;
  --border-light:    #EBEBF5;
  --text-1:          #0A0A1A;
  --text-2:          #4A4A6A;
  --text-3:          #8A8AAA;
  --text-4:          #BBBBD0;
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.08);
  --shadow:          0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.12);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-1);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

img { max-width: 100%; height: auto; display: block; }

button, input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
}

ul, ol { list-style: none; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-1);
  letter-spacing: -0.02em;
}

h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p { color: var(--text-2); line-height: 1.7; }

.text-xs   { font-size: 11px; }
.text-sm   { font-size: 12px; }
.text-base { font-size: 14px; }
.text-md   { font-size: 15px; }
.text-lg   { font-size: 16px; }
.text-xl   { font-size: 18px; }
.text-2xl  { font-size: 22px; }
.text-3xl  { font-size: 28px; }

.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }

.text-primary   { color: var(--text-1); }
.text-secondary { color: var(--text-2); }
.text-muted     { color: var(--text-3); }
.text-accent    { color: var(--accent); }
.text-success   { color: var(--success); }
.text-warning   { color: var(--warning); }
.text-danger    { color: var(--danger); }

/* ── Layout ───────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

.page-wrapper {
  padding: var(--space-8);
  max-width: 1400px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.page-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 3px;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-logo {
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-height);
}

.sidebar-logo img {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.nav-section {
  margin-bottom: var(--space-6);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  text-decoration: none;
}

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

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

.nav-item.active .nav-icon {
  color: var(--accent);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-user:hover { background: var(--bg-3); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-level {
  font-size: 11px;
  color: var(--text-3);
}

/* ── Top Header ───────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.header-search input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4) var(--space-2) 36px;
  color: var(--text-1);
  font-size: 13px;
  transition: var(--transition);
  outline: none;
}

.header-search input:focus {
  border-color: var(--accent);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.header-search input::placeholder { color: var(--text-4); }

.header-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  width: 16px;
  height: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
}

.header-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
}

.header-btn .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-2);
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-light);
}

.card-sm { padding: var(--space-4); border-radius: var(--radius-md); }
.card-lg { padding: var(--space-8); border-radius: var(--radius-xl); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: var(--transition);
}

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

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.accent  { background: var(--accent-light); color: var(--accent); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-light); color: var(--danger); }

.stat-body { flex: 1; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.stat-change {
  font-size: 11px;
  font-weight: 500;
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
  height: 36px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
  color: white;
}

.btn-secondary {
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-4);
  border-color: var(--text-4);
  color: var(--text-1);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-3);
  color: var(--text-1);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: white;
}

.btn-success {
  background: var(--success-light);
  color: var(--success);
}
.btn-success:hover:not(:disabled) {
  background: var(--success);
  color: white;
}

.btn-sm {
  height: 30px;
  padding: var(--space-1) var(--space-3);
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  height: 44px;
  padding: var(--space-3) var(--space-8);
  font-size: 15px;
  border-radius: var(--radius-md);
}

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

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
}

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: var(--space-2);
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  color: var(--text-1);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
  appearance: none;
}

.form-control:focus {
  border-color: var(--accent);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-4); }

.form-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B8A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: var(--space-1);
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-control.is-invalid {
  border-color: var(--danger);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Input with icon */
.input-group {
  position: relative;
}

.input-group .form-control {
  padding-left: 40px;
}

.input-group .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.input-group .input-icon-right {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  cursor: pointer;
  width: 16px;
  height: 16px;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-accent   { background: var(--accent-light); color: var(--accent); }
.badge-success  { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-danger   { background: var(--danger-light); color: var(--danger); }
.badge-info     { background: var(--info-light); color: var(--info); }
.badge-muted    { background: var(--bg-3); color: var(--text-3); }

/* Status badges */
.badge-not-started { background: var(--bg-3); color: var(--text-3); }
.badge-learning    { background: var(--info-light); color: var(--info); }
.badge-practicing  { background: var(--warning-light); color: var(--warning); }
.badge-mastered    { background: var(--success-light); color: var(--success); }
.badge-forgotten   { background: var(--danger-light); color: var(--danger); }

/* ── Progress Bars ────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: width 0.6s ease;
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

.progress-lg { height: 10px; }
.progress-sm { height: 4px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-3);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  font-size: 13.5px;
  color: var(--text-2);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td {
  background: var(--bg-3);
  color: var(--text-1);
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  border: 1px solid transparent;
}

.alert-success { background: var(--success-light); color: var(--success); border-color: rgba(34,197,94,0.2); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: rgba(245,158,11,0.2); }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border-color: rgba(239,68,68,0.2); }
.alert-info    { background: var(--info-light);    color: var(--info);    border-color: rgba(59,130,246,0.2); }
.alert-accent  { background: var(--accent-light);  color: var(--accent);  border-color: rgba(99,102,241,0.2); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: var(--transition);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--bg-3);
  border: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-6);
}

.tab {
  padding: var(--space-3) var(--space-4);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text-1); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Dropdown ─────────────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: var(--transition);
  overflow: hidden;
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.dropdown-item:hover {
  background: var(--bg-3);
  color: var(--text-1);
}

.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-light); }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

/* ── Toast Notifications ──────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: slideInRight 0.3s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--accent); }

.toast-icon { flex-shrink: 0; }
.toast-message { font-size: 13.5px; color: var(--text-1); flex: 1; }
.toast-close { color: var(--text-4); cursor: pointer; flex-shrink: 0; }

/* ── Subject Progress ─────────────────────────────────────── */
.subject-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: var(--transition);
  cursor: pointer;
}

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

.subject-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.subject-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.subject-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.subject-chapters {
  font-size: 12px;
  color: var(--text-3);
}

/* ── Streak Widget ────────────────────────────────────────── */
.streak-widget {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(239,68,68,0.1));
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.streak-fire {
  font-size: 28px;
  line-height: 1;
}

.streak-count {
  font-size: 28px;
  font-weight: 800;
  color: var(--warning);
  letter-spacing: -0.04em;
}

.streak-label {
  font-size: 12px;
  color: var(--text-3);
}

/* ── Revision Cards ───────────────────────────────────────── */
.revision-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-2);
  transition: var(--transition);
}

.revision-item:hover {
  border-color: var(--accent);
  background: var(--bg-3);
}

.revision-priority {
  width: 4px;
  height: 40px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.priority-high   { background: var(--danger); }
.priority-medium { background: var(--warning); }
.priority-low    { background: var(--success); }

/* ── Heatmap ──────────────────────────────────────────────── */
.heatmap {
  display: grid;
  grid-template-columns: repeat(53, 1fr);
  gap: 3px;
}

.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--bg-3);
  transition: var(--transition);
  cursor: pointer;
}

.heatmap-cell:hover { transform: scale(1.3); }
.heatmap-cell.level-1 { background: rgba(99,102,241,0.2); }
.heatmap-cell.level-2 { background: rgba(99,102,241,0.4); }
.heatmap-cell.level-3 { background: rgba(99,102,241,0.6); }
.heatmap-cell.level-4 { background: rgba(99,102,241,0.8); }
.heatmap-cell.level-5 { background: var(--accent); }

/* ── Timer ────────────────────────────────────────────────── */
.timer-display {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.timer-ring {
  transform: rotate(-90deg);
}

.timer-ring-bg {
  fill: none;
  stroke: var(--bg-3);
  stroke-width: 8;
}

.timer-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}

/* ── Knowledge Graph ──────────────────────────────────────── */
.graph-container {
  width: 100%;
  height: 500px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

/* ── Onboarding ───────────────────────────────────────────── */
.onboarding-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: var(--space-6);
}

.onboarding-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-12);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
}

.onboarding-steps {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.onboarding-step {
  flex: 1;
  height: 4px;
  background: var(--bg-3);
  border-radius: var(--radius-full);
  transition: var(--transition-slow);
}

.onboarding-step.active { background: var(--accent); }
.onboarding-step.done   { background: var(--success); }

/* ── Auth Pages ───────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}

.auth-left {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 72px;
}

.auth-right {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 64px 72px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  margin-bottom: var(--space-8);
}

.auth-logo img {
  height: 36px;
}

.auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: var(--space-8);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-6) 0;
  color: var(--text-4);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Dashboard Grid ───────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.dashboard-main {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-6);
}

.dashboard-sidebar-right {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ── Empty States ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
}

.empty-icon {
  width: 64px;
  height: 64px;
  background: var(--bg-3);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-5);
  color: var(--text-4);
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: var(--space-2);
}

.empty-desc {
  font-size: 13.5px;
  color: var(--text-3);
  margin-bottom: var(--space-6);
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Skeleton Loading ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text.w-3\/4 { width: 75%; }
.skeleton-text.w-1\/2 { width: 50%; }
.skeleton-title { height: 20px; margin-bottom: 12px; }
.skeleton-card { height: 120px; border-radius: var(--radius-lg); }

/* ── Tooltips ─────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-4);
  color: var(--text-1);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: var(--transition);
  z-index: 100;
  border: 1px solid var(--border);
}

[data-tooltip]:hover::after { opacity: 1; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ── Animations ───────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.animate-fade-in    { animation: fadeIn 0.3s ease; }
.animate-slide-up   { animation: slideInUp 0.3s ease; }
.animate-pulse      { animation: pulse 2s infinite; }
.animate-spin       { animation: spin 1s linear infinite; }
.animate-bounce     { animation: bounce 1s ease infinite; }

/* ── Utility Classes ──────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.grid   { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.hidden { display: none; }
.block  { display: block; }
.relative { position: relative; }
.absolute { position: absolute; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded    { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }
.border { border: 1px solid var(--border); }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.opacity-50 { opacity: 0.5; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.p-4  { padding: var(--space-4); }
.p-6  { padding: var(--space-6); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-main { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-wrapper {
    padding: var(--space-4);
  }

  .auth-wrapper {
    grid-template-columns: 1fr;
  }

  .auth-left { display: none; }

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

  .top-header { padding: 0 var(--space-4); }

  .header-search { display: none; }

  .timer-display { font-size: 48px; }

  .heatmap { grid-template-columns: repeat(26, 1fr); }

  .modal { max-width: 100%; margin: var(--space-4); }

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

@media (max-width: 480px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .auth-right { padding: var(--space-6); }
  .onboarding-card { padding: var(--space-6); }
}

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

@media (max-width: 768px) {
  .sidebar-overlay.active { display: block; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .top-header, .btn, .toast-container { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { border: 1px solid #ddd; }
}

/* ── Practice Hero — force white text ─────────────────────── */
.practice-hero,
.practice-hero h1,
.practice-hero h2,
.practice-hero h3,
.practice-hero p,
.practice-hero span,
.practice-hero div,
.practice-hero a,
.practice-hero label {
  color: #ffffff !important;
}
.practice-hero .hero-stat-label {
  color: rgba(255,255,255,0.85) !important;
}
