/* Import Premium Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

/* Color System & Global Tokens */
:root {
  --primary-rgb: 37, 99, 235;
  /* Blue */
  --primary: hsl(221, 83%, 53%);
  --primary-dark: hsl(221, 80%, 45%);
  --primary-light: hsl(221, 90%, 94%);
  --secondary: hsl(263, 70%, 50%);
  /* Purple */
  --secondary-light: hsl(263, 80%, 95%);
  --accent: hsl(199, 89%, 48%);
  /* Cyan */
  --accent-light: hsl(199, 100%, 95%);

  --bg-app: hsl(210, 40%, 98%);
  --bg-sidebar: hsl(222, 47%, 11%);
  --bg-card: hsl(0, 0%, 100%);

  --text-primary: hsl(224, 71%, 4%);
  --text-secondary: hsl(215, 25%, 27%);
  --text-muted: hsl(215, 16%, 47%);
  --text-light: hsl(210, 40%, 98%);

  --border-color: rgba(226, 232, 240, 0.8);
  --border-glow: rgba(37, 99, 235, 0.15);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 10px 30px rgba(37, 99, 235, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --sidebar-width: 320px;
  --header-height: 70px;
}

/* Base resets & scrollbar styling */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 18px;
  /* High legibility default */
  color: var(--text-primary);
  font-family: var(--font-sans);
  background-color: var(--bg-app);
}

body {
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.3);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.5);
}

/* Sidebar navigation layout */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-light);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: white;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
  cursor: pointer;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
}

.logo-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 16px;
}

.nav-week-group {
  margin-bottom: 24px;
}

.nav-week-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: hsl(215, 20%, 50%);
  padding: 0 12px 10px 12px;
}

.nav-list {
  list-style: none;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  color: hsl(215, 15%, 75%);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  gap: 10px;
}

.nav-link-content {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.15) 0%, rgba(139, 92, 246, 0.05) 100%);
  border-left: 3px solid var(--primary);
  color: white;
  font-weight: 600;
}

.nav-day-num {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-light);
  flex-shrink: 0;
}

.nav-link.active .nav-day-num {
  background: var(--primary);
}

/* Sidebar progress indicators */
.progress-indicator {
  width: 18px;
  height: 18px;
  border: 2px solid hsl(215, 15%, 55%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: transparent;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  font-weight: 800;
}

.nav-link.active .progress-indicator {
  border-color: rgba(255, 255, 255, 0.6);
}

.progress-indicator.completed {
  background: hsl(142, 72%, 29%);
  /* Green */
  border-color: hsl(142, 72%, 29%) !important;
  color: white;
}

.progress-indicator.completed::before {
  content: '✓';
}

/* Mobile top navbar */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-sidebar);
  color: white;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 150;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.menu-toggle {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Main content wrapper */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 40px;
  display: flex;
  flex-direction: column;
}

/* Progress Tracker Bar at Top */
.global-progress-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 30px;
}

.global-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.progress-percentage-label {
  color: var(--primary);
  font-weight: 800;
}

.global-progress-bar-bg {
  background: hsl(210, 40%, 93%);
  height: 10px;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.global-progress-bar-fill {
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  height: 100%;
  width: 0%;
  /* Set dynamically */
  border-radius: var(--radius-full);
  transition: width var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
}

.educational-narrative h4 {
  margin: 2rem 0 1rem;
  padding: 14px 18px;
  border: 1px solid var(--border-color);
  border-left: 5px solid var(--primary);
  border-radius: 10px;
  background: linear-gradient(90deg,
      var(--primary-light) 0%,
      white 100%);
  color: var(--text-primary);
  font-size: 1.35rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.custom-table th {
  background-color: var(--bg-sidebar);
  color: white;
  padding: 12px 16px;
  font-weight: 600;
  text-align: left;
}

.custom-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.custom-table tbody tr:nth-of-type(even) {
  background-color: rgba(37, 99, 235, 0.02);
}

.custom-table tbody tr:hover {
  background-color: rgba(37, 99, 235, 0.05);
}

.callout-warning {
  background-color: hsl(0, 100%, 97%) !important;
  border-left: 4px solid hsl(0, 84%, 60%) !important;
}

.callout-warning .callout-content strong {
  color: hsl(0, 84%, 40%) !important;
}

.callout-success {
  background-color: hsl(142, 70%, 97%) !important;
  border-left: 4px solid hsl(142, 72%, 29%) !important;
}

.callout-success .callout-content strong {
  color: hsl(142, 72%, 25%) !important;
}

.key-badge {
  background-color: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 0.85rem;
  color: #334155;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.term-definition {
  margin: 20px 0;
  border-left: 4px solid var(--accent);
  padding-left: 18px;
  background: rgba(6, 182, 212, 0.03);
  padding-top: 12px;
  padding-bottom: 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.term-title {
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.term-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Single-page Tabbed Visibility */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: tabFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Welcome Hero Card */
.hero-card {
  background: linear-gradient(135deg, hsl(222, 47%, 11%) 0%, hsl(222, 40%, 18%) 100%);
  color: white;
  padding: 48px;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.15) 0%, transparent 70%);
  border-radius: var(--radius-full);
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(37, 99, 235, 0.4);
  color: var(--primary-light);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 18px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.1rem;
  line-height: 1.6;
  color: #94a3b8;
  margin-bottom: 28px;
}

.hero-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 24px;
  margin-bottom: 30px;
}

.hero-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 600;
}

