/* ============================================================
   LMS Platform — Main Stylesheet
   ============================================================ */

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

:root {
  --primary:        #1e3a5f;
  --primary-dark:   #142840;
  --primary-mid:    #264d7a;
  --accent:         #2563eb;
  --accent-dark:    #1d4ed8;
  --accent-light:   #eff6ff;
  --accent-subtle:  rgba(37,99,235,0.06);
  --success:        #15803d;
  --success-bg:     #f0fdf4;
  --error:          #b91c1c;
  --error-bg:       #fef2f2;
  --warning:        #b45309;
  --warning-bg:     #fffbeb;
  --gray-50:        #f8fafc;
  --gray-100:       #f1f5f9;
  --gray-150:       #eaeff5;
  --gray-200:       #e2e8f0;
  --gray-300:       #cbd5e1;
  --gray-400:       #94a3b8;
  --gray-500:       #64748b;
  --gray-600:       #475569;
  --gray-700:       #334155;
  --gray-800:       #1e293b;
  --gray-900:       #0f172a;
  --white:          #ffffff;
  --sidebar-w:      224px;
  --topbar-h:       58px;
  --radius:         8px;
  --radius-sm:      5px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --shadow-xs:      0 1px 2px rgba(0,0,0,0.04);
  --shadow:         0 1px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:      0 8px 28px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05);
  --shadow-xl:      0 20px 48px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --transition:     0.18s ease;
  --transition-md:  0.28s ease;
  --font:           'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --bottom-nav-h:   60px;
}

/* ── BASE ────────────────────────────────────────────────────── */
html { overflow-x: hidden; }
body {
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--gray-100);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* Prevent inputs/selects from bursting out of their containers */
input, select, textarea, button { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── TYPOGRAPHY ─────────────────────────────────────────────── */
h1 { font-size: 1.5rem;  font-weight: 700; color: var(--gray-900); letter-spacing: -0.02em; line-height: 1.25; }
h2 { font-size: 1.25rem; font-weight: 700; color: var(--gray-900); letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; font-weight: 600; color: var(--gray-800); }
p  { color: var(--gray-600); line-height: 1.65; }

/* ── ENTRANCE ANIMATIONS ─────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

.animate-fade-up  { animation: fadeUp  0.35s ease both; }
.animate-fade-in  { animation: fadeIn  0.25s ease both; }
.animate-scale-in { animation: scaleIn 0.22s ease both; }

/* Staggered animation delays for grid children */
.stagger-children > *:nth-child(1) { animation-delay: 0.04s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.08s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.12s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.16s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.20s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.24s; }

/* ── SKELETON LOADER ─────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
.skeleton-text  { height: 14px; border-radius: 4px; margin-bottom: 8px; }
.skeleton-title { height: 20px; border-radius: 4px; margin-bottom: 12px; width: 60%; }
.skeleton-card  { height: 120px; border-radius: var(--radius-lg); }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 0.875rem; font-weight: 600; cursor: pointer; line-height: 1.4;
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition), color var(--transition),
              transform 0.12s ease;
  text-decoration: none; white-space: nowrap; font-family: var(--font);
  letter-spacing: 0.01em;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent); color: var(--white); border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(37,99,235,0.25);
}
.btn-primary:hover {
  background: var(--accent-dark); border-color: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,0.30);
}

.btn-secondary { background: var(--white); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); box-shadow: var(--shadow-xs); }

.btn-ghost { background: transparent; color: var(--gray-600); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-success { background: var(--success); color: var(--white); border-color: var(--success); box-shadow: 0 1px 3px rgba(21,128,61,0.2); }
.btn-success:hover { background: #166534; box-shadow: 0 4px 10px rgba(21,128,61,0.25); }

.btn-danger  { background: var(--error); color: var(--white); border-color: var(--error); }
.btn-danger:hover  { background: #991b1b; }

.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent-light); }

.btn-sm  { padding: 6px 13px; font-size: 0.8rem; }
.btn-lg  { padding: 12px 26px; font-size: 0.95rem; }
.btn-full { width: 100%; }

/* ── ALERTS ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 0.875rem; font-weight: 500;
  border: 1px solid transparent; display: flex; align-items: flex-start; gap: 10px;
  animation: fadeUp 0.3s ease;
}
.alert-error   { background: var(--error-bg);   color: var(--error);   border-color: #fecaca; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }
.alert-info    { background: var(--accent-light); color: var(--accent); border-color: #bfdbfe; }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--gray-700); margin-bottom: 6px; letter-spacing: 0.01em;
}
.label-hint { font-weight: 400; color: var(--gray-400); font-size: 0.75rem; margin-left: 4px; }
.label-req  { color: var(--error); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="file"],
select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  font-size: 0.875rem; font-family: var(--font); color: var(--gray-900);
  background: var(--white); line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--gray-100); color: var(--gray-400); cursor: not-allowed;
}
textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 0.76rem; color: var(--gray-400); margin-top: 4px; }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 44px; }
.toggle-pw {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--gray-400);
  padding: 0; display: flex; align-items: center;
}
.toggle-pw:hover { color: var(--gray-600); }
.toggle-pw svg { width: 18px; height: 18px; }

input[type="checkbox"], input[type="radio"] {
  width: 15px; height: 15px; border: 1.5px solid var(--gray-400);
  border-radius: 3px; cursor: pointer; accent-color: var(--accent);
  appearance: auto; padding: 0;
}
.check-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.875rem; font-weight: 400; color: var(--gray-700);
  cursor: pointer; user-select: none; margin-bottom: 0;
}

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200); box-shadow: var(--shadow-xs); padding: 24px;
  transition: box-shadow var(--transition-md);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-150);
}
.card-title { font-size: 0.95rem; font-weight: 700; color: var(--gray-800); }

/* Interactive card (for course/quiz cards) */
.card-interactive {
  cursor: pointer;
  transition: transform var(--transition-md), box-shadow var(--transition-md),
              border-color var(--transition-md);
}
.card-interactive:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--gray-300);
}
.card-interactive:active { transform: translateY(-1px); }

