/* ═══════════════════════════════════════════════════════════════
   EduDrive — Professional Learning Platform
   Modern Dark Theme with Blue-Indigo Accent
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Brand Colors */
  --primary:        #4f8ef7;
  --primary-dark:   #2563eb;
  --primary-light:  #93c5fd;
  --primary-glow:   rgba(79,142,247,0.25);

  --accent-purple:  #818cf8;
  --accent-cyan:    #22d3ee;
  --accent-emerald: #34d399;

  /* Semantic Colors */
  --success:   #10b981;
  --warning:   #f59e0b;
  --danger:    #f87171;
  --info:      #38bdf8;

  /* Background Scale */
  --bg-deepest: #04070f;
  --bg-base:    #070d1a;
  --bg-surface: #0b1323;
  --bg-card:    #0f1a2e;
  --bg-elevated:#162035;
  --bg-hover:   #1a2840;
  --bg-input:   #0d1629;
  --bg-overlay: rgba(4,7,15,0.9);

  /* Borders */
  --border:        rgba(79,142,247,0.14);
  --border-subtle: rgba(255,255,255,0.055);
  --border-active: rgba(79,142,247,0.45);
  --border-hover:  rgba(79,142,247,0.22);

  /* Text */
  --text-primary:   #e8f0ff;
  --text-secondary: #8fa8cc;
  --text-muted:     #445877;
  --text-accent:    #93c5fd;
  --text-white:     #ffffff;

  /* Layout */
  --sidebar-w:  290px;
  --topbar-h:   62px;
  --playlist-w: 310px;

  /* Radius */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 24px;

  /* Shadows */
  --shadow-xs: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.65);
  --shadow-glow-sm: 0 0 20px rgba(79,142,247,0.15);
  --shadow-glow: 0 0 40px rgba(79,142,247,0.2);

  /* Animation */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 0.15s;
  --t-base: 0.2s;
  --t-slow: 0.3s;
}

/* ═══════════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES  [data-theme="light"]
   ═══════════════════════════════════════════════════════════════ */
[data-theme="light"] {
  /* Brand stays the same but slightly deeper */
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #60a5fa;
  --primary-glow:   rgba(37,99,235,0.18);

  --accent-purple:  #6366f1;
  --accent-cyan:    #0891b2;
  --accent-emerald: #059669;

  /* Semantic */
  --success:   #059669;
  --warning:   #d97706;
  --danger:    #dc2626;
  --info:      #0284c7;

  /* Background Scale — whites/grays */
  --bg-deepest: #f0f4ff;
  --bg-base:    #f8faff;
  --bg-surface: #ffffff;
  --bg-card:    #ffffff;
  --bg-elevated:#f1f5fe;
  --bg-hover:   #e8effc;
  --bg-input:   #f1f5ff;
  --bg-overlay: rgba(248,250,255,0.95);

  /* Borders */
  --border:        rgba(37,99,235,0.14);
  --border-subtle: rgba(0,0,0,0.08);
  --border-active: rgba(37,99,235,0.45);
  --border-hover:  rgba(37,99,235,0.25);

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-muted:     #94a3b8;
  --text-accent:    #2563eb;
  --text-white:     #ffffff;

  /* Shadows */
  --shadow-xs: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.14);
  --shadow-glow-sm: 0 0 20px rgba(37,99,235,0.12);
  --shadow-glow:    0 0 40px rgba(37,99,235,0.15);
}

/* ─── Light-mode specific overrides ─── */
[data-theme="light"] body {
  background: var(--bg-base);
  color: var(--text-primary);
}

