/* ===== VARIABLES ===== */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3352;
  --accent: #61dafb;
  --accent2: #a78bfa;
  --accent3: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --sidebar-w: 280px;
  --radius: 10px;
  --font-mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font: 'Inter', system-ui, sans-serif;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow: hidden;
}
#sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
#sidebar-header .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #61dafb, #a78bfa);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #0f1117;
}
#sidebar-header h1 { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.3; }
#sidebar-header span { font-size: 11px; color: var(--text3); font-weight: 400; }

#progress-bar-wrap {
  padding: 12px 16px 8px;
  flex-shrink: 0;
}
#progress-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; display: flex; justify-content: space-between; }
#progress-track { height: 4px; background: var(--border); border-radius: 99px; }
#progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; transition: width 0.4s ease; width: 0%; }

#sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
}
#sidebar-nav::-webkit-scrollbar { width: 4px; }
#sidebar-nav::-webkit-scrollbar-track { background: transparent; }
#sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  padding: 12px 16px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 8px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(97,218,251,0.1); color: var(--accent); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.nav-item.active .nav-num {
  background: rgba(97,218,251,0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.nav-item.completed .nav-num {
  background: rgba(52,211,153,0.1);
  border-color: var(--accent3);
  color: var(--accent3);
}
.nav-item .nav-num-check::after { content: '✓'; }

/* ===== TOPBAR ===== */
#topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: 56px;
  background: rgba(15,17,23,0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  z-index: 90;
}
#menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
#breadcrumb { font-size: 13px; color: var(--text3); flex: 1; }
#breadcrumb span { color: var(--text2); }
#module-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  background: rgba(97,218,251,0.1);
  color: var(--accent);
  border: 1px solid rgba(97,218,251,0.2);
}

/* ===== MAIN CONTENT ===== */
#main {
  margin-left: var(--sidebar-w);
  padding-top: 56px;
  min-height: 100vh;
}
.module-page {
  display: none;
  padding: 40px 48px 60px;
  max-width: 860px;
  animation: fadeIn 0.3s ease;
}
.module-page.active { display: block; }

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

/* ===== MODULE HEADER ===== */
.module-hero {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.module-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent2);
  background: rgba(167,139,250,0.1);
  border: 1px solid rgba(167,139,250,0.2);
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 16px;
}
.module-hero h2 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  color: #fff;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}
.module-hero p {
  font-size: 16px;
  color: var(--text2);
  max-width: 620px;
  line-height: 1.6;
}
.meta-row {
  display: flex;
  gap: 20px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.meta-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text3);
}
.meta-chip svg { width: 13px; height: 13px; }

/* ===== CONTENT ELEMENTS ===== */
.module-page h3 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 36px 0 12px;
  padding-top: 8px;
}
.module-page h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 24px 0 8px;
}
.module-page p { margin-bottom: 14px; color: var(--text2); }
.module-page ul, .module-page ol { padding-left: 20px; margin-bottom: 16px; }
.module-page li { color: var(--text2); margin-bottom: 6px; }
.module-page strong { color: var(--text); font-weight: 600; }

/* Info / warning / tip boxes */
.info-box, .warn-box, .tip-box, .danger-box {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin: 20px 0;
  border-left: 3px solid;
}
.info-box { background: rgba(97,218,251,0.06); border-color: var(--accent); }
.warn-box { background: rgba(251,191,36,0.06); border-color: var(--warn); }
.tip-box { background: rgba(52,211,153,0.06); border-color: var(--accent3); }
.danger-box { background: rgba(248,113,113,0.06); border-color: var(--danger); }
.box-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.box-body { font-size: 14px; color: var(--text2); line-height: 1.6; }
.box-body strong { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 700; }
.info-box .box-body strong { color: var(--accent); }
.warn-box .box-body strong { color: var(--warn); }
.tip-box .box-body strong { color: var(--accent3); }
.danger-box .box-body strong { color: var(--danger); }

