/* ================================================================
   main.css — Premium Theme, Typography, Layout & Component Styles
   ================================================================ */

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

/* ---------- Theme Variables ---------- */
:root {
  /* Light theme (default) — premium tech */
  --bg-primary: #fafafa;
  --bg-secondary: #f0f0f0;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f5f5f5;
  --text-primary: #1a1d27;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-light: #ecfdf5;
  --accent-dark: #059669;
  --success: #10b981;
  --success-light: #d1fae5;
  --success-dark: #059669;
  --error: #ef4444;
  --error-light: #fee2e2;
  --error-dark: #dc2626;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-dark: #d97706;
  --border: #e2e5ef;
  --border-light: #eef1f6;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.09);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-height: 64px;
  --max-width: 1040px;
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #121212;
    --bg-surface: #050505;
    --bg-surface-hover: #1c1c1e;
    --text-primary: #e4e9f2;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #10b981;
    --accent-hover: #34d399;
  --accent-light: #064e3b;
  --success: #34d399;
    --success-light: #064e3b;
    --success-dark: #10b981;
    --error: #f87171;
    --error-light: #450a0a;
    --error-dark: #ef4444;
    --warning: #fbbf24;
    --warning-light: #451a03;
    --warning-dark: #f59e0b;
    --border: #222222;
    --border-light: #161616;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.6);
}

/* System preference auto-detection */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
  --bg-primary: #000000;
  --bg-secondary: #121212;
  --bg-surface: #050505;
  --bg-surface-hover: #1c1c1e;
    --text-primary: #e4e9f2;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
  --accent: #10b981;
  --accent-hover: #34d399;
  --accent-light: #064e3b;
    --success: #34d399;
    --success-light: #064e3b;
    --success-dark: #10b981;
    --error: #f87171;
    --error-light: #450a0a;
    --error-dark: #ef4444;
    --warning: #fbbf24;
    --warning-light: #451a03;
    --warning-dark: #f59e0b;
  --border: #222222;
  --border-light: #161616;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.6);
  }
}

/* ---------- RTL Font Overrides ---------- */
[dir="rtl"] {
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, 'Cairo', 'Tahoma', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace;
}

/* ---------- Base Typography ---------- */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

img {
  max-width: 100%;
  height: auto;
}

/* ---------- Focus & Selection ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-light);
  color: var(--accent-dark);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 99px;
  transition: background var(--transition);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ---------- Layout Helpers ---------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-wrapper {
  min-height: calc(100vh - var(--nav-height));
  padding-top: calc(var(--nav-height) + 2rem);
  padding-bottom: 3rem;
}

.section-title {
  font-size: clamp(1.25rem, 3vw, 1.85rem);
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.text-center {
  text-align: center;
}

/* ---------- Navigation / Header ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.header-inner {
  display: flex;
  align-items: center;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  gap: 1.25rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.02em;
  transition: color var(--transition), transform var(--transition);
}

.site-logo:hover {
  color: var(--accent);
}

.logo-img {
  height: 1.5em;
  width: auto;
  vertical-align: middle;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  list-style: none;
}

[dir="rtl"] .nav-links {
  margin-right: auto;
  margin-left: 0;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  position: relative;
}

.nav-links a:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.nav-links a.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  position: relative;
  letter-spacing: 0.01em;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: transparent;
}

.btn-success:hover {
  background: var(--success-dark);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .btn-success:hover {
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  box-shadow: none;
  transform: none;
}

.btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 0.8rem 2rem;
  font-size: 1rem;
}

.btn-icon {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  font-size: 1.1rem;
  border-radius: 999px;
}

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

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-body {
  padding: 1.75rem;
}

/* Cards Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.5rem;
}

[dir="rtl"] .card-grid {
  direction: rtl;
}

/* ---------- Progress Bars ---------- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: left center;
}

[dir="rtl"] .progress-fill {
  transform-origin: right center;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: all var(--transition);
}

.badge-accent {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-secondary);
  border-radius: 999px;
  padding: 2px;
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
}

.theme-btn svg {
  display: block;
}

.theme-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-surface-hover);
}

.theme-btn.active {
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.theme-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Language Toggle ---------- */
.lang-btn {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  text-transform: uppercase;
}