/* Sidebar */
[data-theme="light"] .sidebar {
  background: #ffffff;
  border-right-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .sidebar-logo {
  border-bottom-color: rgba(0,0,0,0.07);
}
[data-theme="light"] .brand { color: var(--primary-dark); }
[data-theme="light"] .sidebar-logo-icon {
  background: linear-gradient(135deg, #2563eb, #6366f1);
}
[data-theme="light"] .course-item:hover { background: #f0f4ff; }
[data-theme="light"] .course-item.active { background: rgba(37,99,235,.08); }
[data-theme="light"] .chapter-item:hover { background: #eef2ff; }
[data-theme="light"] .chapter-item.active { background: rgba(37,99,235,.1); }
[data-theme="light"] .sidebar-footer { border-top-color: rgba(0,0,0,.07); }
[data-theme="light"] .user-avatar {
  background: linear-gradient(135deg,#2563eb,#6366f1);
}
[data-theme="light"] .nav-section-label { color: #94a3b8; }

/* Topbar */
[data-theme="light"] .topbar {
  background: rgba(255,255,255,0.92);
  border-bottom-color: rgba(0,0,0,0.07);
}
[data-theme="light"] .icon-btn { color: #334155; }
[data-theme="light"] .icon-btn:hover { background: #f0f4ff; color: var(--primary); }

/* Cards & panels */
[data-theme="light"] .card { background: #fff; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .stat-card { background: #fff; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .stat-card:hover { box-shadow: 0 4px 20px rgba(37,99,235,0.1); }
[data-theme="light"] .welcome-hero {
  background: linear-gradient(135deg, rgba(37,99,235,0.06), rgba(99,102,241,0.04));
  border-color: rgba(37,99,235,0.12);
}
[data-theme="light"] .welcome-hero-stats {
  background: #f8faff;
  border-color: rgba(0,0,0,0.08);
}

/* Toolbar */
[data-theme="light"] .courses-toolbar {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] #home-courses-table {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .toolbar-search {
  background: #f1f5ff;
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .view-switcher {
  background: #f1f5ff;
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .count-badge {
  background: #f0f4ff;
  border-color: rgba(0,0,0,0.08);
  color: #64748b;
}

/* Grid cards */
[data-theme="light"] .grid-card {
  background: #fff;
  border-color: rgba(0,0,0,0.09);
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}
[data-theme="light"] .grid-card:hover {
  border-color: rgba(37,99,235,0.3);
  box-shadow: 0 6px 20px rgba(37,99,235,0.12);
}
[data-theme="light"] .grid-stat-chip {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.07);
}

/* List cards */
[data-theme="light"] .list-card { background: #fff; border-bottom-color: rgba(0,0,0,0.07); }
[data-theme="light"] .list-card:hover { background: #f8faff; }

/* Category cards */
[data-theme="light"] .cat-card {
  background: #f8faff;
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .cat-card:hover { background: #eef2ff; border-color: rgba(37,99,235,.2); }

/* Course overview */
[data-theme="light"] .co-desc {
  background: #f8faff;
  border-color: rgba(0,0,0,0.08);
  color: #334155;
}
[data-theme="light"] .co-chapters-area {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .co-chapters-header,
[data-theme="light"] .co-video-header {
  background: #f1f5ff;
  border-color: rgba(0,0,0,0.07);
}
[data-theme="light"] .co-chapter-item { border-bottom-color: rgba(0,0,0,0.07); }
[data-theme="light"] .co-chapter-item:hover { background: #f0f4ff; }
[data-theme="light"] .co-chapter-item.active { background: rgba(37,99,235,.07); border-left-color: var(--primary); }
[data-theme="light"] .co-chapter-num { background: #f0f4ff; border-color: rgba(0,0,0,.09); }
[data-theme="light"] .co-video-item { border-bottom-color: rgba(0,0,0,0.07); }
[data-theme="light"] .co-video-item:hover { background: #f8faff; }
[data-theme="light"] .co-video-num { background: #f0f4ff; border-color: rgba(0,0,0,.09); }
[data-theme="light"] .co-video-area { background: #fff; }
[data-theme="light"] .co-video-header { background: rgba(37,99,235,.04); border-color: rgba(0,0,0,0.07); }

/* Login page */
[data-theme="light"] .login-page { background: linear-gradient(135deg,#e0e8ff 0%,#f0f4ff 50%,#e8f0fe 100%); }
[data-theme="light"] .login-card {
  background: rgba(255,255,255,0.95);
  border-color: rgba(37,99,235,0.15);
  box-shadow: 0 20px 60px rgba(37,99,235,0.12);
}
[data-theme="light"] .login-logo p { color: #64748b; }
[data-theme="light"] .form-label { color: #334155; }
[data-theme="light"] .form-input {
  background: #f1f5ff;
  border-color: rgba(0,0,0,0.12);
  color: #0f172a;
}
[data-theme="light"] .form-input:focus { border-color: var(--primary); }
[data-theme="light"] .form-input::placeholder { color: #94a3b8; }

/* Admin */
[data-theme="light"] .admin-sidebar { background: #fff; border-right-color: rgba(0,0,0,.08); }
[data-theme="light"] .admin-topbar { background: rgba(255,255,255,.92); border-bottom-color: rgba(0,0,0,.07); }
[data-theme="light"] .admin-content { background: #f8faff; }
[data-theme="light"] .course-admin-card { background: #fff; border-color: rgba(0,0,0,.08); }
[data-theme="light"] .chapter-row { border-bottom-color: rgba(0,0,0,.06); }
[data-theme="light"] .chapter-row:hover { background: #f8faff; }
[data-theme="light"] .video-row { border-bottom-color: rgba(0,0,0,.06); }
[data-theme="light"] .video-row:hover { background: #f8faff; }

/* Modal */
[data-theme="light"] .modal-backdrop { background: rgba(0,0,0,.35); }
[data-theme="light"] .modal-box {
  background: #fff;
  border-color: rgba(0,0,0,.1);
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
[data-theme="light"] .modal-header { border-bottom-color: rgba(0,0,0,.08); background: #f8faff; }
[data-theme="light"] .modal-footer { border-top-color: rgba(0,0,0,.08); background: #f8faff; }
[data-theme="light"] .form-input-dark {
  background: #f1f5ff;
  border-color: rgba(0,0,0,.12);
  color: #0f172a;
}
[data-theme="light"] .form-input-dark:focus { border-color: var(--primary); }
[data-theme="light"] .form-input-dark::placeholder { color: #94a3b8; }

/* Watch page */
[data-theme="light"] .watch-layout { background: #f0f4ff; }
[data-theme="light"] .watch-topbar { background: rgba(255,255,255,.95); border-bottom-color: rgba(0,0,0,.08); }
[data-theme="light"] .playlist-panel { background: #fff; border-left-color: rgba(0,0,0,.08); }
[data-theme="light"] .playlist-item { border-bottom-color: rgba(0,0,0,.06); }
[data-theme="light"] .playlist-item:hover { background: #f0f4ff; }
[data-theme="light"] .playlist-item.active { background: rgba(37,99,235,.08); }

/* Search box */
[data-theme="light"] .search-box {
  background: #f1f5ff;
  border-color: rgba(0,0,0,.1);
}
[data-theme="light"] .search-box input { color: #0f172a; }
[data-theme="light"] .search-box input::placeholder { color: #94a3b8; }

/* Alerts */
[data-theme="light"] .alert-error { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
[data-theme="light"] .alert-success { background: #f0fdf4; border-color: #86efac; color: #166534; }

/* Carousel */
[data-theme="light"] .carousel-section { border-color: rgba(0,0,0,.09); }
[data-theme="light"] .carousel-arrow { background: rgba(255,255,255,.8); color: #0f172a; border-color: rgba(0,0,0,.12); }
[data-theme="light"] .carousel-arrow:hover { background: var(--primary); color: #fff; }

/* Misc */
[data-theme="light"] .badge { background: rgba(37,99,235,.1); color: var(--primary); border-color: rgba(37,99,235,.2); }
[data-theme="light"] .btn-secondary { background: #f0f4ff; color: var(--primary); border-color: rgba(37,99,235,.2); }
[data-theme="light"] .btn-secondary:hover { background: #e0e8ff; }
[data-theme="light"] .nav-section-label { color: #94a3b8; }
[data-theme="light"] .sep { color: #cbd5e1; }
[data-theme="light"] .current { color: #0f172a; }
[data-theme="light"] .orb { opacity: .3; }
[data-theme="light"] .empty-state { color: #64748b; }

/* Theme toggle button */
.theme-toggle {
  position: relative;
  width: 44px; height: 24px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
  flex-shrink: 0;
  display: flex; align-items: center;
  padding: 2px;
}
.theme-toggle-knob {
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  transition: transform var(--t-base) var(--ease-spring);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
[data-theme="light"] .theme-toggle {
  background: #dbeafe;
  border-color: rgba(37,99,235,.2);
}
[data-theme="light"] .theme-toggle-knob {
  transform: translateX(20px);
  background: linear-gradient(135deg, #2563eb, #6366f1);
}
.theme-toggle-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  white-space: nowrap; user-select: none;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  /* Smooth transition when theme changes */
  transition: background var(--t-base) var(--ease);
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(79,142,247,0.25);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(79,142,247,0.45);
}

/* ─── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
}
p { color: var(--text-secondary); }
a { color: var(--primary); text-decoration: none; }

/* ─── Global Utilities ───────────────────────────────────── */
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full { width: 100%; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-gradient {
  background: linear-gradient(135deg, var(--primary-light), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-base);
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 30;
  transition: transform var(--t-slow) var(--ease);
  /* Subtle gradient to add depth */
  background: linear-gradient(180deg, #0b1323 0%, #0d1629 100%);
}

/* ── Sidebar Logo ── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.sidebar-logo::after {
  content: '';
  position: absolute;
  bottom: 0; left: 18px; right: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(79,142,247,0.2), transparent);
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary-dark), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(79,142,247,0.35);
  flex-shrink: 0;
  position: relative;
}
.sidebar-logo-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255,255,255,0.15);
}
.sidebar-logo-icon i {
  font-size: 17px;
  color: #fff;
}

.sidebar-logo-text .brand {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-white);
  letter-spacing: -0.04em;
  line-height: 1;
}
.sidebar-logo-text .tagline {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Sidebar Search ── */
.sidebar-search {
  padding: 12px 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  transition: all var(--t-base) var(--ease);
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(13,22,41,0.9);
}
.search-box i {
  color: var(--text-muted);
  font-size: 12px;
  flex-shrink: 0;
}
.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
  font-family: inherit;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ── Sidebar Nav ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 10px 8px 6px;
}

/* Course Item */
.course-item {
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  margin-bottom: 1px;
  overflow: hidden;
}
.course-item:hover {
  background: var(--bg-hover);
}
.course-item.active {
  background: rgba(79,142,247,0.1);
}

.course-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
}

.course-num {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.course-info { flex: 1; min-width: 0; }
.course-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.course-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.course-chevron {
  color: var(--text-muted);
  font-size: 10px;
  transition: transform var(--t-base) var(--ease);
  flex-shrink: 0;
}
.course-item.active .course-chevron {
  transform: rotate(90deg);
  color: var(--primary);
}

/* Chapter Item */
.chapters-container {
  padding: 2px 0 6px 10px;
  border-left: 1.5px solid rgba(79,142,247,0.12);
  margin-left: 20px;
  margin-right: 4px;
  margin-bottom: 4px;
}

.chapter-item {
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  margin-bottom: 1px;
}
.chapter-item:hover { background: rgba(255,255,255,0.04); }
.chapter-item.active {
  background: rgba(79,142,247,0.09);
}

.chapter-item-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}
.chapter-item-inner i {
  color: var(--warning);
  font-size: 11px;
  flex-shrink: 0;
}
.chapter-info { flex: 1; min-width: 0; }
.chapter-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chapter-item.active .chapter-title {
  color: var(--text-accent);
}
.chapter-count {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0,0,0,0.15);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--t-base) var(--ease);
}
.user-card:hover {
  border-color: var(--border-hover);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary-dark), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79,142,247,0.3);
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.user-actions { display: flex; gap: 3px; }

/* ─── Icon Button ──────────────────────────────── */
.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: all var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.icon-btn.danger:hover {
  background: rgba(248,113,113,0.1);
  color: var(--danger);
}

/* ═══════════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════════ */

.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  flex-shrink: 0;
  position: relative;
}
.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(79,142,247,0.15), transparent);
}

.topbar-hamburger { display: none; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.breadcrumb .sep { color: var(--text-muted); opacity: 0.5; }
.breadcrumb .current {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════════════════════ */

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--bg-base);
}
@media (max-width: 768px) {
  .main-content { padding: 14px 12px; }
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  display: none;
}
.sidebar-overlay.show { display: block; }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--t-fast);
}
.btn:hover::after { background: rgba(255,255,255,0.05); }
.btn:active::after { background: rgba(0,0,0,0.1); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #4f8ef7 60%, #6366f1 100%);
  color: #fff;
  box-shadow: 0 2px 14px rgba(79,142,247,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 22px rgba(79,142,247,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(79,142,247,0.3);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-hover); }

.btn-ghost { background: none; color: var(--text-secondary); border: none; }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger {
  background: rgba(248,113,113,0.08);
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.2);
}
.btn-danger:hover { background: rgba(248,113,113,0.15); border-color: rgba(248,113,113,0.3); }

.btn-success {
  background: rgba(16,185,129,0.1);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.2);
}
.btn-success:hover { background: rgba(16,185,129,0.18); }

.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-xs  { padding: 3px 9px; font-size: 11px; border-radius: var(--r-xs); }
.btn-lg  { padding: 11px 24px; font-size: 15px; }
.btn-icon { padding: 8px; aspect-ratio: 1; }

/* ═══════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  transition: border-color var(--t-base) var(--ease);
}
.card:hover { border-color: var(--border); }

.card-glass {
  background: rgba(255,255,255,0.025);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-lg);
}

/* Stat Card */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  transition: all var(--t-base) var(--ease);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0;
  transition: opacity var(--t-base);
}
.stat-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card:hover::before { opacity: 1; }
.stat-card-icon {
  font-size: 26px;
  margin-bottom: 4px;
}
.stat-card-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-card-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════
   WELCOME / HOME
   ═══════════════════════════════════════════════════════════════ */

.welcome-hero {
  background: linear-gradient(135deg,
    rgba(37,99,235,0.08) 0%,
    rgba(79,142,247,0.05) 40%,
    rgba(99,102,241,0.04) 100%);
  border: 1px solid rgba(79,142,247,0.12);
  border-radius: var(--r-2xl);
  padding: 30px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.welcome-hero::before {
  content: '';
  position: absolute;
  top: -60%; right: -10%;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(79,142,247,0.07) 0%, transparent 70%);
  pointer-events: none;
}
.welcome-hero::after {
  content: '';
  position: absolute;
  bottom: -40%; left: -5%;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(99,102,241,0.05) 0%, transparent 70%);
  pointer-events: none;
}

/* Course Overview Hero */
.course-hero {
  background: linear-gradient(135deg,
    rgba(37,99,235,0.09) 0%,
    rgba(79,142,247,0.06) 50%,
    rgba(99,102,241,0.04) 100%);
  border: 1px solid rgba(79,142,247,0.14);
  border-radius: var(--r-2xl);
  padding: 28px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}
.course-hero::before {
  content: '';
  position: absolute;
  top: -50%; right: -15%;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(79,142,247,0.07), transparent 70%);
  pointer-events: none;
}
.course-hero-emoji {
  font-size: 44px;
  margin-bottom: 14px;
  display: block;
}
.course-hero h2 {
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.course-hero p {
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 560px;
  line-height: 1.7;
}
.course-hero-stats {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(79,142,247,0.09);
  border: 1px solid rgba(79,142,247,0.18);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-accent);
  font-weight: 500;
}
.stat-badge i { font-size: 11px; }

/* ═══════════════════════════════════════════════════════════════
   VIDEO LIST
   ═══════════════════════════════════════════════════════════════ */

.video-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
  position: relative;
  overflow: hidden;
  user-select: none;
}
.video-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--primary), #6366f1);
  opacity: 0;
  transition: opacity var(--t-fast);
  border-radius: 0 2px 2px 0;
}
.video-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}
.video-card:hover::before { opacity: 1; }
.video-card.active {
  background: rgba(79,142,247,0.07);
  border-color: rgba(79,142,247,0.25);
}
.video-card.active::before { opacity: 1; }
.video-card.watched {
  opacity: 0.75;
}
.video-card.watched:hover { opacity: 1; }

.video-thumb-num {
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, rgba(79,142,247,0.12), rgba(99,102,241,0.08));
  border: 1px solid rgba(79,142,247,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-accent);
  flex-shrink: 0;
  transition: all var(--t-base);
}
.video-thumb-watched {
  background: rgba(16,185,129,0.09);
  border-color: rgba(16,185,129,0.2);
}
.video-thumb-watched i {
  color: var(--success);
  font-size: 16px;
}

.video-info { flex: 1; min-width: 0; }
.video-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.video-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.video-duration {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.video-status { font-size: 11px; font-weight: 500; }
.video-status.watched { color: var(--success); }
.video-status.unwatched { color: var(--text-muted); }

.play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(79,142,247,0.1);
  border: 1px solid rgba(79,142,247,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 11px;
  transition: all var(--t-base) var(--ease);
  flex-shrink: 0;
}
.video-card:hover .play-btn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(79,142,247,0.4);
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════
   WATCH / VIDEO PLAYER PAGE
   ═══════════════════════════════════════════════════════════════ */

.watch-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #020811;
  overflow: hidden;
}

.watch-topbar {
  height: var(--topbar-h);
  background: #080f1e;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  flex-shrink: 0;
  z-index: 10;
}

.watch-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.watch-player-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000;
}

/* 16:9 Aspect ratio container */
.player-container {
  position: relative;
  background: #000;
  width: 100%;
  padding-top: 56.25%;
  flex-shrink: 0;
  max-height: calc(100vh - var(--topbar-h) - 140px);
  /* Override padding based on actual height */
}

@media (min-height: 700px) {
  .player-container {
    max-height: none;
    padding-top: 56.25%;
  }
}

.player-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.player-info {
  padding: 16px 20px;
  background: var(--bg-surface);
  border-top: 1px solid rgba(255,255,255,0.05);
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.watch-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Progress / Watched indicator */
.progress-section {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(16,185,129,0.07);
  border: 1px solid rgba(16,185,129,0.18);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeIn var(--t-slow) ease;
}
.progress-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(16,185,129,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.progress-icon i { color: var(--success); font-size: 15px; }

/* Playlist Sidebar */
.playlist-sidebar {
  width: var(--playlist-w);
  min-width: var(--playlist-w);
  background: var(--bg-surface);
  border-left: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.playlist-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.2);
}
.playlist-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.playlist-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 10px;
}

.playlist-items {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  margin-bottom: 1px;
}
.playlist-item:hover { background: var(--bg-hover); }
.playlist-item.active {
  background: rgba(79,142,247,0.1);
  border: 1px solid rgba(79,142,247,0.18);
}

.playlist-idx {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.playlist-item.active .playlist-idx {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,142,247,0.35);
}

.playlist-item-info { flex: 1; min-width: 0; }
.playlist-item-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.playlist-item.active .playlist-item-title { color: var(--text-primary); }
.playlist-item-duration { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

/* Animated background */
.login-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.login-bg .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  animation: float 8s ease-in-out infinite;
}
.login-bg .orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #2563eb, transparent 70%);
  opacity: 0.08;
  top: -200px; right: -150px;
  animation-delay: 0s;
}
.login-bg .orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  opacity: 0.07;
  bottom: -200px; left: -150px;
  animation-delay: -3s;
}
.login-bg .orb-3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #22d3ee, transparent 70%);
  opacity: 0.05;
  top: 40%; left: 40%;
  transform: translate(-50%,-50%);
  animation-delay: -6s;
}

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.03); }
}

/* Decorative grid lines */
.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(79,142,247,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,142,247,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid rgba(79,142,247,0.12);
  border-radius: var(--r-2xl);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: cardIn 0.5s var(--ease-spring);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Glowing top border */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(79,142,247,0.5), transparent);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary-dark), #4f46e5);
  box-shadow: 0 8px 32px rgba(79,142,247,0.45), inset 0 1px 0 rgba(255,255,255,0.15);
  margin-bottom: 16px;
  position: relative;
}
.login-logo-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255,255,255,0.14);
}
.login-logo-icon i { font-size: 30px; color: #fff; }

.login-logo h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-white);
  letter-spacing: -0.04em;
}
.login-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Form */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.input-wrap { position: relative; }

.input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
  z-index: 1;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 11px 42px 11px 40px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all var(--t-base) var(--ease);
  font-family: inherit;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), 0 2px 10px rgba(0,0,0,0.3);
  background: rgba(13,22,41,0.9);
}
.form-input::placeholder { color: var(--text-muted); }

.input-action {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px;
  transition: color var(--t-fast);
  border-radius: 4px;
}
.input-action:hover { color: var(--text-secondary); background: var(--bg-hover); }

.login-submit {
  width: 100%;
  padding: 13px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--primary-dark), #4f8ef7 50%, #6366f1);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
  box-shadow: 0 4px 20px rgba(79,142,247,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
  font-family: inherit;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-submit:hover:not(:disabled) {
  box-shadow: 0 6px 28px rgba(79,142,247,0.55), inset 0 1px 0 rgba(255,255,255,0.18);
  transform: translateY(-1px);
}
.login-submit:active:not(:disabled) {
  transform: translateY(0);
}
.login-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.alert {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.alert-error {
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.22);
  color: #fca5a5;
}
.alert i { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   ADMIN PAGE
   ═══════════════════════════════════════════════════════════════ */

.admin-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.admin-sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0b1323 0%, #0d1629 100%);
}

.admin-nav {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  letter-spacing: 0.01em;
}
.admin-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.admin-nav-item.active {
  background: rgba(79,142,247,0.1);
  color: var(--text-accent);
  border: 1px solid rgba(79,142,247,0.15);
}
.admin-nav-item.active i { color: var(--primary); }
.admin-nav-item i {
  width: 16px;
  text-align: center;
  font-size: 13px;
}

.admin-content-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

.admin-topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 16px;
  flex-shrink: 0;
}
.admin-topbar h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

/* Admin Course Cards */
.admin-course-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 10px;
  transition: all var(--t-base) var(--ease);
}
.admin-course-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.admin-course-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.admin-course-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, rgba(79,142,247,0.12), rgba(99,102,241,0.08));
  border: 1px solid rgba(79,142,247,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.admin-course-info { flex: 1; min-width: 0; }
.admin-course-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-course-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.admin-chapter-section {
  border-top: 1px solid var(--border-subtle);
  background: rgba(0,0,0,0.15);
}
.admin-chapter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(79,142,247,0.03);
}
.admin-chapter-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chapter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid rgba(255,255,255,0.03);
  transition: background var(--t-fast);
}
.chapter-row:hover { background: rgba(255,255,255,0.02); }
.chapter-row i.fa-folder { color: var(--warning); font-size: 12px; flex-shrink: 0; }
.chapter-row-info { flex: 1; min-width: 0; }
.chapter-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chapter-row-count { font-size: 11px; color: var(--text-muted); }

.video-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 8px 32px;
  border-top: 1px solid rgba(255,255,255,0.025);
  transition: background var(--t-fast);
}
.video-row:hover { background: rgba(255,255,255,0.02); }
.video-row i.fa-play-circle { color: var(--primary); font-size: 11px; flex-shrink: 0; opacity: 0.7; }
.video-row-info { flex: 1; min-width: 0; }
.video-row-title {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-row-duration { font-size: 10px; color: var(--text-muted); }

/* User list card */
.user-list-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: all var(--t-base) var(--ease);
}
.user-list-card:hover {
  border-color: var(--border-hover);
  transform: translateX(2px);
}

.user-list-avatar {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary-dark), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(79,142,247,0.25);
}
.user-list-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.user-list-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.role-admin {
  background: rgba(79,142,247,0.1);
  color: var(--text-accent);
  border: 1px solid rgba(79,142,247,0.2);
}
.role-viewer {
  background: rgba(148,163,184,0.08);
  color: var(--text-muted);
  border: 1px solid rgba(148,163,184,0.15);
}

/* Import tab */
.import-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 16px;
  transition: border-color var(--t-base);
}
.import-card:hover { border-color: var(--border); }
.import-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.import-card > p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

.code-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: #86efac;
  overflow-x: auto;
  margin-bottom: 16px;
  white-space: pre;
  line-height: 1.6;
  position: relative;
}
.code-block::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, #22d3ee, #86efac, transparent);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */

.form-input-dark {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all var(--t-base) var(--ease);
  font-family: inherit;
}
.form-input-dark:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(13,22,41,0.95);
}
.form-input-dark::placeholder { color: var(--text-muted); }
select.form-input-dark { cursor: pointer; }
textarea.form-input-dark { resize: vertical; min-height: 78px; }

/* ═══════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4,7,15,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid rgba(79,142,247,0.14);
  border-radius: var(--r-2xl);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), var(--shadow-glow-sm);
  animation: modalIn 0.28s var(--ease-spring);
  position: relative;
}
.modal-box::before {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(79,142,247,0.4), transparent);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: all var(--t-fast);
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
}

.modal-form-group { margin-bottom: 15px; }
.modal-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}
.modal-footer .btn {
  flex: 1;
  justify-content: center;
  padding: 11px;
}

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.35s var(--ease-spring);
  min-width: 250px;
  max-width: 360px;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.toast-success {
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.25);
  color: #6ee7b7;
}
.toast-error {
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.25);
  color: #fca5a5;
}
.toast-info {
  background: rgba(79,142,247,0.12);
  border: 1px solid rgba(79,142,247,0.25);
  color: var(--text-accent);
}
.toast i { flex-shrink: 0; font-size: 14px; }

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

.fade-in {
  animation: fadeIn 0.35s var(--ease);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide-in {
  animation: slideInLeft 0.3s var(--ease);
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ═══════════════════════════════════════════════════════════════
   LOADING STATES
   ═══════════════════════════════════════════════════════════════ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(79,142,247,0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 14px;
  color: var(--text-muted);
}
.loading-screen p { font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  text-align: center;
}
.empty-icon {
  font-size: 44px;
  opacity: 0.18;
  display: block;
  margin-bottom: 4px;
}
.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}
.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.7;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
  :root { --playlist-w: 280px; }
}

@media (max-width: 900px) {
  .playlist-sidebar {
    display: none;
  }
  .playlist-sidebar.open {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 55vh;
    z-index: 40;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    width: 100%;
    min-width: unset;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-w: 280px;
    --topbar-h: 56px;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 40px rgba(0,0,0,0.6);
  }
  .topbar-hamburger {
    display: flex !important;
  }

  .main-content { padding: 16px; }

  .watch-body { flex-direction: column; }

  .login-card { padding: 32px 24px; }

  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    min-width: unset;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 2px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .admin-nav {
    display: flex;
    padding: 8px;
    gap: 4px;
  }
  .admin-nav-item {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .modal-box { padding: 22px 18px; border-radius: var(--r-xl); }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 18px; max-width: 100%; }
  .login-logo h1 { font-size: 24px; }
  .toast { min-width: unset; width: calc(100vw - 32px); }
  .toast-container { right: 16px; left: 16px; }
}

/* ═══════════════════════════════════════════════════════════════
   SPECIAL COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

/* Shimmer skeleton loader */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-hover) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Progress bar */
.progress-bar {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #6366f1);
  border-radius: 10px;
  transition: width 0.4s ease;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge-blue {
  background: rgba(79,142,247,0.12);
  color: var(--text-accent);
  border: 1px solid rgba(79,142,247,0.2);
}
.badge-green {
  background: rgba(16,185,129,0.1);
  color: #6ee7b7;
  border: 1px solid rgba(16,185,129,0.2);
}

/* Section divider with text */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* Hover card highlight */
.hover-highlight {
  transition: all var(--t-base) var(--ease);
}
.hover-highlight:hover {
  background: var(--bg-elevated);
  border-radius: var(--r-sm);
}

/* Focus ring for accessibility */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   HOME PAGE — Course Grid & List
   ═══════════════════════════════════════════════════════════════ */

/* ── Home Wrapper ── */
.home-wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 4px 40px;
}

/* ── Hero Section ── */
.home-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.home-hero-left { flex: 1; min-width: 0; }

.home-greeting {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}

.home-title {
  font-size: clamp(20px, 3vw, 26px);
  color: var(--text-primary);
  font-weight: 800;
  margin-bottom: 6px;
}

.home-sub {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.home-stats {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ── Toolbar (Search + View Toggle) ── */
.courses-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.courses-search-wrap {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 16px;
  transition: all var(--t-base) var(--ease);
}

.courses-search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.courses-search-wrap > i {
  color: var(--text-muted);
  font-size: 13px;
  flex-shrink: 0;
}

.courses-search-inp {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}

.courses-search-inp::placeholder { color: var(--text-muted); }

.search-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--t-fast);
  flex-shrink: 0;
}
.search-clear:hover { color: var(--danger); }

/* ── View Toggle ── */
.view-toggle {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  overflow: hidden;
  flex-shrink: 0;
}

.view-btn {
  width: 38px;
  height: 38px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--t-fast) var(--ease);
}

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

.view-btn.active {
  color: var(--primary);
  background: rgba(79,142,247,0.12);
}

/* ── Course Home Grid ── */
.course-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

/* ── Course Card (Grid) ── */
.course-home-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-base);
  display: flex;
  flex-direction: column;
}

.course-home-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(79,142,247,0.2);
  border-color: rgba(79,142,247,0.25);
}

.course-card-banner {
  width: 100%;
  aspect-ratio: 16/9;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.course-card-banner-emoji {
  font-size: 40px;
  opacity: 0.9;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.course-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.12);
}

.course-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.course-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.course-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.course-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.course-card-meta i { color: var(--primary); font-size: 11px; }

.course-card-cta {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: gap var(--t-fast);
}

.course-home-card:hover .course-card-cta { gap: 8px; }

/* ── Course Home List ── */
.course-home-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.course-home-list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
  padding-right: 16px;
}

.course-home-list-item:hover {
  border-color: rgba(79,142,247,0.3);
  background: var(--bg-elevated);
  transform: translateX(2px);
}

.course-list-thumb {
  width: 100px;
  min-width: 100px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.course-list-info {
  flex: 1;
  min-width: 0;
  padding: 14px 0;
}

.course-list-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.course-list-desc {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.course-list-meta {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
}

.course-list-meta i { color: var(--primary); margin-right: 4px; }

.course-list-cta {
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
  transition: all var(--t-fast);
}

.course-home-list-item:hover .course-list-cta {
  color: var(--primary);
  transform: translateX(3px);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile & Tablet
   ═══════════════════════════════════════════════════════════════ */

/* Tablet (≤ 1024px): sidebar collapses */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 270px;
    --playlist-w: 280px;
  }

  .course-home-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
  }
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {
  :root {
    --topbar-h: 56px;
  }

  /* ── Layout ── */
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 85vw) !important;
    min-width: 0 !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }

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

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
    backdrop-filter: blur(2px);
  }

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

  .main-wrap {
    width: 100%;
    height: 100vh;
    overflow: auto;
  }

  #sidebar-close-btn { display: flex !important; }

  /* ── Home Hero ── */
  .home-hero {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
  }

  .home-stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .home-title { font-size: 20px; }

  /* ── Courses ── */
  .course-home-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .course-card-title { font-size: 13px; }
  .course-card-body { padding: 12px; }

  .course-list-thumb {
    width: 80px;
    min-width: 80px;
    height: 60px;
  }

  .course-list-desc { display: none; }

  /* ── Topbar ── */
  .topbar {
    height: var(--topbar-h);
    padding: 0 12px;
  }

  /* ── Watch page ── */
  .watch-body {
    flex-direction: column;
  }

  .playlist-sidebar {
    width: 100%;
    height: 280px;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
  }

  .watch-player-wrap {
    width: 100%;
  }

  /* ── Stats ── */
  .stat-card {
    padding: 12px;
  }

  /* ── Admin ── */
  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100% !important;
    min-width: 0 !important;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    flex-direction: row;
    height: auto;
  }

  .admin-nav {
    flex-direction: row;
    flex: 1;
    overflow-x: auto;
    padding: 0;
    gap: 0;
  }

  .admin-nav-item {
    white-space: nowrap;
    border-radius: 0;
    border-bottom: 2px solid transparent;
  }

  .admin-nav-item.active {
    background: transparent;
    border-bottom-color: var(--primary);
    color: var(--primary);
  }

  .admin-content-wrap {
    overflow: auto;
  }
}

/* Small mobile (≤ 480px) */
@media (max-width: 480px) {
  .home-wrap { padding: 0 0 32px; }

  .courses-toolbar { gap: 8px; }

  .course-home-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .home-stats {
    gap: 8px;
  }

  .stat-card {
    padding: 10px 8px;
  }

  .stat-card-value { font-size: 20px; }

  .modal-box {
    width: 95vw !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  .watch-topbar {
    padding: 0 8px;
  }

  .player-info {
    padding: 10px 12px;
  }
}

/* ── Sidebar toggle animation ── */
.sidebar-overlay {
  transition: opacity var(--t-slow);
}

/* ══════════════════════════════════════════════════════════════
   HOME PAGE – Multi-view Course Listing (v3 — fully redesigned)
   ══════════════════════════════════════════════════════════════ */

/* ── Page wrapper ── */
.home-page-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding-top: 6px;
}

/* ════════════════════════════════════════
   WELCOME HERO (new — stats inline)
   ════════════════════════════════════════ */
.welcome-hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.welcome-hero-text {
  flex: 1;
  min-width: 0;
}
.greeting-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px;
}
.greeting-title {
  font-size: 24px; color: var(--text-primary); margin-bottom: 4px; font-weight: 800;
  line-height: 1.25;
}
.greeting-sub { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-top: 4px; }