/* ===== CODE BLOCKS ===== */
.code-block {
  margin: 20px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.code-lang {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
}
.copy-btn {
  font-size: 11px;
  color: var(--text3);
  background: none;
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: var(--accent3); color: var(--accent3); }
pre {
  padding: 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  background: #0d1117;
  color: #e6edf3;
}
pre::-webkit-scrollbar { height: 4px; }
pre::-webkit-scrollbar-track { background: transparent; }
pre::-webkit-scrollbar-thumb { background: var(--border); }

/* Syntax highlighting */
.kw { color: #ff7b72; }   /* keywords */
.fn { color: #d2a8ff; }   /* functions */
.st { color: #a5d6ff; }   /* strings */
.cm { color: #8b949e; font-style: italic; } /* comments */
.nm { color: #79c0ff; }   /* names/vars */
.nb { color: #ffa657; }   /* numbers */
.op { color: #ff7b72; }   /* operators */
.tag { color: #7ee787; }  /* JSX tags */
.at { color: #79c0ff; }   /* attributes */
.val { color: #a5d6ff; }  /* values */

/* Inline code */
code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

/* ===== STEP GRID ===== */
.steps {
  counter-reset: step;
  margin: 20px 0;
}
.step {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  position: relative;
}
.step::after {
  content: '';
  position: absolute;
  left: 16px;
  top: 36px;
  bottom: -8px;
  width: 1px;
  background: var(--border);
}
.step:last-child::after { display: none; }
.step-num {
  width: 32px; height: 32px;
  background: rgba(97,218,251,0.1);
  border: 1px solid rgba(97,218,251,0.3);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}
.step-body { flex: 1; padding-bottom: 8px; }
.step-body h4 { margin-top: 4px; margin-bottom: 6px; }

/* ===== FEATURE CARDS ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 20px 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--accent); }
.card-icon { font-size: 24px; margin-bottom: 8px; }
.card h4 { font-size: 13px; margin: 0 0 4px; }
.card p { font-size: 12px; margin: 0; color: var(--text3); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; margin: 20px 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--surface2); color: var(--text); font-weight: 600; padding: 10px 14px; text-align: left; border-bottom: 2px solid var(--border); }
td { padding: 9px 14px; border-bottom: 1px solid var(--border); color: var(--text2); }
tr:hover td { background: var(--surface); }

/* ===== EXERCISE SECTION ===== */
.exercise-section {
  margin-top: 48px;
  padding: 28px;
  background: rgba(167,139,250,0.05);
  border: 1px solid rgba(167,139,250,0.2);
  border-radius: var(--radius);
}
.exercise-section h3 {
  color: var(--accent2);
  font-size: 16px;
  margin-top: 0;
  padding-top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.exercise-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--text2);
}
.exercise-item::before {
  content: attr(data-num) '. ';
  font-weight: 700;
  color: var(--accent2);
}

/* ===== NAV BUTTONS ===== */
.nav-buttons {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 52px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  flex: 1;
  max-width: 240px;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(97,218,251,0.05); }
.nav-btn.next { margin-left: auto; justify-content: flex-end; }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

/* ===== SIDEBAR OVERLAY (mobile) ===== */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* ===== HOME ===== */
.home-hero {
  text-align: center;
  padding: 60px 0 48px;
}
.home-logo {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, #61dafb, #a78bfa);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  font-weight: 900;
  color: #0f1117;
  margin: 0 auto 20px;
}
.home-hero h2 { font-size: 36px; font-weight: 800; color: #fff; margin-bottom: 12px; letter-spacing: -0.5px; }
.home-hero p { font-size: 16px; color: var(--text2); max-width: 500px; margin: 0 auto 32px; }
.start-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0f1117;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  transition: opacity 0.2s;
}
.start-btn:hover { opacity: 0.9; }
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 20px;
}
.module-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.module-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.module-card .m-num {
  width: 28px; height: 28px;
  background: rgba(97,218,251,0.1);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}
.module-card .m-title { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.4; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #sidebar-overlay.visible { display: block; }
  #menu-toggle { display: flex; }
  #main { margin-left: 0; }
  #topbar { left: 0; }
  .module-page { padding: 24px 20px 48px; }
  .module-hero h2 { font-size: 24px; }
  .nav-buttons { flex-direction: column; }
  .nav-btn { max-width: 100%; }
  .nav-btn.next { margin-left: 0; justify-content: flex-start; }
}
