/* ContainerLearn — Master CSS Style System */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Fira+Code:wght@400;500;600&display=swap');

:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-code: 'Fira Code', monospace;

  /* Color Palette - Light Mode */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  
  --color-secondary: #06b6d4;
  --color-secondary-hover: #0891b2;
  --color-secondary-light: #cffafe;

  --color-success: #10b981;
  --color-success-light: #d1fae5;
  --color-warning: #f59e0b;
  --color-warning-light: #fef3c7;
  --color-danger: #ef4444;
  --color-danger-light: #fee2e2;

  --nav-bg: rgba(255, 255, 255, 0.9);
  --card-shadow: 0 10px 30px -5px rgba(37, 99, 235, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --hover-shadow: 0 20px 40px -10px rgba(37, 99, 235, 0.15);
  --code-bg: #1e293b;
  --code-text: #e2e8f0;

  --transition-speed: 0.3s;
}

/* Dark Mode Color Palette */
body.dark-mode {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #334155;
  --bg-glass: rgba(30, 41, 59, 0.85);
  
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-light: #94a3b8;
  
  --border-color: #334155;
  --border-hover: #475569;

  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-primary-light: rgba(59, 130, 246, 0.2);
  
  --color-secondary: #22d3ee;
  --color-secondary-hover: #67e8f9;
  --color-secondary-light: rgba(34, 211, 238, 0.2);

  --color-success: #34d399;
  --color-success-light: rgba(52, 211, 153, 0.2);
  --color-warning: #fbbf24;
  --color-warning-light: rgba(251, 191, 36, 0.15);
  --color-danger: #f87171;
  --color-danger-light: rgba(248, 113, 113, 0.2);

  --nav-bg: rgba(15, 23, 42, 0.9);
  --card-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --hover-shadow: 0 20px 40px -10px rgba(34, 211, 238, 0.15);
  --code-bg: #020617;
  --code-text: #f1f5f9;
}

/* ============================================================
   Dark Mode — ROOT FIX: Override Bootstrap 5's own CSS variables
   Bootstrap uses --bs-* vars for ALL component colors.
   We must override them on body.dark-mode or text stays black.
   ============================================================ */

body.dark-mode {
  /* Bootstrap core body variables */
  --bs-body-color: #f8fafc;
  --bs-body-color-rgb: 248, 250, 252;
  --bs-body-bg: #0f172a;
  --bs-body-bg-rgb: 15, 23, 42;

  /* Bootstrap secondary/tertiary text */
  --bs-secondary-color: #cbd5e1;
  --bs-secondary-color-rgb: 203, 213, 225;
  --bs-tertiary-color: #94a3b8;
  --bs-tertiary-color-rgb: 148, 163, 184;

  /* Bootstrap surface backgrounds */
  --bs-secondary-bg: #1e293b;
  --bs-secondary-bg-rgb: 30, 41, 59;
  --bs-tertiary-bg: #334155;
  --bs-tertiary-bg-rgb: 51, 65, 85;

  /* Bootstrap heading color */
  --bs-heading-color: #f8fafc;

  /* Bootstrap border */
  --bs-border-color: #334155;
  --bs-border-color-translucent: rgba(255,255,255,0.15);

  /* Bootstrap link */
  --bs-link-color: #3b82f6;
  --bs-link-hover-color: #60a5fa;
  --bs-link-color-rgb: 59, 130, 246;

  /* Bootstrap emphasis */
  --bs-emphasis-color: #f8fafc;
  --bs-emphasis-color-rgb: 248, 250, 252;

  /* Bootstrap code */
  --bs-code-color: #e879f9;

  /* Bootstrap subtle backgrounds for badges/alerts */
  --bs-primary-bg-subtle: rgba(59, 130, 246, 0.15);
  --bs-secondary-bg-subtle: rgba(100, 116, 139, 0.15);
  --bs-success-bg-subtle: rgba(52, 211, 153, 0.15);
  --bs-info-bg-subtle: rgba(34, 211, 238, 0.15);
  --bs-warning-bg-subtle: rgba(251, 191, 36, 0.15);
  --bs-danger-bg-subtle: rgba(248, 113, 113, 0.15);
  --bs-light-bg-subtle: #1e293b;
  --bs-dark-bg-subtle: #334155;

  /* Bootstrap subtle border colors */
  --bs-primary-border-subtle: rgba(59, 130, 246, 0.3);
  --bs-secondary-border-subtle: rgba(100, 116, 139, 0.3);
  --bs-success-border-subtle: rgba(52, 211, 153, 0.3);
  --bs-info-border-subtle: rgba(34, 211, 238, 0.3);
  --bs-warning-border-subtle: rgba(251, 191, 36, 0.3);
  --bs-danger-border-subtle: rgba(248, 113, 113, 0.3);

  /* Bootstrap subtle text colors */
  --bs-primary-text-emphasis: #60a5fa;
  --bs-secondary-text-emphasis: #94a3b8;
  --bs-success-text-emphasis: #6ee7b7;
  --bs-info-text-emphasis: #67e8f9;
  --bs-warning-text-emphasis: #fde68a;
  --bs-danger-text-emphasis: #fca5a5;
  --bs-light-text-emphasis: #f8fafc;
  --bs-dark-text-emphasis: #cbd5e1;

  /* Bootstrap form variables */
  --bs-form-control-bg: #334155;
  --bs-form-control-disabled-bg: #1e293b;
  --bs-input-bg: #334155;
  --bs-input-border-color: #475569;
  --bs-input-color: #f8fafc;
  --bs-input-placeholder-color: #64748b;
  --bs-input-focus-bg: #334155;
  --bs-input-focus-color: #f8fafc;

  /* Bootstrap table */
  --bs-table-color: #f8fafc;
  --bs-table-bg: transparent;
  --bs-table-border-color: #334155;
  --bs-table-striped-bg: rgba(255,255,255,0.05);
  --bs-table-hover-bg: rgba(255,255,255,0.075);
}

