:root {
  /* Colors */
  --bg-dark: #0a0a0c;
  --bg-panel: #141418;
  --bg-surface: #1e1e24;
  --bg-hover: #2a2a30;
  
  --accent-primary: #a855f7;
  --accent-hover: #9333ea;
  --accent-glow: rgba(168, 85, 247, 0.2);
  
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --border-light: rgba(255, 255, 255, 0.08);

  --font-sans: 'Inter', sans-serif;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;
  
  --nav-height: 70px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden; /* We manage scroll area inside */
}

/* --- TYPOGRAPHY --- */
h1, h2, h3 { font-weight: 600; line-height: 1.2; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s ease;
}
.btn-primary {
  background-color: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover { background-color: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary { background-color: var(--bg-surface); color: var(--text-primary); }
.btn-secondary:hover:not(:disabled) { background-color: var(--bg-hover); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline { border: 1px solid var(--border-light); color: var(--text-secondary); }
.btn-outline:hover { color: var(--text-primary); border-color: var(--text-primary); }
.btn-outline.is-done { color: var(--success); border-color: var(--success); background-color: var(--success-bg); }

/* --- NAVBAR --- */
.navbar {
  height: var(--nav-height);
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: fixed;
  top: 0; width: 100%; z-index: 50;
}
.nav-left { display: flex; align-items: center; gap: 1rem; }
.hamburger-btn { color: var(--text-primary); font-size: 1.5rem; display: none; }

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-icon { color: var(--accent-primary); font-size: 1.75rem; }
.brand-name { font-weight: 700; font-size: 1.125rem; }

.nav-links { display: flex; gap: 2rem; position: absolute; left: 50%; transform: translateX(-50%); }
.nav-link { 
  color: var(--text-secondary); font-weight: 500; font-size: 0.9375rem; 
  padding: 0.5rem 0; border-bottom: 2px solid transparent; transition: color 0.2s;
}
.nav-link:hover { color: var(--text-primary); }
.nav-link.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); }

.nav-right { display: flex; align-items: center; gap: 1.5rem; }

/* Progress Circle */
.global-progress { display: flex; align-items: center; }
.gp-ring { position: relative; width: 40px; height: 40px; }
.circular-chart { display: block; margin: 0 auto; max-width: 100%; max-height: 250px; }
.circle-bg { fill: none; stroke: var(--bg-surface); stroke-width: 3.8; }
.circle { fill: none; stroke-width: 3.8; stroke-linecap: round; transition: stroke-dasharray 0.5s ease; }
.purple .circle { stroke: var(--accent-primary); }
.gp-text { 
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 0.6rem; font-weight: 700; color: var(--text-primary);
}

.user-avatar { 
  width: 36px; height: 36px; border-radius: 50%; background: var(--bg-surface);
  display: flex; align-items: center; justify-content: center; color: var(--accent-primary); border: 1px solid var(--border-light);
}

/* --- MOBILE DRAWER --- */
.mobile-drawer {
  position: fixed; top: 0; left: -300px; width: 280px; height: 100vh;
  background-color: var(--bg-panel); z-index: 100; transition: left 0.3s ease;
  border-right: 1px solid var(--border-light); display: flex; flex-direction: column;
}
.mobile-drawer.open { left: 0; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem; border-bottom: 1px solid var(--border-light);}
.close-drawer { font-size: 1.5rem; color: var(--text-secondary); }
.drawer-links { display: flex; flex-direction: column; padding: 1rem; gap: 0.5rem; }
.drawer-link {
  display: flex; align-items: center; gap: 0.75rem; padding: 1rem;
  border-radius: var(--radius-md); font-weight: 500; color: var(--text-secondary); transition: all 0.2s;
}
.drawer-link i { font-size: 1.25rem; }
.drawer-link.active { background-color: var(--accent-glow); color: var(--accent-primary); }
.drawer-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 90;
  display: none; opacity: 0; transition: opacity 0.3s;
}
.drawer-overlay.active { display: block; opacity: 1; }

/* --- APP MAIN --- */
.app-main {
  margin-top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  width: 100%; overflow: hidden; position: relative;
}
.view-dashboard, .view-player {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  overflow-y: auto; display: none; animation: fadeIn 0.3s ease;
}
.view-dashboard.active, .view-player.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- DASHBOARD VIEW --- */
.view-dashboard { padding-bottom: 4rem; }
.dashboard-banner {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: 4rem 2rem; display: flex; justify-content: center;
  position: relative;
  overflow: hidden;
}
.dashboard-banner::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at top right, rgba(168, 85, 247, 0.15) 0%, transparent 60%);
  pointer-events: none;
}
.banner-content { max-width: 1200px; width: 100%; position: relative; z-index: 1; }
.banner-content h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.banner-content p { font-size: 1.125rem; color: var(--text-secondary); margin-bottom: 2rem; max-width: 600px; }

.dashboard-content { max-width: 1200px; margin: 0 auto; padding: 3rem 2rem; }
.section-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; }
.section-header h2 { font-size: 1.5rem; }
.section-header span { color: var(--text-muted); font-size: 0.875rem; }

.modules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; }
.module-card {
  background-color: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); padding: 1.5rem; cursor: pointer;
  transition: transform 0.2s, border-color 0.2s; position: relative; overflow: hidden;
}
.module-card:hover { transform: translateY(-4px); border-color: var(--accent-primary); }
.module-pill {
  display: inline-block; padding: 0.25rem 0.75rem; font-size: 0.75rem; font-weight: 600;
  background-color: var(--bg-surface); color: var(--text-secondary); border-radius: var(--radius-full); margin-bottom: 1rem;
}
.module-card h3 { font-size: 1.125rem; margin-bottom: 0.5rem; }
.module-card p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1.5rem; line-height: 1.4; }
.card-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.875rem; }
.card-progress { display: flex; align-items: center; gap: 0.5rem; color: var(--accent-primary); font-weight: 500; }
.card-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-surface); display: flex; align-items: center; justify-content: center; }

