/* ===================== Design tokens ===================== */
:root {
  --color-bg: #f3f5fb;
  --color-surface: #ffffff;
  --color-surface-alt: #f8f9fe;
  --color-border: #e6e8f2;
  --color-text: #1a1d2e;
  --color-text-muted: #6b7089;
  --color-text-faint: #9498ad;

  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-primary-light: #eef0fd;
  --color-accent: #06b6d4;
  --color-success: #16a34a;
  --color-success-light: #ecfdf3;
  --color-danger: #e11d48;
  --color-danger-light: #fef1f4;
  --color-warning: #d97706;
  --color-warning-light: #fef8ec;

  --sidebar-start: #3730a3;
  --sidebar-end: #6d28d9;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(26, 29, 46, 0.06), 0 1px 3px rgba(26, 29, 46, 0.06);
  --shadow-md: 0 8px 24px rgba(26, 29, 46, 0.08);
  --shadow-lg: 0 16px 40px rgba(26, 29, 46, 0.14);

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6, .brand, .stat-card .stat-value {
  font-family: "Poppins", "Inter", sans-serif;
}

a { color: var(--color-primary); }

::selection { background: var(--color-primary-light); }

/* ===================== App shell ===================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-start), var(--sidebar-end));
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.4rem 1.25rem 1rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: #fff;
  text-decoration: none;
}

.sidebar-brand .brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
  padding: 0.9rem 0.75rem 0.3rem;
  font-weight: 600;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: rgba(255, 255, 255, 0.82);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar .nav-link i { font-size: 1.05rem; width: 1.3rem; text-align: center; }

.sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar .nav-link.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: inset 3px 0 0 #fff;
}

.sidebar-footer {
  padding: 0.9rem 1.1rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-user-name { font-size: 0.85rem; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-user-role {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
  text-transform: capitalize;
}

.sidebar-logout {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 500;
}
.sidebar-logout:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-toggle {
  border: none;
  background: var(--color-primary-light);
  color: var(--color-primary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 19, 32, 0.45);
  z-index: 1030;
}

.content {
  padding: 1.75rem 2rem 3rem;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header .eyebrow {
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0.15rem 0 0.2rem;
}

.page-header p {
  color: var(--color-text-muted);
  margin: 0;
  font-size: 0.92rem;
}

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-area { margin-left: 0; }
  .topbar { display: flex; }
  .sidebar-backdrop.show { display: block; }
  .content { padding: 1.25rem 1rem 2.5rem; }
}

/* ===================== Cards & surfaces ===================== */
.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.section-card-header h2,
.section-card-header h5 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.section-card-header .subtitle {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

@media (max-width: 576px) {
  .section-card { padding: 1.05rem; border-radius: var(--radius-sm); }
}

/* Dashboard tiles */
.nav-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.tile-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.35rem 1.1rem;
  height: 100%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  text-align: center;
}

.nav-tile:hover .tile-card {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary-light);
}

.tile-card.disabled {
  opacity: 0.55;
  cursor: default;
}

.tile-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
  font-size: 1.5rem;
  color: #fff;
}

.tile-icon.bg-1 { background: linear-gradient(135deg, #4f46e5, #4338ca); }
.tile-icon.bg-2 { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.tile-icon.bg-3 { background: linear-gradient(135deg, #10b981, #059669); }
.tile-icon.bg-4 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.tile-icon.bg-5 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.tile-icon.bg-6 { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.tile-icon.bg-7 { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.tile-icon.bg-8 { background: linear-gradient(135deg, #64748b, #475569); }

.stat-icon.bg-1 { background: linear-gradient(135deg, #4f46e5, #4338ca); }
.stat-icon.bg-2 { background: linear-gradient(135deg, #10b981, #059669); }
.stat-icon.bg-3 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.bg-4 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.tile-title { font-weight: 700; font-size: 0.95rem; }
.tile-sub { color: var(--color-text-muted); font-size: 0.78rem; margin-top: 0.15rem; }

/* Stat cards */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  height: 100%;
}

.stat-card .stat-label {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  margin: 0.15rem 0;
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  float: right;
}

.stat-trend { font-size: 0.78rem; font-weight: 600; }
.stat-trend.up { color: var(--color-success); }
.stat-trend.down { color: var(--color-danger); }

/* Badges */
.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-soft.primary { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-soft.success { background: var(--color-success-light); color: var(--color-success); }
.badge-soft.danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge-soft.warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-soft.neutral { background: var(--color-surface-alt); color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* Buttons */
.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
.btn-outline-primary {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline-primary:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

/* Progress */
.progress { background: var(--color-surface-alt); border-radius: 999px; height: 0.55rem; }
.progress-bar { background: var(--color-primary); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--color-text-muted);
}
.empty-state .empty-icon {
  font-size: 2.2rem;
  margin-bottom: 0.6rem;
  color: var(--color-text-faint);
}
.empty-state h6 { color: var(--color-text); font-weight: 600; margin-bottom: 0.25rem; }

/* Auth page */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 15% 20%, #6d28d9 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, #4f46e5 0%, transparent 45%),
    linear-gradient(160deg, #1e1b4b, #312e81 55%, #1e1b4b);
  padding: 1.5rem;
}

.auth-card {
  max-width: 400px;
  width: 100%;
  margin: 0;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: none;
}

.auth-card .card-body { padding: 2.25rem 2rem; }

.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--sidebar-start), var(--sidebar-end));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
  margin: 0 auto 1rem;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: #fff;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  width: 100%;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.btn-google:hover { box-shadow: var(--shadow-sm); border-color: #c7cbe0; }

/* Topic chips (daily log) */
.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.35rem 0.5rem 0.35rem 0.9rem;
  margin: 0.25rem;
}
.topic-chip .chip-hours { width: 4.5rem; }
.topic-breadcrumb { font-size: 0.8rem; color: var(--color-text-muted); }

/* Question card */
.question-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}

.option-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.option-row:hover { border-color: var(--color-primary); }
.option-row.selected { border-color: var(--color-primary); background: var(--color-primary-light); }
.option-row.correct { border-color: var(--color-success); background: var(--color-success-light); }
.option-row.incorrect { border-color: var(--color-danger); background: var(--color-danger-light); }
.option-row input { margin-top: 0.2rem; }

.timer-badge {
  font-family: "Poppins", monospace;
  font-weight: 700;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.9rem;
  font-size: 1.05rem;
}
.timer-badge.low { background: var(--color-danger-light); color: var(--color-danger); }

/* Misc */
.table { color: var(--color-text); }
.table thead th {
  border-bottom-width: 1px;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

textarea.form-control, input.form-control, select.form-select {
  border-radius: var(--radius-sm);
  border-color: var(--color-border);
}
textarea.form-control:focus, input.form-control:focus, select.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.12);
}

.chapter-progress-row + .chapter-progress-row { margin-top: 0.85rem; }

@media (max-width: 576px) {
  .section-card { padding: 1rem; border-radius: 0.5rem; }
}