/* ── TABLES ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead tr { background: var(--gray-50); border-bottom: 2px solid var(--gray-200); }
thead th {
  padding: 11px 14px; text-align: left; font-weight: 600;
  color: var(--gray-500); font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.05em; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background var(--transition); }
tbody tr:hover { background: var(--gray-50); }
tbody td { padding: 12px 14px; color: var(--gray-700); vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 0.71rem; font-weight: 600; letter-spacing: 0.03em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error   { background: var(--error-bg);   color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--accent-light); color: var(--accent); }
.badge-gray    { background: var(--gray-100);   color: var(--gray-600); }
.badge-dark    { background: var(--gray-800);   color: var(--white); }

/* ── STAT CARDS ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-md), box-shadow var(--transition-md);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
/* Subtle top accent line */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition-md);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card:hover::before { opacity: 1; }

.stat-val   { font-size: 2rem; font-weight: 800; color: var(--gray-900); line-height: 1; letter-spacing: -0.03em; }
.stat-label { font-size: 0.77rem; color: var(--gray-500); margin-top: 5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-trend { font-size: 0.75rem; margin-top: 8px; }
.stat-icon-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-icon {
  width: 38px; height: 38px; border-radius: var(--radius);
  background: var(--accent-subtle);
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--transition);
}
.stat-card:hover .stat-icon { transform: scale(1.08); }
.stat-icon svg { width: 18px; height: 18px; color: var(--accent); }
.stat-icon.green  { background: rgba(21,128,61,0.08); }
.stat-icon.green svg { color: var(--success); }
.stat-icon.orange { background: rgba(180,83,9,0.08); }
.stat-icon.orange svg { color: var(--warning); }
.stat-icon.purple { background: rgba(124,58,237,0.08); }
.stat-icon.purple svg { color: #7c3aed; }
.stat-icon.blue   { background: rgba(37,99,235,0.08); }
.stat-icon.blue svg   { color: var(--accent); }

/* ── APP LAYOUT ─────────────────────────────────────────────── */
.app-body { display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 100;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.topbar-left  { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 4px; }

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 0.98rem; color: var(--primary);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}
.brand-logo svg { width: 16px; height: 16px; color: white; }

.sidebar-toggle {
  background: none; border: none; cursor: pointer; padding: 7px;
  border-radius: var(--radius); color: var(--gray-500); display: flex;
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--gray-100); color: var(--gray-800); }
.sidebar-toggle svg { width: 18px; height: 18px; }

