:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --accent-primary: #1e40af;
  --accent-secondary: #3b82f6;
  --accent-light: #eff6ff;
  --gold-accent: #d97706;
  --gold-light: #fffbeb;
  --emerald-accent: #059669;
  --emerald-light: #ecfdf5;
  --rose-accent: #e11d48;
  --rose-light: #fff1f2;
  --purple-accent: #7c3aed;
  --purple-light: #f5f3ff;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.1);
}

[data-theme="dark"] {
  --bg-primary: #0b1120;
  --bg-secondary: #1e293b;
  --bg-tertiary: #0f172a;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --accent-primary: #60a5fa;
  --accent-secondary: #3b82f6;
  --accent-light: rgba(59, 130, 246, 0.15);
  --gold-accent: #fbbf24;
  --gold-light: rgba(245, 158, 11, 0.15);
  --emerald-accent: #34d399;
  --emerald-light: rgba(16, 185, 129, 0.15);
  --rose-accent: #fb7185;
  --rose-light: rgba(244, 63, 94, 0.15);
  --purple-accent: #a78bfa;
  --purple-light: rgba(139, 92, 246, 0.15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Heebo', 'Rubik', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  line-height: 1.65;
  direction: rtl;
  text-align: right;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}
::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

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

.sidebar {
  width: 310px;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.main-content {
  flex: 1;
  margin-right: 310px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-content {
    margin-right: 0;
  }
}

/* Top Header */
.top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  backdrop-filter: blur(10px);
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: 0.6rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

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

.nav-tab.active {
  background-color: var(--accent-light);
  color: var(--accent-primary);
  border-color: rgba(59, 130, 246, 0.3);
}

/* Sidebar Lesson Items */
.lesson-nav-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin: 0.2rem 0.6rem;
  border-radius: 0.65rem;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  text-align: right;
  width: calc(100% - 1.2rem);
  background: transparent;
  color: var(--text-primary);
}

.lesson-nav-item:hover {
  background-color: var(--bg-tertiary);
}

.lesson-nav-item.active {
  background-color: var(--accent-light);
  border-color: rgba(59, 130, 246, 0.35);
}

.lesson-badge-num {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

.lesson-nav-item.active .lesson-badge-num {
  background-color: var(--accent-secondary);
  color: #ffffff;
}

.lesson-nav-item.completed .lesson-badge-num {
  background-color: var(--emerald-accent);
  color: #ffffff;
}

/* Cards & Content Blocks */
.content-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.content-card:hover {
  box-shadow: var(--shadow-md);
}

.section-anchor {
  scroll-margin-top: 90px;
}

/* Callout Boxes */
.callout {
  border-radius: 0.85rem;
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
  border-right: 5px solid;
  position: relative;
}

.callout-rule {
  background-color: var(--accent-light);
  border-right-color: var(--accent-secondary);
}

.callout-exception {
  background-color: var(--rose-light);
  border-right-color: var(--rose-accent);
}

.callout-tip {
  background-color: var(--gold-light);
  border-right-color: var(--gold-accent);
}

.callout-example {
  background-color: var(--emerald-light);
  border-right-color: var(--emerald-accent);
}

.callout-formula {
  background-color: var(--purple-light);
  border-right-color: var(--purple-accent);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.98rem;
  margin-bottom: 0.4rem;
}

/* Tables */
.legal-table-wrapper {
  overflow-x: auto;
  margin: 1.1rem 0;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.legal-table th {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 700;
  padding: 0.85rem 1rem;
  border-bottom: 2px solid var(--border-color);
  text-align: right;
}

.legal-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  vertical-align: top;
}

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

.legal-table tr:hover td {
  background-color: rgba(59, 130, 246, 0.03);
}

/* Step Flow / Decision Tree */
.steps-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 1rem 0;
}

.step-box {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0.85rem;
  padding: 1rem 1.15rem;
}

.step-number {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  border-radius: 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Interactive Multiple Choice Question Card */
.question-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.4rem;
  margin: 1.25rem 0;
  position: relative;
  transition: border-color 0.25s ease;
}

.question-card.answered-correct {
  border-color: var(--emerald-accent);
}

.question-card.answered-wrong {
  border-color: var(--rose-accent);
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  text-align: right;
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.5;
  transition: all 0.18s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent-secondary);
  background-color: var(--accent-light);
}

.option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.option-btn.correct {
  background-color: var(--emerald-light);
  border-color: var(--emerald-accent);
  font-weight: 600;
}

.option-btn.correct .option-letter {
  background-color: var(--emerald-accent);
  color: white;
  border-color: var(--emerald-accent);
}

.option-btn.wrong {
  background-color: var(--rose-light);
  border-color: var(--rose-accent);
}

.option-btn.wrong .option-letter {
  background-color: var(--rose-accent);
  color: white;
  border-color: var(--rose-accent);
}

.explanation-box {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  border-radius: 0.75rem;
  background-color: var(--bg-tertiary);
  border-right: 4px solid var(--accent-secondary);
  font-size: 0.94rem;
  animation: fadeIn 0.25s ease-out;
}

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

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-sda { background: #dbeafe; color: #1e40af; }
.badge-sdp { background: #fce7f3; color: #9d174d; }
.badge-rayot { background: #f3e8ff; color: #6b21a8; }
.badge-hot { background: #fef3c7; color: #b45309; }
.badge-skill { background: #d1fae5; color: #065f46; }
.badge-hotzlap { background: #e0e7ff; color: #3730a3; }

[data-theme="dark"] .badge-sda { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
[data-theme="dark"] .badge-sdp { background: rgba(236, 72, 153, 0.2); color: #f9a8d4; }
[data-theme="dark"] .badge-rayot { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; }
[data-theme="dark"] .badge-hot { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
[data-theme="dark"] .badge-skill { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
[data-theme="dark"] .badge-hotzlap { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }

/* Highlight search match */
mark.search-hl {
  background-color: #fde047;
  color: #0f172a;
  padding: 0 3px;
  border-radius: 3px;
}

/* Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #1d4ed8 100%);
  color: white;
  border-radius: 1.25rem;
  padding: 2rem;
  margin-bottom: 1.75rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.hero-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}

/* Subtopic Pills Navigation */
.subtopic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.subtopic-pill {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
}

.subtopic-pill:hover {
  border-color: var(--accent-secondary);
  color: var(--accent-primary);
  background-color: var(--accent-light);
}

/* Modal for PDF Viewer */
.pdf-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}

.pdf-modal-backdrop.active {
  display: flex;
}

.pdf-modal-content {
  background: var(--bg-secondary);
  width: 100%;
  max-width: 1100px;
  height: 90vh;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