/* ============================================================
   Dark Mode — Individual element overrides for anything
   Bootstrap doesn't cover via its own CSS variables
   ============================================================ */

/* bg-body-tertiary: Bootstrap's light grey surface */
body.dark-mode .bg-body-tertiary {
  background-color: #334155 !important;
  color: #f8fafc !important;
}

/* Section with bg-body-tertiary */
body.dark-mode section.bg-body-tertiary {
  background-color: #1a2744 !important;
  color: #f8fafc !important;
}

/* text-dark: hardcoded black text */
body.dark-mode .text-dark {
  color: #f8fafc !important;
}

/* text-muted in dark mode */
body.dark-mode .text-muted {
  color: #94a3b8 !important;
}

/* text-body */
body.dark-mode .text-body {
  color: #f8fafc !important;
}

/* small text */
body.dark-mode small,
body.dark-mode .small {
  color: inherit;
}

/* strong / bold text */
body.dark-mode strong,
body.dark-mode b {
  color: inherit;
}

/* Headings */
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3,
body.dark-mode h4, body.dark-mode h5, body.dark-mode h6,
body.dark-mode .h1, body.dark-mode .h2, body.dark-mode .h3,
body.dark-mode .h4, body.dark-mode .h5, body.dark-mode .h6 {
  color: #f8fafc;
}

/* bg-warning-subtle: yellow background with dark text */
body.dark-mode .bg-warning-subtle {
  background-color: rgba(251, 191, 36, 0.15) !important;
  color: #fde68a !important;
}

/* bg-info badge */
body.dark-mode .bg-info {
  background-color: #0891b2 !important;
  color: #f0f9ff !important;
}

/* mark element highlight */
body.dark-mode mark {
  background-color: rgba(251, 191, 36, 0.25) !important;
  color: #fde68a !important;
}

/* Bootstrap form controls */
body.dark-mode .form-control,
body.dark-mode .form-select {
  background-color: #334155;
  color: #f8fafc;
  border-color: #475569;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
  background-color: #334155;
  color: #f8fafc;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

body.dark-mode .form-control::placeholder {
  color: #64748b;
}

body.dark-mode .form-label,
body.dark-mode label {
  color: #f8fafc;
}

/* Bootstrap alert variants */
body.dark-mode .alert-info {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

body.dark-mode .alert-warning {
  background-color: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
  color: #fde68a;
}

body.dark-mode .alert-success {
  background-color: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.3);
  color: #6ee7b7;
}

body.dark-mode .alert-danger {
  background-color: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.3);
  color: #fca5a5;
}

/* Bootstrap border utilities */
body.dark-mode .border-warning-subtle {
  border-color: rgba(251, 191, 36, 0.35) !important;
}

body.dark-mode .border,
body.dark-mode .border-top,
body.dark-mode .border-bottom,
body.dark-mode .border-start,
body.dark-mode .border-end {
  border-color: #334155 !important;
}

/* bg-primary-subtle */
body.dark-mode .bg-primary-subtle {
  background-color: rgba(59, 130, 246, 0.2) !important;
}

/* bg-secondary-subtle */
body.dark-mode .bg-secondary-subtle {
  background-color: rgba(100, 116, 139, 0.2) !important;
}

/* bg-dark in code box */
body.dark-mode .bg-dark {
  background-color: #020617 !important;
}

/* Navbar toggler icon */
body.dark-mode .navbar-toggler-icon {
  filter: invert(1);
}

/* hr */
body.dark-mode hr {
  border-color: #334155;
  opacity: 1;
}

/* Badges — keep readable */
body.dark-mode .badge.bg-secondary {
  background-color: #475569 !important;
  color: #f8fafc !important;
}

/* p, li, span default text */
body.dark-mode p,
body.dark-mode li,
body.dark-mode span:not(.badge):not(.code-dot):not(.search-icon) {
  color: inherit;
}

/* blockquote */
body.dark-mode blockquote,
body.dark-mode .blockquote {
  color: #cbd5e1;
}