/* Inline hero stats (replaces separate stats-row) */
.welcome-hero-stats {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  overflow: hidden;
  flex-shrink: 0;
}
.hero-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
}
.hero-stat-divider {
  width: 1px; height: 36px;
  background: var(--border-subtle);
  flex-shrink: 0;
}
.hero-stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.hero-stat-info { line-height: 1; }
.hero-stat-val {
  font-size: 22px; font-weight: 800; color: var(--text-primary);
}
.hero-stat-lbl {
  font-size: 11px; color: var(--text-muted); margin-top: 3px; font-weight: 500;
}

/* ════════════════════════════════════════
   COURSES TOOLBAR
   ════════════════════════════════════════ */
.courses-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md) var(--r-md) 0 0;
  flex-wrap: wrap;
}
.toolbar-left {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.toolbar-icon {
  color: var(--primary); font-size: 14px; flex-shrink: 0;
}
.toolbar-title {
  font-size: 14px; font-weight: 700; color: var(--text-primary); white-space: nowrap;
}
.count-badge {
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  background: var(--bg-input); padding: 2px 8px;
  border-radius: 20px; border: 1px solid var(--border-subtle); white-space: nowrap;
}
.toolbar-right {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* Search box in toolbar */
.toolbar-search {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  min-width: 160px; max-width: 240px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.toolbar-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.toolbar-search-icon { color: var(--text-muted); font-size: 11px; flex-shrink: 0; }
.toolbar-search-inp {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13px; font-family: inherit;
  min-width: 0;
}
.toolbar-search-inp::placeholder { color: var(--text-muted); }
.toolbar-search-clear {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 0 2px; line-height: 1; flex-shrink: 0; font-size: 11px;
  transition: color var(--t-fast);
}
.toolbar-search-clear:hover { color: var(--danger); }
.toolbar-search-clear.hidden { display: none; }

/* View switcher */
.view-switcher {
  display: flex; gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 3px;
}
.view-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 5px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border: none; background: transparent;
  transition: all var(--t-fast) var(--ease); white-space: nowrap;
}
.view-btn i { font-size: 12px; }
.view-btn-label { display: none; }
.view-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.view-btn.active { color: var(--primary); background: rgba(79,142,247,.15); }

/* Content area border */
#home-courses-table {
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--r-md) var(--r-md);
  overflow: hidden;
  background: var(--bg-card);
  min-height: 160px;
}