/* Sidebar */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--white);
  overflow-y: auto; overflow-x: hidden; z-index: 90;
  transition: transform var(--transition-md), width var(--transition-md);
  border-right: 1px solid var(--gray-200);
}
.sidebar-section { padding: 14px 0 6px; }
.sidebar-label {
  padding: 0 14px 7px; font-size: 0.67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--gray-400);
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; color: var(--gray-600);
  font-size: 0.845rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-left: 2px solid transparent; text-decoration: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1px 8px 1px 0;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; transition: color var(--transition); }
.nav-item:hover { background: var(--gray-100); color: var(--gray-900); text-decoration: none; }
.nav-item.active {
  background: var(--accent-light); color: var(--accent);
  border-left-color: var(--accent); font-weight: 600;
}
.nav-item.active svg { color: var(--accent); }

/* Main content */
.main-content {
  margin-top: var(--topbar-h); margin-left: var(--sidebar-w);
  padding: 28px; min-height: calc(100vh - var(--topbar-h));
  transition: margin-left var(--transition-md);
  min-width: 0; overflow-x: hidden;
}
.page-header   { margin-bottom: 24px; }
.page-title    { font-size: 1.4rem; font-weight: 800; color: var(--gray-900); line-height: 1.2; letter-spacing: -0.02em; }
.page-subtitle { font-size: 0.85rem; color: var(--gray-500); margin-top: 4px; }

/* Topbar icon buttons */
.icon-btn {
  background: none; border: none; cursor: pointer; padding: 7px;
  border-radius: var(--radius); color: var(--gray-500);
  position: relative; transition: background var(--transition), color var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--gray-100); color: var(--gray-800); }
.icon-btn svg { width: 18px; height: 18px; }
.notif-badge {
  position: absolute; top: 3px; right: 3px; background: var(--error);
  color: var(--white); font-size: 0.6rem; font-weight: 700;
  min-width: 14px; height: 14px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 2px;
  animation: pulse-dot 1.8s ease infinite;
}

/* Notification + user dropdown */
.notif-wrap, .user-menu-wrap { position: relative; }
.notif-dropdown, .user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); min-width: 290px; z-index: 200;
  display: none; border: 1px solid var(--gray-200);
  animation: scaleIn 0.18s ease;
  transform-origin: top right;
}
.notif-dropdown.open, .user-dropdown.open { display: block; }
.notif-header {
  padding: 12px 16px; font-weight: 700; font-size: 0.78rem;
  color: var(--gray-500); border-bottom: 1px solid var(--gray-200);
  text-transform: uppercase; letter-spacing: 0.05em;
  display: flex; align-items: center; justify-content: space-between;
}
.notif-empty  { padding: 28px 16px; color: var(--gray-400); font-size: 0.875rem; text-align: center; }
.notif-item   {
  padding: 11px 16px; border-bottom: 1px solid var(--gray-100);
  font-size: 0.83rem; cursor: pointer; color: var(--gray-700);
  transition: background var(--transition);
}
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: var(--accent-light); }