.lang-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.lang-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

[dir="rtl"] .toast-container {
  right: auto;
  left: 1.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  color: var(--text-primary);
  pointer-events: auto;
  animation: slide-up 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
  max-width: 380px;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

[dir="rtl"] .toast::before {
  left: auto;
  right: 0;
  border-radius: 2px 0 0 2px;
}

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
  transition: border-color var(--transition);
}

.site-footer a {
  color: var(--text-secondary);
}

.site-footer a:hover {
  color: var(--accent);
}

/* ---------- Loading State ---------- */
.loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 2.5rem auto;
}

/* Skeleton loading placeholder */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-secondary) 25%,
    var(--bg-surface-hover) 50%,
    var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-title {
  height: 1.5rem;
  width: 70%;
  margin-bottom: 1rem;
}

.skeleton-card {
  height: 180px;
  border-radius: var(--radius-lg);
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* ---------- User Panel ---------- */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.panel-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.user-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 2000;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

[dir="rtl"] .user-panel {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
}

.user-panel.open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.panel-avatar {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 1rem;
}

.panel-level-section {
  text-align: center;
  margin-bottom: 1.5rem;
}

.panel-level-badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.25rem 1rem;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.panel-level-label {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.panel-level-next {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.panel-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.panel-stat {
  text-align: center;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.5rem;
  transition: background var(--transition);
}

.panel-stat-value {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
}

.panel-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.panel-section {
  margin-bottom: 1.5rem;
}

.panel-section h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.panel-badges .badge-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  transition: all var(--transition);
}

.panel-course-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
  transition: border-color var(--transition);
}

.panel-course-item:last-child {
  border-bottom: none;
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---------- HERO (Home) ---------- */
.hero {
  padding: 4rem 0 3rem;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  bottom: -350px;
  left: 50%;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.35) 0%, rgba(16, 185, 129, 0.12) 40%, transparent 65%);
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  animation: sunrise 1.8s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.hero-title {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  line-height: 1.12;
  margin-bottom: 1rem;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 auto 1.75rem;
  line-height: 1.65;
}

[dir="rtl"] .hero-content {
  text-align: right;
}

/* ---------- Feature Icon (Home) ---------- */
.feature-icon {
  font-size: 2.4rem;
  margin-bottom: 0.85rem;
  display: inline-block;
}

.features-section {
  padding-top: 1rem;
}

/* ---------- Course Card (Courses page) ---------- */
.course-card-icon {
  font-size: 2.2rem;
  margin-bottom: 0.85rem;
  display: inline-block;
}

.course-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0.5rem 0;
}

.course-card-bar {
  margin: 0.85rem 0;
}

/* ---------- Track Page Stats ---------- */
.track-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-light);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ---------- Progress Card (Track) ---------- */
.progress-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.progress-card:hover {
  border-color: var(--accent-light);
  box-shadow: var(--shadow-md);
}

.progress-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

/* ---------- Badge Item (Track) ---------- */
.badge-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin: 0.25rem;
  transition: all var(--transition);
}

.badge-item:hover {
  border-color: var(--accent-light);
  box-shadow: var(--shadow-sm);
}

.badge-item.locked {
  opacity: 0.4;
  filter: grayscale(0.8);
}

/* ---------- Checklist Item (Track) ---------- */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}

.checklist-item:last-child {
  border-bottom: none;
}

.check-icon {
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

/* ---------- Scroll Progress Bar (Viewer) ---------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 1001;
  background: transparent;
}

.scroll-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  width: 0%;
  transition: width 0.08s linear;
  border-radius: 0 2px 2px 0;
}

/* ---------- Viewer Wrapper (Viewer) ---------- */
.viewer-wrapper {
  min-height: calc(100vh - var(--nav-height));
  padding-top: calc(var(--nav-height) + 1.5rem);
  padding-bottom: 3rem;
}

.viewer-wrapper .container {
  max-width: 1600px;
}

.viewer-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.viewer-main {
  flex: 1 1 0;
  min-width: 0;
}

.viewer-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--nav-height) + 1.5rem);
}