/* Loading placeholder */
.courses-loading-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 56px 0; gap: 12px;
  color: var(--text-muted); font-size: 13px;
}

/* ════════════════════════════════════════
   CAROUSEL / SPOTLIGHT
   ════════════════════════════════════════ */
.carousel-section {
  position: relative;
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-bottom: 20px;
  height: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}
.carousel-track { position: relative; width: 100%; height: 100%; }
.carousel-slide {
  position: absolute; inset: 0;
  opacity: 0; pointer-events: none;
  cursor: pointer;
  transform: scale(1.02);
  transition: opacity .5s ease, transform .5s ease;
}
.carousel-slide.active { opacity: 1; pointer-events: auto; transform: scale(1); }
.carousel-slide-bg { position: absolute; inset: 0; }
.carousel-slide-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(4,7,15,.9) 0%, rgba(4,7,15,.6) 50%, rgba(4,7,15,.1) 100%);
}
.carousel-slide-content {
  position: relative; z-index: 2;
  padding: 30px 36px;
  height: 100%;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  max-width: 560px;
}
.carousel-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(245,158,11,.18); color: #fbbf24;
  border: 1px solid rgba(245,158,11,.3);
  border-radius: 20px; padding: 3px 12px;
  font-size: 11px; font-weight: 700; width: fit-content;
}
.carousel-title {
  font-size: 22px; font-weight: 800; color: #fff;
  line-height: 1.3; text-shadow: 0 2px 12px rgba(0,0,0,.5);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.carousel-desc {
  font-size: 13px; color: rgba(255,255,255,.72); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.carousel-meta {
  display: flex; gap: 14px; flex-wrap: wrap;
}
.carousel-meta-item {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: rgba(255,255,255,.6);
}
.carousel-meta-item i { font-size: 11px; }
.carousel-cta {
  display: inline-flex; align-items: center; gap: 7px;
  width: fit-content; margin-top: 2px; padding: 10px 22px;
  background: var(--primary); color: #fff; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 700; cursor: pointer; border: none;
  transition: all var(--t-fast) var(--ease);
  box-shadow: 0 4px 18px rgba(79,142,247,.45);
}
.carousel-cta:hover { background: #3b7de8; transform: translateY(-1px); }
.carousel-slide-idx {
  position: absolute; bottom: 12px; right: 16px; z-index: 5;
  font-size: 10px; font-weight: 700; color: rgba(255,255,255,.4);
}
/* Arrows */
.carousel-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 5; width: 36px; height: 36px;
  background: rgba(4,7,15,.65); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.12); border-radius: 50%;
  color: #fff; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast); opacity: .7;
}
.carousel-arrow:hover { opacity: 1; background: rgba(79,142,247,.5); }
.carousel-prev { left: 12px; }
.carousel-next { right: 12px; }
/* Dots */
.carousel-dots {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 5; display: flex; gap: 5px;
}
.carousel-dot {
  width: 6px; height: 6px; border-radius: 3px;
  background: rgba(255,255,255,.3); cursor: pointer; border: none;
  transition: all .3s ease;
}
.carousel-dot.active { width: 20px; background: var(--primary); }

/* ════════════════════════════════════════
   GRID VIEW
   ════════════════════════════════════════ */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px;
}
.grid-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
  display: flex; flex-direction: column;
  position: relative;
}
.grid-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.grid-card:focus { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Thumbnail */
.grid-card-thumb {
  position: relative;
  width: 100%; aspect-ratio: 16/9;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.grid-thumb-icon { font-size: 38px; opacity: .55; }
.grid-card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,.65));
}
.grid-card-num {
  position: absolute; top: 10px; left: 10px;
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff;
}
/* Play overlay on hover */
.grid-card-play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--t-base);
  background: rgba(0,0,0,.25);
}
.grid-card:hover .grid-card-play-overlay { opacity: 1; }
.grid-play-circle {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
/* Body */
.grid-card-body {
  padding: 14px 14px 8px; flex: 1;
  display: flex; flex-direction: column; gap: 5px;
}
.grid-card-title {
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.grid-card-desc {
  font-size: 11px; color: var(--text-muted); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  flex: 1;
}
.grid-card-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.grid-stat-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
}
.grid-stat-chip i { font-size: 9px; }
.grid-stat-chip--green { color: #34d399 !important; }
/* Footer */
.grid-card-footer { padding: 10px 14px 14px; }
.grid-card-btn {
  width: 100%; padding: 9px;
  border-radius: var(--r-sm); border: none;
  background: var(--btn-col, #6366f1);
  color: #fff; font-size: 12px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 6px;
  box-shadow: 0 3px 12px rgba(99,102,241,.35);
  transition: all var(--t-fast) var(--ease);
}
.grid-card-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }

/* ════════════════════════════════════════
   LIST VIEW
   ════════════════════════════════════════ */
.courses-list-view { display: flex; flex-direction: column; }
.list-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  min-width: 0;
}
.list-card:last-child { border-bottom: none; }
.list-card:hover { background: var(--bg-hover); }
.list-card:focus { outline: 2px solid var(--primary); outline-offset: -2px; }

.list-card-thumb {
  width: 90px; height: 64px; border-radius: var(--r-sm);
  flex-shrink: 0; overflow: hidden; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.list-card-thumb-num {
  position: absolute; top: 5px; left: 5px;
  width: 20px; height: 20px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: #fff;
}
.list-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.list-card-title {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-card-desc {
  font-size: 12px; color: var(--text-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.list-card-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.list-stat-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
}
.list-stat-chip i { font-size: 10px; }
.list-card-action { flex-shrink: 0; }
.list-card-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
  border: 1px solid rgba(99,102,241,.3);
  color: var(--lbtn-col, #6366f1);
  background: rgba(99,102,241,.08);
  transition: all var(--t-fast) var(--ease);
}
.list-card-btn:hover { filter: brightness(1.2); transform: translateY(-1px); }

/* ════════════════════════════════════════
   CATEGORY VIEW
   ════════════════════════════════════════ */
.category-view { display: flex; flex-direction: column; padding: 16px; gap: 24px; }

.category-group {}

.category-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}
.category-header-line {
  position: absolute; bottom: -1px; left: 0;
  width: 48px; height: 2px; border-radius: 1px;
  opacity: .7;
}
.category-icon-wrap {}
.category-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: rgba(99,102,241,.1);
  border: 1px solid rgba(99,102,241,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  color: var(--cat-col, #6366f1);
}
.category-header-info {}
.category-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.category-count { font-size: 11px; color: var(--text-muted); }

/* Category cards horizontal scroll on mobile, grid on desktop */
.category-cards-grid {
  display: flex; flex-direction: column; gap: 7px;
}
.cat-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  min-width: 0;
}
.cat-card:hover { border-color: var(--border-hover); background: var(--bg-hover); }
.cat-card:focus { outline: 2px solid var(--primary); outline-offset: 2px; }

.cat-card-thumb {
  width: 52px; height: 40px; border-radius: var(--r-sm); flex-shrink: 0;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.cat-card-body { flex: 1; min-width: 0; }
.cat-card-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px;
}
.cat-card-desc {
  font-size: 11px; color: var(--text-muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 4px;
}
.cat-card-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.cat-stat-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
}
.cat-stat-chip i { font-size: 9px; }
.cat-card-arrow {
  width: 28px; height: 28px; border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer; background: transparent;
  transition: transform var(--t-fast);
}
.cat-card:hover .cat-card-arrow { transform: translateX(4px); }

/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */

/* Desktop – show view-btn labels */
@media (min-width: 768px) {
  .view-btn-label { display: inline; }
}

@media (max-width: 900px) {
  .welcome-hero-inner { flex-direction: column; align-items: flex-start; }
  .welcome-hero-stats { width: 100%; justify-content: stretch; }
  .hero-stat { flex: 1; justify-content: center; }
}

@media (max-width: 640px) {
  .home-page-wrap { padding-top: 0; }
  .greeting-title { font-size: 19px; }

  /* Carousel */
  .carousel-section { height: 190px; }
  .carousel-slide-content { padding: 20px 20px; gap: 6px; }
  .carousel-title { font-size: 16px; }
  .carousel-desc { display: none; }
  .carousel-meta { display: none; }
  .carousel-cta { padding: 8px 16px; font-size: 12px; margin-top: 0; }

  /* Toolbar */
  .courses-toolbar { padding: 10px 12px; gap: 8px; }
  .toolbar-search { min-width: 120px; }

  /* Grid */
  .courses-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px; }
  .grid-card-thumb { aspect-ratio: 4/3; }
  .grid-card-desc { display: none; }

  /* List */
  .list-card-thumb { width: 70px; height: 52px; }
  .list-card-desc { display: none; }
  .list-card-btn span { display: none; }
  .list-card-btn { padding: 8px 10px; }

  /* Category */
  .category-view { padding: 12px; gap: 18px; }
  .cat-card-desc { display: none; }
}

@media (max-width: 420px) {
  .courses-grid { grid-template-columns: 1fr; }
  .welcome-hero-stats { flex-direction: column; }
  .hero-stat-divider { width: 80%; height: 1px; margin: 0 auto; }
  .hero-stat { padding: 12px 16px; width: 100%; justify-content: flex-start; }
}

/* ══════════════════════════════════════════════════════════════
   COURSE OVERVIEW — Inline chapter + video layout
   ══════════════════════════════════════════════════════════════ */

.co-wrap {
  max-width: 860px;
  margin: 0 auto;
}

/* ── Banner ── */
.co-banner {
  position: relative;
  width: 100%;
  height: 200px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  display: flex; align-items: flex-end;
  overflow: hidden;
}
.co-banner-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.1) 20%, rgba(0,0,0,.78));
}
.co-banner-emoji {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 60px; opacity: .65;
}
.co-banner-content {
  position: relative; z-index: 1;
  padding: 20px 24px; flex: 1;
}
.co-title {
  font-size: 21px; font-weight: 800; color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.5);
  margin-bottom: 8px; line-height: 1.3;
}
.co-badges {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.co-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.15); backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; color: #fff;
}
.co-badge i { font-size: 11px; }