/* User menu */
.user-menu-btn {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 1px solid transparent; cursor: pointer; padding: 5px 10px;
  border-radius: var(--radius); transition: background var(--transition), border-color var(--transition);
}
.user-menu-btn:hover { background: var(--gray-100); border-color: var(--gray-200); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem; flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(37,99,235,0.2);
}
.user-name   { font-size: 0.85rem; font-weight: 600; color: var(--gray-700); }
.chevron     { color: var(--gray-400); display: flex; transition: transform var(--transition); }
.user-menu-wrap.open .chevron { transform: rotate(180deg); }
.chevron svg { width: 12px; height: 12px; }
.user-dropdown a {
  display: block; padding: 9px 16px; color: var(--gray-700); font-size: 0.85rem;
  border-bottom: 1px solid var(--gray-100); transition: background var(--transition);
}
.user-dropdown a:hover { background: var(--gray-50); text-decoration: none; }
.user-dropdown a:last-child { border-bottom: none; color: var(--error); }

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none;
  transition: opacity 0.22s;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white); border-radius: var(--radius-xl);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-xl);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.22s ease;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white); z-index: 1;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.modal-title  { font-weight: 700; font-size: 1.05rem; color: var(--gray-900); }
.modal-close  {
  background: none; border: none; cursor: pointer; color: var(--gray-400);
  padding: 5px; border-radius: var(--radius); display: flex;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }

/* ── PROGRESS BAR ───────────────────────────────────────────── */
.progress-wrap { background: var(--gray-200); border-radius: 999px; overflow: hidden; height: 6px; }
.progress-bar  { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.6s cubic-bezier(.4,0,.2,1); }

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 52px 24px; }
.empty-icon  {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--gray-100), var(--gray-150));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; border: 1px solid var(--gray-200);
}
.empty-icon svg { width: 24px; height: 24px; color: var(--gray-400); }
.empty-state p { font-size: 0.9rem; color: var(--gray-400); }

/* ── PAGINATION ─────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 13px; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 500;
  border: 1px solid var(--gray-200); color: var(--gray-700);
  transition: var(--transition);
}
.pagination a:hover { background: var(--accent); color: var(--white); border-color: var(--accent); text-decoration: none; }
.pagination .current { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* ── DIVIDER ─────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── Lesson text blocks ──────────────────────────────────────── */
.lesson-text-block {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 20px;
}

/* ── BOTTOM NAV (mobile students only) ─────────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--gray-200);
  z-index: 200;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  /* iOS Safari: force fixed positioning to work correctly */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.bottom-nav-inner {
  display: flex; align-items: stretch;
  width: 100%; height: var(--bottom-nav-h);
}
.bottom-nav-item {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--gray-400); font-size: 0.6rem; font-weight: 600;
  text-decoration: none; transition: color var(--transition);
  letter-spacing: 0.01em; text-transform: uppercase;
  padding: 0 2px; overflow: hidden;
  position: relative;
}
.bottom-nav-item span {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.bottom-nav-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item.active::before {
  content: '';
  position: absolute; top: 0; left: 15%; right: 15%;
  height: 2.5px; background: var(--accent);
  border-radius: 0 0 4px 4px;
}
.bottom-nav-item:hover { text-decoration: none; color: var(--accent); }

/* ── SIDEBAR OVERLAY ─────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 89;
  opacity: 0;
  transition: opacity var(--transition-md);
}
.sidebar-overlay.open {
  opacity: 1;
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 90;
    width: min(var(--sidebar-w), 80vw);
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .sidebar-overlay { display: block; }
  .main-content {
    margin-left: 0 !important; padding: 16px;
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
  }
  /* Bottom nav — always visible on mobile for non-admin */
  .bottom-nav { display: flex !important; }
  .sidebar-toggle { display: flex; }

  /* Forms */
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Tables: wrap in a scrollable container so card overflow isn't needed */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll table { min-width: 480px; }

  /* Page header stacks */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header > div:last-child { width: 100%; }
  .page-header .btn { width: 100%; justify-content: center; }


  /* Quiz result box */
  .quiz-result-wrap { padding: 0 !important; margin: 0 auto !important; max-width: 100% !important; }

}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .topbar { padding: 0 12px; }
  .user-name { display: none; }
  .stat-val { font-size: 1.6rem; }
  .page-header > div { flex-direction: column; width: 100%; }
  .page-header .btn-sm { width: 100%; justify-content: center; text-align: center; }
  .dash-hero { padding: 20px 16px; }
  .dash-hero-stats { flex-wrap: wrap; gap: 12px; }
  .course-grid { grid-template-columns: 1fr; }
  /* Quiz list: button below content */
  .quiz-card-row { flex-direction: column; }
  .quiz-card-row > div:last-child { width: 100%; }
  .quiz-card-row .btn { width: 100%; text-align: center; justify-content: center; }
  /* Notifications card full width */
  .notif-card { max-width: 100% !important; }
  .notif-page-item { padding: 12px 16px; gap: 10px; }
}
@media (min-width: 769px) {
  .sidebar-toggle { display: flex; }
  .sidebar.collapsed { width: 54px; overflow: visible; }
  .sidebar.collapsed .sidebar-label { display: none; }
  .sidebar.collapsed .nav-item span { display: none; }
  .sidebar.collapsed .nav-item {
    justify-content: center; padding: 10px; margin: 1px 4px;
    border-left-width: 0; border-radius: var(--radius);
    position: relative;
  }
  .sidebar.collapsed .nav-item.active { background: var(--accent-light); }
  /* Tooltip on hover in collapsed mode */
  .sidebar.collapsed .nav-item::after {
    content: attr(data-label);
    position: absolute; left: calc(100% + 10px); top: 50%;
    transform: translateY(-50%);
    background: var(--gray-900); color: #fff;
    font-size: 0.75rem; font-weight: 500;
    padding: 4px 10px; border-radius: var(--radius-sm);
    white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity 0.15s ease;
    z-index: 200;
  }
  .sidebar.collapsed .nav-item:hover::after { opacity: 1; }
  .main-content.sidebar-collapsed { margin-left: 54px; }
}

