/* ==========================================================================
   PODE Course Interactive Study App - Minimalist Editorial Design
   MATH 2010: Differential Equations
   Aesthetic: Quiet, Typographic, Monochromatic, Distraction-Free
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Light Mode: Warm Paper & Charcoal Ink */
  --bg-app: #ffffff;
  --bg-sidebar: #fafafa;
  --bg-card: #ffffff;
  --bg-subtle: #f4f4f5;
  --bg-hover: #ebebee;

  --border: #e4e4e7;
  --border-subtle: #f0f0f2;
  --border-strong: #d4d4d8;

  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;

  --accent: #18181b;
  --accent-inverted: #ffffff;

  --status-mastered: #10b981;
  --status-review: #f59e0b;
  --alert-bg: #fffbeb;
  --alert-border: #fef3c7;
  --alert-text: #92400e;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --sidebar-w: 290px;
  --header-h: 56px;
  --content-max-w: 800px;
}

[data-theme="dark"] {
  /* Dark Mode: Deep Matte Zinc */
  --bg-app: #0e0e10;
  --bg-sidebar: #141416;
  --bg-card: #18181b;
  --bg-subtle: #1f1f23;
  --bg-hover: #27272a;

  --border: #27272a;
  --border-subtle: #1f1f23;
  --border-strong: #3f3f46;

  --text-primary: #f4f4f5;
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;

  --accent: #f4f4f5;
  --accent-inverted: #18181b;

  --status-mastered: #34d399;
  --status-review: #fbbf24;
  --alert-bg: #1c1917;
  --alert-border: #292524;
  --alert-text: #fde68a;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.65;
  font-size: 15px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

/* Custom Minimal Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* Layout */
#app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px 18px 16px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.course-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.sidebar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Progress Tracker */
.sidebar-stats {
  margin-top: 14px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.progress-bar-container {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

/* Sidebar Search */
.sidebar-search-box {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-search-input {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.sidebar-search-input:focus {
  border-color: var(--text-secondary);
}

/* Sidebar Nav */
.sidebar-nav {
  padding: 14px 12px 40px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.nav-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-counter {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Module List */
.nav-module-group {
  margin-bottom: 6px;
}

.nav-module-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  user-select: none;
}

.nav-module-title:hover {
  background: var(--bg-hover);
}

.nav-module-title .chevron {
  font-size: 9px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.nav-module-group.collapsed .chevron {
  transform: rotate(-90deg);
}

.nav-module-group.collapsed .topic-list {
  display: none;
}

.topic-list {
  display: flex;
  flex-direction: column;
  padding-left: 6px;
  margin-top: 2px;
  gap: 1px;
}

.topic-nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.35;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.topic-nav-btn.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  font-weight: 600;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}

.status-dot.mastered {
  background: var(--status-mastered);
}

.status-dot.needs-review {
  background: var(--status-review);
}

/* Main Content Area */
#main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 36px;
  position: sticky;
  top: 0;
  background: var(--bg-app);
  z-index: 40;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-primary);
  cursor: pointer;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb-separator {
  color: var(--text-faint);
  font-size: 11px;
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* Topic Container */
.content-area {
  padding: 36px 48px 80px 48px;
  max-width: var(--content-max-w);
  margin: 0 auto;
  width: 100%;
}

.topic-header {
  margin-bottom: 24px;
}

.topic-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.slide-badge {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.topic-main-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.25;
}

/* Alert Banner */
.flagged-alert {
  background: var(--alert-bg);
  border: 1px solid var(--alert-border);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--alert-text);
}

.flagged-alert-title {
  font-weight: 600;
  margin-bottom: 2px;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* View Switcher Tabs (Minimalist Segmented Control) */
.view-tabs-container {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  gap: 4px;
}

.view-tab-btn {
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s ease;
}

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

.view-tab-btn.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--text-primary);
}

/* Content Text & Typography */
.study-card {
  margin-bottom: 36px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.card-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.card-body p {
  margin-bottom: 14px;
}

.card-body ul, .card-body ol {
  padding-left: 20px;
  margin-bottom: 14px;
}

.card-body li {
  margin-bottom: 6px;
}

/* KaTeX Formatting */
.katex-display {
  margin: 1em 0 !important;
  padding: 10px 14px !important;
  background: var(--bg-subtle) !important;
  border-radius: var(--radius-sm) !important;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Worked Examples */
.example-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  background: var(--bg-card);
}

.example-header {
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.example-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.example-body {
  padding: 18px;
}

.problem-statement {
  background: var(--bg-subtle);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.step-item {
  border-left: 2px solid var(--border-strong);
  padding-left: 14px;
  margin-left: 6px;
  margin-bottom: 16px;
}

.step-marker {
  display: none;
}

.step-math {
  background: var(--bg-subtle);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.step-reason {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.example-controls {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-inverted);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Interactive Simulations (Clean Scientific Look) */
.simulation-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 32px;
  background: var(--bg-card);
}

.sim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.sim-canvas-wrapper {
  width: 100%;
  height: 320px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

canvas.interactive-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.sim-controls {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}

.sim-slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sim-slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.sim-slider-val {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

input[type="range"] {
  width: 100%;
  height: 4px;
  background: var(--border-strong);
  accent-color: var(--text-primary);
  cursor: pointer;
}

/* Practice & Quiz */
.practice-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 32px;
  background: var(--bg-card);
}

.practice-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.hint-box, .solution-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.6;
  display: none;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* Flashcards (Clean Minimalist Design) */
.flashcard-wrapper {
  max-width: 540px;
  margin: 30px auto;
}

.flashcard-scene {
  width: 100%;
  min-height: 240px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.15s ease;
  user-select: none;
}

.flashcard-scene:hover {
  border-color: var(--text-secondary);
}

.flashcard-face-back {
  display: none;
}

.flashcard-scene.is-flipped .flashcard-face-front {
  display: none;
}

.flashcard-scene.is-flipped .flashcard-face-back {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 100%;
}

.flashcard-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.flashcard-text {
  font-size: 16px;
  color: var(--text-primary);
  margin: 20px 0;
  line-height: 1.5;
}

.flashcard-hint {
  font-size: 12px;
  color: var(--text-faint);
}

.flashcard-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

/* Formula Sheet */
.formula-search-bar {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  margin-bottom: 24px;
  outline: none;
}

.formula-search-bar:focus {
  border-color: var(--text-secondary);
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.formula-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: var(--bg-card);
}

.formula-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.formula-card-notes {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 6px;
}

/* Decision Tree / Connect the Dots */
.decision-tree-node {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 18px;
  background: var(--bg-card);
}

.decision-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.decision-branches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.branch-card {
  background: var(--bg-subtle);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.branch-label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.branch-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Exam Mode */
.exam-container {
  max-width: 680px;
  margin: 0 auto;
}

.exam-timer-bar {
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  position: sticky;
  top: 70px;
  z-index: 30;
}

.timer-display {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.exam-question-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 18px;
  background: var(--bg-card);
}

.question-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.question-text {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-btn {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s ease;
}

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

.option-btn.selected {
  background: var(--bg-hover);
  border-color: var(--text-primary);
  font-weight: 600;
}

.option-btn.correct {
  border-color: var(--status-mastered) !important;
  color: var(--status-mastered) !important;
  font-weight: 600;
}

.option-btn.incorrect {
  border-color: #ef4444 !important;
  color: #ef4444 !important;
  font-weight: 600;
}

/* Mobile Media Queries */
@media (max-width: 900px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

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

  #main-wrapper {
    margin-left: 0;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .content-area {
    padding: 24px 20px 60px 20px;
  }
}