.viewer-ad {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--nav-height) + 1.5rem);
}

.ad-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  overflow: hidden;
}

.ad-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-light);
}

.ad-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.ad-image {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  display: block;
}

.ad-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.sidebar-lessons {
  margin-bottom: 1rem;
}

.sidebar-lesson-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.3;
}

[dir="rtl"] .sidebar-lesson-item {
  text-align: right;
}

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

.sidebar-lesson-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

@media (max-width: 900px) {
  .viewer-layout {
    flex-direction: column;
  }
  .viewer-sidebar {
    width: 100%;
    position: static;
  }
  .viewer-ad {
    width: 100%;
    position: static;
  }
}

.viewer-breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.viewer-breadcrumb a {
  color: var(--text-muted);
  transition: color var(--transition);
}

.viewer-breadcrumb a:hover {
  color: var(--accent);
}

.viewer-title {
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}

.viewer-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 1000px;
  min-height: 280px;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.viewer-content.animate-scale-in {
  animation: scale-in 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Markdown rendered styles */
.viewer-content h1 {
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  margin: 1.75rem 0 0.75rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.45rem;
}

.viewer-content h2 {
  font-size: clamp(1.2rem, 2.5vw, 1.4rem);
  margin: 1.5rem 0 0.5rem;
}

.viewer-content h3 {
  font-size: clamp(1.05rem, 2vw, 1.15rem);
  margin: 1.25rem 0 0.5rem;
}

.viewer-content p {
  margin-bottom: 0.9rem;
  line-height: 1.75;
}

.viewer-content ul,
.viewer-content ol {
  margin: 0.5rem 0 1rem 1.5rem;
}

[dir="rtl"] .viewer-content ul,
[dir="rtl"] .viewer-content ol {
  margin-left: 0;
  margin-right: 1.5rem;
}

.viewer-content li {
  margin-bottom: 0.3rem;
}

.viewer-content pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  font-size: 0.88rem;
  line-height: 1.65;
  position: relative;
  direction: ltr;
  text-align: left;
}

.viewer-content pre::before {
  content: attr(data-language);
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-radius: 0 var(--radius-md) 0 var(--radius-sm);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.viewer-content pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
  font-size: inherit;
  font-family: var(--font-mono);
}

.viewer-content :not(pre) > code {
  background: var(--bg-secondary);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--accent);
  direction: ltr;
}

.viewer-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.viewer-content th,
.viewer-content td {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
}

.viewer-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.viewer-content blockquote {
  border-inline-start: 4px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: var(--bg-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.viewer-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.75rem 0;
}

.viewer-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 1rem 0;
}

.viewer-content strong {
  font-weight: 700;
}

/* ---------- Quiz Styles (Viewer) ---------- */
.quiz-question {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.quiz-question:last-child {
  border-bottom: none;
}

.quiz-question-text {
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s ease;
  border: 1.5px solid var(--border);
  background: var(--bg-primary);
  position: relative;
}

.quiz-option:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateX(6px);
}

[dir="rtl"] .quiz-option:hover {
  transform: translateX(-6px);
}

.quiz-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.quiz-option .quiz-option-control {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: var(--bg-surface);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  position: relative;
}

.quiz-option .quiz-option-control::after {
  content: '';
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-option input:checked ~ .quiz-option-control {
  border-color: var(--accent);
  background: var(--accent-light);
}

.quiz-option input:checked ~ .quiz-option-control::after {
  transform: scale(1);
}

.quiz-option input[type="checkbox"] ~ .quiz-option-control {
  border-radius: 4px;
}

.quiz-option input[type="checkbox"] ~ .quiz-option-control::after {
  border-radius: 1px;
  width: 0.5rem;
  height: 0.5rem;
}

.quiz-option .quiz-option-label {
  flex: 1;
  font-size: 0.95rem;
}

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

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

.quiz-option.correct .quiz-option-control::after {
  background: var(--success);
  transform: scale(1);
}

.quiz-option.incorrect {
  background: var(--error-light);
  border-color: var(--error);
  color: var(--error-dark);
}

.quiz-option.incorrect .quiz-option-control {
  border-color: var(--error);
  background: var(--error-light);
}

.quiz-option.incorrect .quiz-option-control::after {
  background: var(--error);
  transform: scale(1);
}

.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.75;
}