/* ── DARK THEME ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --primary:        #3b82f6;
  --primary-dark:   #2563eb;
  --primary-mid:    #60a5fa;
  --accent:         #3b82f6;
  --accent-dark:    #2563eb;
  --accent-light:   rgba(59,130,246,0.12);
  --accent-subtle:  rgba(59,130,246,0.08);
  --success:        #22c55e;
  --success-bg:     #052e16;
  --error:          #f87171;
  --error-bg:       #2d0a0a;
  --warning:        #fbbf24;
  --warning-bg:     #2d1a00;
  --gray-50:        #1e2430;
  --gray-100:       #161b27;
  --gray-150:       #1a2133;
  --gray-200:       #232d3f;
  --gray-300:       #2e3d54;
  --gray-400:       #64748b;
  --gray-500:       #94a3b8;
  --gray-600:       #b0bec5;
  --gray-700:       #cfd8e3;
  --gray-800:       #e2e8f0;
  --gray-900:       #f1f5f9;
  --white:          #1a2133;
  --shadow-xs:      0 1px 2px rgba(0,0,0,0.4);
  --shadow:         0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:      0 4px 8px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg:      0 8px 24px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4);
  --shadow-xl:      0 20px 48px rgba(0,0,0,0.7), 0 4px 12px rgba(0,0,0,0.5);
}
[data-theme="dark"] body { background: #0f1520; color: var(--gray-800); }
[data-theme="dark"] .topbar { background: rgba(22,27,39,0.95); border-bottom-color: #232d3f; }
[data-theme="dark"] .sidebar { background: #161b27; border-right-color: #232d3f; }
[data-theme="dark"] .card { background: #1a2133; border-color: #232d3f; }
[data-theme="dark"] .card-header { border-bottom-color: #232d3f; background: transparent; }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select {
  background: #0f1520; border-color: #2e3d54; color: var(--gray-800);
}
[data-theme="dark"] input:focus, [data-theme="dark"] textarea:focus, [data-theme="dark"] select:focus {
  border-color: var(--accent); background: #131a28;
}
[data-theme="dark"] .btn-secondary { background: #1e2840; color: var(--gray-700); border-color: #2e3d54; }
[data-theme="dark"] .btn-secondary:hover { background: #232d3f; }
[data-theme="dark"] .btn-ghost:hover { background: #232d3f; }
[data-theme="dark"] .nav-item { color: var(--gray-500); }
[data-theme="dark"] .nav-item:hover { background: #232d3f; color: var(--gray-700); }
[data-theme="dark"] .nav-item.active { background: rgba(59,130,246,0.15); color: var(--accent); border-left-color: var(--accent); }
[data-theme="dark"] .sidebar-label { color: var(--gray-400); }
[data-theme="dark"] table thead th { background: #1e2840; border-bottom-color: #232d3f; color: var(--gray-500); }
[data-theme="dark"] table tbody tr:hover { background: #1e2840; }
[data-theme="dark"] table tbody td { border-bottom-color: #232d3f; }
[data-theme="dark"] .table-wrap { border-color: #232d3f; }
[data-theme="dark"] .modal { background: #1a2133; border-color: #232d3f; }
[data-theme="dark"] .modal-header { background: #1a2133; border-bottom-color: #232d3f; }
[data-theme="dark"] .modal-footer { background: #1a2133; border-top-color: #232d3f; }
[data-theme="dark"] .notif-dropdown, [data-theme="dark"] .user-dropdown { background: #1a2133; border-color: #232d3f; }
[data-theme="dark"] .notif-item { border-bottom-color: #232d3f; }
[data-theme="dark"] .notif-item:hover, [data-theme="dark"] .user-dropdown a:hover { background: #232d3f; }
[data-theme="dark"] .alert-success { background: var(--success-bg); color: var(--success); border-color: #166534; }
[data-theme="dark"] .alert-error   { background: var(--error-bg);   color: var(--error);   border-color: #7f1d1d; }
[data-theme="dark"] .alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #92400e; }
[data-theme="dark"] .stat-card { background: #1a2133; border-color: #232d3f; }
[data-theme="dark"] .badge-gray { background: #232d3f; color: var(--gray-600); }
[data-theme="dark"] .tab-badge { background: #232d3f; }
[data-theme="dark"] .section-block { border-color: #232d3f !important; }
[data-theme="dark"] .section-header { background: #1a2133 !important; border-color: #232d3f; }
[data-theme="dark"] .lesson-row { background: #1a2133 !important; border-color: #232d3f !important; }
[data-theme="dark"] .lesson-tab-btn { color: var(--gray-500); }
[data-theme="dark"] .lesson-tab-btn.active { color: var(--gray-800); }
[data-theme="dark"] #lessonTabPrereqs, [data-theme="dark"] #lessonTabAttachments { background: transparent; }
[data-theme="dark"] .text-block-wrap { background: #1e2840; border-color: #2e3d54; }
[data-theme="dark"] .ai-gen-modal { background: #1a2133; border-color: #232d3f; }
[data-theme="dark"] .learn-sidebar { background: #161b27; border-right-color: #232d3f; }
[data-theme="dark"] .learn-sidebar-header { border-bottom-color: #232d3f; }
[data-theme="dark"] .section-nav-header { background: #161b27; }
[data-theme="dark"] .section-nav-header:hover { background: #1a2133; }
[data-theme="dark"] .complete-bar { background: #1e2840; border-top-color: #232d3f; }
[data-theme="dark"] .ql-toolbar { background: #1e2840; border-color: #2e3d54 !important; }
[data-theme="dark"] .ql-container { background: #0f1520; border-color: #2e3d54 !important; color: var(--gray-800); }
[data-theme="dark"] .ql-editor { color: var(--gray-800); }
[data-theme="dark"] .bottom-nav { background: rgba(22,27,39,0.97); border-top-color: #232d3f; }
[data-theme="dark"] .sidebar-overlay { background: rgba(0,0,0,0.65); }
[data-theme="dark"] .skeleton { background: linear-gradient(90deg, #232d3f 25%, #1a2133 50%, #232d3f 75%); background-size: 200% 100%; }