/* em / italic */
body.dark-mode em {
  color: inherit;
}

/* code inline */
body.dark-mode code {
  color: #e879f9;
  background-color: rgba(232, 121, 249, 0.1);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Monospace example box */
body.dark-mode .font-monospace {
  color: #f8fafc;
}

body.dark-mode .font-monospace.text-primary {
  color: #60a5fa !important;
}

/* Global Reset & Typography */
* {
  box-sizing: border-box;
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease, border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Base Headings */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

a:hover {
  color: var(--color-primary-hover);
}

/* Custom Navbar */
.navbar-custom {
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0.8rem 1rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--text-main) !important;
}

.navbar-brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
}

.nav-link {
  font-weight: 500;
  color: var(--text-muted) !important;
  padding: 0.5rem 1rem !important;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--color-primary) !important;
  background-color: var(--color-primary-light);
}

/* Dark Mode Button */
.btn-theme-toggle {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.9rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-theme-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Progress Pill in Nav */
.progress-badge {
  background: var(--color-secondary-light);
  color: var(--color-secondary-hover);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--color-secondary);
}

body.dark-mode .progress-badge {
  color: var(--color-secondary);
}

/* Modern Hero Section */
.hero-section {
  padding: 5rem 0 4rem;
  background: radial-gradient(circle at 80% 20%, rgba(37, 99, 235, 0.08) 0%, transparent 60%),
              radial-gradient(circle at 10% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 60%);
  position: relative;
}

.hero-title {
  font-size: 3.2rem;
  line-height: 1.15;
  font-weight: 800;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 600px;
}

.hero-img {
  width: 100%;
  max-width: 540px;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border-color);
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-12px); }
}

/* Custom Buttons */
.btn-primary-custom {
  background: linear-gradient(135deg, var(--color-primary) 0%, #1d4ed8 100%);
  color: #ffffff !important;
  border: none;
  font-weight: 600;
  padding: 0.75rem 1.75rem;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary-custom:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-outline-custom {
  background: transparent;
  color: var(--text-main) !important;
  border: 2px solid var(--border-color);
  font-weight: 600;
  padding: 0.7rem 1.6rem;
  border-radius: 10px;
}

.btn-outline-custom:hover {
  border-color: var(--color-primary);
  color: var(--color-primary) !important;
  background-color: var(--color-primary-light);
}

/* Custom Card Container */
.custom-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: var(--card-shadow);
  height: 100%;
  position: relative;
  overflow: hidden;
}

.custom-card:hover {
  box-shadow: var(--hover-shadow);
  border-color: var(--border-hover);
  transform: translateY(-3px);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

/* Learning Path Visualizer */
.path-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  padding-left: 2rem;
}

.path-container::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: linear-gradient(to bottom, var(--color-primary), var(--color-secondary));
  border-radius: 2px;
}

.path-step {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

.path-step::before {
  content: '';
  position: absolute;
  left: -29px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid var(--bg-primary);
}

/* Search Input Styling */
.search-box {
  position: relative;
  margin-bottom: 2rem;
}

.search-input {
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  color: var(--text-main);
  border-radius: 12px;
  padding: 0.9rem 1.25rem 0.9rem 3rem;
  font-size: 1rem;
  width: 100%;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-light);
}

.search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 1.2rem;
}

/* Code Block Custom Styling */
.code-window {
  background: var(--code-bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin: 1.25rem 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.code-header {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-size: 0.85rem;
  font-family: var(--font-code);
}

.code-dots {
  display: flex;
  gap: 6px;
}

.code-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

pre code {
  font-family: var(--font-code);
  color: var(--code-text);
  padding: 1.25rem;
  display: block;
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-x: auto;
}

/* Table Styling */
.table-custom {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  margin: 1.5rem 0;
}

.table-custom th {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

body.dark-mode .table-custom th {
  color: var(--color-secondary);
}

.table-custom td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.table-custom tr:last-child td {
  border-bottom: none;
}

/* Quiz Specific Styling */
.quiz-question-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--card-shadow);
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.quiz-option:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.quiz-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
}

.quiz-option.correct-answer {
  border-color: var(--color-success);
  background: var(--color-success-light);
  color: var(--color-success);
}

.quiz-option.wrong-answer {
  border-color: var(--color-danger);
  background: var(--color-danger-light);
  color: var(--color-danger);
}

/* Progress bar inside cards */
.progress-bar-custom {
  height: 10px;
  border-radius: 5px;
  background-color: var(--border-color);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transition: width 0.5s ease-in-out;
}

/* Footer */
footer {
  margin-top: auto;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 3rem 0 1.5rem;
  color: var(--text-muted);
}

.footer-link {
  color: var(--text-muted);
}

.footer-link:hover {
  color: var(--color-primary);
}

/* Media embed wrappers */
.ratio-16x9 {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border-color);
}

audio {
  width: 100%;
  border-radius: 30px;
  margin-top: 1rem;
}

/* Animation utilities */
.fade-in {
  animation: fadeIn 0.4s ease-in;
}

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