.quiz-result {
  text-align: center;
  padding: 1.75rem;
  margin-top: 1.5rem;
  border-radius: var(--radius-md);
  animation: scale-in 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.quiz-result.passed {
  background: var(--success-light);
  border: 1px solid var(--success);
}

.quiz-result.failed {
  background: var(--error-light);
  border: 1px solid var(--error);
}

.quiz-result-score {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
}

.quiz-result-label {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 0.35rem;
}

.quiz-result-points {
  margin-top: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ---------- Viewer Footer ---------- */
.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.75rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.viewer-nav {
  display: flex;
  gap: 0.5rem;
}

/* ---------- Feature Rows (Home) ---------- */
.feature-row {
  display: flex;
  align-items: center;
  gap: 3rem;
  margin-bottom: 4rem;
}

.feature-row-reverse {
  flex-direction: row-reverse;
}

.feature-image {
  flex: 0 0 300px;
  position: relative;
}

.feature-image::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 340px;
  height: 340px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(16, 185, 129, 0.35) 0%, rgba(16, 185, 129, 0.1) 50%, transparent 75%);
  border-radius: 50%;
  pointer-events: none;
}

.feature-image img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  position: relative;
}

.feature-content {
  flex: 1;
}

.feature-content h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  font-style: italic;
}

.feature-content p {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  font-style: italic;
}

@media (max-width: 768px) {
  .feature-row,
  .feature-row-reverse {
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
  }

  .feature-image {
    flex: 0 0 auto;
    max-width: 240px;
  }
}

/* ---------- Home Courses Section ---------- */
.home-courses-section {
  padding: 4rem 0;
  text-align: center;
  position: relative;
}

.home-courses-title {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 800;
  margin-bottom: 2.5rem;
  letter-spacing: -0.02em;
  position: relative;
  display: inline-block;
  color: var(--text-primary);
  text-shadow: 0 0 40px rgba(16, 185, 129, 0.3), 0 0 80px rgba(16, 185, 129, 0.15);
  animation: glow-pulse-title 3s ease-in-out infinite;
}

@keyframes glow-pulse-title {
  0%, 100% {
    text-shadow: 0 0 40px rgba(16, 185, 129, 0.3), 0 0 80px rgba(16, 185, 129, 0.15);
  }
  50% {
    text-shadow: 0 0 60px rgba(16, 185, 129, 0.5), 0 0 120px rgba(16, 185, 129, 0.25), 0 0 180px rgba(16, 185, 129, 0.1);
  }
}

.home-courses-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.home-course-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.home-course-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: radial-gradient(ellipse at center bottom, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.home-course-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.2), var(--shadow-lg);
  border-color: rgba(16, 185, 129, 0.3);
}

.home-course-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  position: relative;
}

.home-course-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  position: relative;
}

.home-course-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 1rem;
  position: relative;
  flex: 1;
}

.home-course-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  position: relative;
}

@media (max-width: 768px) {
  .home-courses-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .home-courses-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Responsive Breakpoints ---------- */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }

  .nav-links a span {
    display: none;
  }

  .nav-links a {
    padding: 0.5rem 0.6rem;
    font-size: 1.1rem;
  }

  .header-inner {
    gap: 0.5rem;
    padding: 0 1rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .card-body {
    padding: 1.25rem;
  }

  .viewer-content {
    padding: 1.25rem;
  }

  .track-stats {
    grid-template-columns: 1fr;
  }

  .user-panel {
    width: 100vw;
  }

  .hero {
    padding: 2.5rem 0 1.5rem;
  }

  .site-logo {
    font-size: 1rem;
    color: var(--accent);
  }

  .btn-lg {
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