/* --- PLAYER VIEW --- */
.course-layout { display: flex; height: 100%; }

.player-main { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 2rem; gap: 1.5rem; }
.video-wrapper {
  width: 100%; max-width: 1200px; margin: 0 auto; background: #000;
  border-radius: var(--radius-lg); border: 1px solid var(--border-light); overflow: hidden;
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
  max-height: 55vh;
}
.video-aspect { width: 100%; height: 100%; position: relative; }
.video-aspect iframe { width: 100%; height: 100%; border: none; }
.error-state { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #111; color: var(--text-muted); gap: 1rem;}
.error-state i { font-size: 3rem; color: #ef4444; }

.player-header { max-width: 1200px; width: 100%; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;}
.badge { display: inline-block; padding: 0.25rem 0.75rem; font-size: 0.75rem; font-weight: 600; background-color: var(--accent-glow); color: var(--accent-primary); border-radius: var(--radius-full); margin-bottom: 0.5rem;}
.lesson-meta h2 { font-size: 1.5rem; }

.player-nav-buttons { max-width: 1200px; width: 100%; margin: 0 auto; padding-top: 1rem; border-top: 1px solid var(--border-light); display: flex; justify-content: space-between;}

/* Sidebar Accordion */
.course-sidebar {
  width: 380px; flex-shrink: 0; background-color: var(--bg-panel); border-left: 1px solid var(--border-light);
  display: flex; flex-direction: column;
}
.sidebar-header { padding: 1.5rem; border-bottom: 1px solid var(--border-light); }
.accordion-playlist { flex: 1; overflow-y: auto; }
/* Scrollbar */
.accordion-playlist::-webkit-scrollbar, .player-main::-webkit-scrollbar, .view-dashboard::-webkit-scrollbar { width: 6px; }
.accordion-playlist::-webkit-scrollbar-thumb, .player-main::-webkit-scrollbar-thumb, .view-dashboard::-webkit-scrollbar-thumb { background: var(--bg-surface); border-radius: 3px; }

.acc-item { border-bottom: 1px solid var(--border-light); }
.acc-header {
  padding: 1.25rem 1.5rem; display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; background: var(--bg-panel); transition: background 0.2s;
}
.acc-header:hover { background: var(--bg-surface); }
.acc-title { font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.25rem; }
.acc-meta { font-size: 0.75rem; color: var(--text-muted); }
.acc-icon { transition: transform 0.3s; color: var(--text-secondary); }
.acc-item.open .acc-icon { transform: rotate(180deg); }
.acc-content { display: none; background: var(--bg-dark); }
.acc-item.open .acc-content { display: block; animation: slideDown 0.3s ease; }

.lesson-list { display: flex; flex-direction: column; }
.lesson-row {
  display: flex; align-items: flex-start; gap: 1rem; padding: 1rem 1.5rem;
  cursor: pointer; transition: background 0.2s; border-left: 3px solid transparent;
}
.lesson-row:hover { background: var(--bg-surface); }
.lesson-row.active { background: var(--bg-surface); border-left-color: var(--accent-primary); }

.l-status { margin-top: 2px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--text-muted); display: flex; align-items: center; justify-content: center; color: transparent;}
.lesson-row.done .l-status { background: var(--success); border-color: var(--success); color: white; }
.lesson-row.active:not(.done) .l-status { border-color: var(--accent-primary); }
.l-status i { font-size: 0.75rem; font-weight: bold; }

.l-details { flex: 1; }
.l-name { font-size: 0.875rem; color: var(--text-secondary); transition: color 0.2s;}
.lesson-row.active .l-name { color: var(--text-primary); font-weight: 500; }
.lesson-row:hover .l-name { color: var(--text-primary); }

@media (max-width: 1024px) {
  .course-layout { flex-direction: column; }
  .course-sidebar { width: 100%; height: 50vh; border-left: none; border-top: 1px solid var(--border-light); }
  .player-main { padding: 1.5rem 1rem; }
}

@media (max-width: 768px) {
  .nav-links.desktop-only { display: none; }
  .hamburger-btn { display: block; }
  .dashboard-banner { padding: 3rem 1.5rem; text-align: center; }
  .banner-content h1 { font-size: 2rem; }
  .player-main { padding: 1rem 0; gap: 1rem; }
  .video-wrapper { border-radius: 0; border-left: none; border-right: none; }
  .player-header { flex-direction: column; gap: 1.5rem; padding: 0 1rem; }
  .player-actions { width: 100%; }
  #btnMarkDone { width: 100%; }
  .player-nav-buttons { padding: 1rem; }
  
  .toast-alert {
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* --- TOAST ALERT --- */
.toast-alert {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  max-width: 420px;
  background-color: #271212;
  border: 1px solid #7f1d1d;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  z-index: 999;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  animation: slideUpToast 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.3s ease;
}
.toast-icon {
  color: #ef4444;
  font-size: 1.5rem;
  margin-top: 2px;
}
.toast-content strong {
  display: block;
  color: #fca5a5;
  margin-bottom: 0.25rem;
  font-size: 0.9375rem;
}
.toast-content p {
  color: #f87171;
  font-size: 0.8125rem;
  line-height: 1.4;
}
.toast-close {
  color: #fca5a5;
  padding: 0.25rem;
  opacity: 0.7;
}
.toast-close:hover {
  opacity: 1;
}
@keyframes slideUpToast {
  from { transform: translateY(100px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