.meta-val {
  font-size: 1rem;
  font-weight: 600;
  color: #f1f5f9;
}

/* Day Section Structure */
.day-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition-normal);
}

.day-section:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.day-header {
  border-bottom: 2px solid var(--bg-app);
  padding-bottom: 24px;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}

.day-tag {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: 6px;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: inline-block;
}

.day-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.day-meta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.day-meta-badge {
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-app);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 4px;
}

/* Content Blocks */
.day-content {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.lo-card {
  border-left: 4px solid var(--secondary);
  background: var(--bg-app);
  padding: 20px 24px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: 24px;
}

.lo-card-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.lo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lo-item {
  font-size: 0.95rem;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
}

.lo-item::before {
  content: '✓';
  color: var(--secondary);
  font-weight: 800;
}

/* Rich Explanatory Text */
.educational-narrative {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.educational-narrative h4 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-top: 10px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.educational-narrative p {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.educational-narrative ul,
.educational-narrative ol {
  margin-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.educational-narrative li {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.educational-narrative strong {
  color: var(--text-primary);
}

/* Semantic Figures */
.media-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin: 16px 0;
}

figure {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

figure:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

figure img {
  width: 100%;
  max-width: 600px;
  height: auto;
  display: block;
  margin: 0 auto;
}

figcaption {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
}

/* Callout Box (Alerts) */
.callout {
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  padding: 20px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.callout-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.callout-content p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Practical Activity Styling */
.activity-card {
  background: linear-gradient(135deg, #ffffff 0%, hsl(210, 40%, 98%) 100%);
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 30px;
  box-shadow: var(--shadow-glow);
  margin-top: 20px;
}

.activity-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.activity-badge {
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 4px;
}

.activity-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.activity-steps {
  list-style: decimal;
  margin-left: 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.activity-steps li {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Show/Hide Toggle Button & Collapsible Container */
.btn-toggle {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-toggle:hover {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.answer-wrapper {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 0;
}

.answer-wrapper.expanded {
  max-height: 1500px;
  /* Large enough to fit any answer */
}

.model-answer {
  background: var(--secondary-light);
  border-left: 4px solid var(--secondary);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: 24px;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
}

.model-answer h5 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 12px;
}

.model-answer ol {
  margin-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.model-answer li {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Bottom Navigation Buttons */
.bottom-nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 40px;
  padding-top: 30px;
  border-top: 2px solid var(--border-color);
  gap: 16px;
  flex-wrap: wrap;
}

.bottom-nav-left,
.bottom-nav-right {
  display: flex;
  gap: 12px;
}

.btn-nav {
  background: white;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-nav:hover:not(:disabled) {
  background: var(--bg-app);
  border-color: var(--text-secondary);
  color: var(--text-primary);
  transform: translateY(-2px);
}

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

.btn-nav.btn-primary-action {
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.btn-nav.btn-primary-action:hover:not(:disabled) {
  background: var(--primary-dark);
  color: white;
}

.btn-nav.btn-completed-action {
  background: hsl(142, 72%, 29%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.btn-nav.btn-completed-action:hover:not(:disabled) {
  background: hsl(142, 72%, 25%);
  color: white;
}

/* Footer Section */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding: 30px;
  background: white;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 280px;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 17px;
  }

  .mobile-header {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
  }

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

  .main-wrapper {
    margin-left: 0;
    padding-top: var(--header-height);
  }

  .main-content {
    padding: 20px;
    gap: 30px;
  }

  .hero-card {
    padding: 24px;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .day-section {
    padding: 24px;
  }

  .day-title {
    font-size: 1.4rem;
  }

  .bottom-nav-container {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .bottom-nav-left,
  .bottom-nav-right {
    flex-direction: column;
  }

  .btn-nav {
    justify-content: center;
  }
}