/* ============================================
   Base Styles — Reset, Typography, Layout
   ============================================ */

:root, [data-theme="dark"] {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --accent-green: #3fb950;
  --accent-green-dim: #238636;
  --accent-amber: #d29922;
  --accent-amber-dim: #9e6a03;
  --accent-red: #f85149;
  --accent-blue: #58a6ff;
  --border-default: #30363d;
  --border-muted: #21262d;
  --font-mono: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --sidebar-width: 280px;
  --header-height: 56px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
  --code-bg: #161b22;
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eaeef2;
  --bg-hover: #d0d7de;
  --text-primary: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8b949e;
  --accent-green: #1a7f37;
  --accent-green-dim: #2da44e;
  --accent-amber: #9a6700;
  --accent-amber-dim: #bf8700;
  --accent-red: #cf222e;
  --accent-blue: #0969da;
  --border-default: #d0d7de;
  --border-muted: #eaeef2;
  --shadow-card: 0 1px 3px rgba(31,35,40,0.12);
  --code-bg: #f6f8fa;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img, svg {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
}

code, pre, kbd {
  font-family: var(--font-mono);
}

/* ============================================
   Layout — Header, Sidebar, Main
   ============================================ */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: 12px;
  overflow: hidden;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.hamburger:hover {
  background: var(--bg-hover);
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: transform var(--transition-fast);
}

.app-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-green);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.app-title .prompt {
  color: var(--text-muted);
}

/* Header controls (theme + language) */
.header-controls {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
}

.header-btn {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.header-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

#theme-toggle {
  font-size: 1rem;
  padding: 2px 8px;
}

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-default);
  overflow-y: auto;
  padding: 16px 0;
  z-index: 90;
  transition: transform var(--transition-normal);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 3px;
}

.sidebar-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background: var(--bg-tertiary);
  color: var(--accent-green);
  font-weight: 500;
}

.nav-item .module-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-muted);
}

.nav-item.active .module-num {
  background: var(--accent-green-dim);
  color: var(--accent-green);
}

.nav-item .progress-dot {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-hover);
}

.nav-item .progress-dot.completed {
  background: var(--accent-green);
}

.nav-item .progress-dot.partial {
  background: var(--accent-amber);
}

.nav-item .flask-badge {
  font-size: 0.55rem;
  background: transparent;
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: auto;
  margin-right: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex-shrink: 0;
  opacity: 0.7;
}

.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  padding: 32px 40px;
  max-width: 960px;
}

#content {
  animation: fadeIn 0.2s ease;
}

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

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4 {
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 16px;
}

h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 600; border-bottom: 1px solid var(--border-default); padding-bottom: 8px; }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }

p {
  margin-bottom: 12px;
  color: var(--text-secondary);
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

.text-green { color: var(--accent-green); }
.text-amber { color: var(--accent-amber); }
.text-red { color: var(--accent-red); }
.text-blue { color: var(--accent-blue); }
.text-muted { color: var(--text-muted); }

/* ============================================
   Sidebar Overlay (mobile)
   ============================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 85;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

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

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

  .main-content {
    margin-left: 0;
    padding: 24px 16px;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 16px 12px;
  }

  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.2rem; }
}