/* ── Description ── */
.co-desc {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-top: none;
  padding: 14px 20px;
  font-size: 13px; color: var(--text-secondary); line-height: 1.65;
}

/* ── Chapters area ── */
.co-chapters-area {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  overflow: hidden;
  margin-bottom: 0;
}
/* When no desc, round top corners of chapters area */
.co-banner + .co-chapters-area {
  border-top: none;
}

.co-chapters-header,
.co-video-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  background: var(--bg-elevated);
}

/* ── Chapter list ── */
.co-chapter-list {
  display: flex; flex-direction: column;
}
.co-chapter-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  min-width: 0;
}
.co-chapter-item:last-child { border-bottom: none; }
.co-chapter-item:hover { background: var(--bg-hover); }
.co-chapter-item.active {
  background: rgba(79,142,247,.08);
  border-left: 3px solid var(--primary);
}
.co-chapter-num {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-input); border: 1px solid var(--border-subtle);
  font-size: 11px; font-weight: 800; color: var(--text-muted);
}
.co-chapter-item.active .co-chapter-num {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.co-chapter-info { flex: 1; min-width: 0; }
.co-chapter-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.co-chapter-meta {
  font-size: 11px; color: var(--text-muted); margin-top: 3px;
  display: flex; align-items: center; gap: 4px;
}
.co-chapter-meta i { font-size: 10px; }
.co-chapter-arrow {
  font-size: 11px; color: var(--text-muted); flex-shrink: 0;
  transition: transform var(--t-fast); opacity: .6;
}
.co-chapter-item.active .co-chapter-arrow {
  transform: rotate(90deg); color: var(--primary); opacity: 1;
}

/* ── Video area (slides below chapters) ── */
.co-video-area {
  background: var(--bg-card);
}
.co-video-header {
  background: rgba(79,142,247,.06);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.co-video-list {
  display: flex; flex-direction: column;
}
.co-video-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  min-width: 0;
}
.co-video-item:last-child { border-bottom: none; }
.co-video-item:hover { background: var(--bg-hover); }
.co-video-item.watched { opacity: .75; }
.co-video-num {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-input); border: 1px solid var(--border-subtle);
  font-size: 11px; font-weight: 800; color: var(--text-muted);
}
.co-video-num.is-watched {
  background: rgba(16,185,129,.15); border-color: rgba(16,185,129,.3);
  color: var(--success);
}
.co-video-info { flex: 1; min-width: 0; }
.co-video-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.co-video-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--text-muted); margin-top: 3px;
}
.co-video-meta i { font-size: 10px; }
.co-video-meta .text-success { color: var(--success); }
.co-video-play {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(79,142,247,.1); border: 1px solid rgba(79,142,247,.2);
  color: var(--primary); font-size: 10px; cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.co-video-item:hover .co-video-play {
  background: var(--primary); color: #fff;
  box-shadow: 0 3px 10px rgba(79,142,247,.4);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .co-banner { height: 160px; }
  .co-title { font-size: 17px; }
  .co-banner-content { padding: 14px 16px; }
  .co-chapter-item { padding: 11px 14px; }
  .co-video-item { padding: 10px 14px; }
  .co-chapters-header, .co-video-header { padding: 10px 14px; }
}

/* ══════════════════════════════════════════════════════════════
   THEME TOGGLE — Topbar + Sidebar
   ══════════════════════════════════════════════════════════════ */

/* Topbar wrapper */
.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* Hide label in topbar on very small screens */
@media (max-width: 480px) {
  .theme-toggle-label { display: none; }
  .admin-btn-label { display: none; }
}

/* Sidebar theme row */
.sidebar-theme-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-bottom: 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}
