/* ==========================================================================
   MINI LMS - PERSIAN / RTL DESIGN SYSTEM & STYLES (LIGHT & DARK THEMES)
   ========================================================================== */

:root {
  /* Common Accent Tokens */
  --accent-cyan: #0891b2;
  --accent-indigo: #4f46e5;
  --accent-purple: #7c3aed;
  --accent-emerald: #059669;
  --accent-rose: #e11d48;
  --accent-amber: #d97706;

  --gradient-brand: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #0891b2 100%);
  --gradient-card: linear-gradient(135deg, rgba(79, 70, 229, 0.05) 0%, rgba(8, 145, 178, 0.05) 100%);
  --gradient-gold: linear-gradient(135deg, #d97706 0%, #f59e0b 50%, #b45309 100%);

  /* Default / Light Theme Palette */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  --bg-glass: rgba(0, 0, 0, 0.03);
  --border-glass: rgba(0, 0, 0, 0.08);
  --border-glow: rgba(79, 70, 229, 0.3);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 4px 14px rgba(79, 70, 229, 0.25);

  /* Persian Typography: Vazirmatn */
  --font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme Overrides */
[data-theme="dark"] {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(31, 41, 55, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.35);

  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #06b6d4 100%);
  --gradient-gold: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #d97706 100%);

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  direction: rtl;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.06) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(8, 145, 178, 0.05) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(124, 58, 237, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.7;
  overflow-x: hidden;
  direction: rtl;
  text-align: right;
  transition: background-color 0.3s ease, color 0.3s ease;
}

[data-theme="dark"] body {
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(6, 182, 212, 0.1) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(168, 85, 247, 0.08) 0px, transparent 50%);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.25);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.4);
}

/* --------------------------------------------------------------------------
   VIEW TOGGLING
   -------------------------------------------------------------------------- */
.view-section {
  display: none;
  animation: fadeInView 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view-section.active {
  display: block;
}

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

/* --------------------------------------------------------------------------
   NAVBAR & HEADER
   -------------------------------------------------------------------------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--border-glass);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .navbar {
  background: rgba(11, 15, 25, 0.88);
  box-shadow: none;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo-badge {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo-img {
  height: 38px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(79, 70, 229, 0.25));
  transition: transform 0.2s ease;
}

.brand-logo-img:hover {
  transform: scale(1.05);
}

.brand-text h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.3;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--accent-indigo);
  font-weight: 700;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-nav {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
}

.btn-nav:hover {
  border-color: var(--border-glow);
  background: rgba(79, 70, 229, 0.05);
}

.btn-nav.primary {
  background: var(--gradient-brand);
  border: none;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn-nav.primary:hover {
  filter: brightness(1.08);
}

.nav-user-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: #fff;
  font-weight: 800;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.user-info {
  display: flex;
  flex-direction: column;
  text-align: right;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.user-meta {
  font-size: 0.72rem;
  color: var(--accent-indigo);
  font-weight: 600;
}

.btn-logout-icon {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-logout-icon:hover {
  color: var(--accent-rose);
  background: rgba(225, 29, 72, 0.1);
}

.btn-icon {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.55rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--border-glow);
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* --------------------------------------------------------------------------
   CATALOG VIEW (HERO & COURSE CARDS)
   -------------------------------------------------------------------------- */
.hero-banner {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.08) 0%, rgba(124, 58, 237, 0.05) 50%, rgba(8, 145, 178, 0.06) 100%);
  border-bottom: 1px solid var(--border-glass);
  padding: 3rem 2rem;
  text-align: center;
}

.hero-content {
  max-width: 850px;
  margin: 0 auto;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(79, 70, 229, 0.1);
  border: 1px solid rgba(79, 70, 229, 0.25);
  color: var(--accent-indigo);
  padding: 0.35rem 0.95rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--text-main);
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.catalog-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

.catalog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.catalog-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.catalog-title-group h3 {
  font-size: 1.35rem;
  font-weight: 800;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 2rem;
}

.course-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-glow);
}

.course-card-cover {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
}

.course-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.course-card:hover .course-card-cover img {
  transform: scale(1.05);
}

.course-badge-overlay {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.course-duration-overlay {
  position: absolute;
  bottom: 14px;
  left: 14px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.course-card-body {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.course-card-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

.course-card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.25rem;
  flex: 1;
}

.course-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  border-top: 1px solid var(--border-glass);
}

.course-instructor-info {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-start-course {
  background: var(--gradient-brand);
  color: #fff;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  box-shadow: var(--shadow-glow);
  transition: var(--transition-fast);
  font-family: inherit;
}

.btn-start-course:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   CLASSROOM TOPBAR & LAYOUT
   -------------------------------------------------------------------------- */
.classroom-topbar {
  max-width: 1400px;
  margin: 1.25rem auto 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.active-course-badge {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 2rem 2.5rem 2rem;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
}

@media (max-width: 1100px) {
  .main-container {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
}

/* --------------------------------------------------------------------------
   PRIMARY VIDEO PLAYER COLUMN
   -------------------------------------------------------------------------- */
.player-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.video-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  position: relative;
}

.video-frame-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

video#lessonVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Video Watermark / Verification Overlay */
.video-watermark {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  z-index: 10;
}

.video-watermark span.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Video Controls & Progress Bar */
.video-statusbar {
  padding: 1.15rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  border-top: 1px solid var(--border-glass);
  background: var(--bg-secondary);
}

[data-theme="dark"] .video-statusbar {
  background: rgba(15, 23, 42, 0.95);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}

.progress-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.progress-percent {
  font-weight: 800;
  color: var(--accent-indigo);
  direction: ltr;
}

.custom-progress-track {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

[data-theme="dark"] .custom-progress-track {
  background: rgba(255, 255, 255, 0.1);
}

.custom-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-brand);
  border-radius: var(--radius-full);
  transition: width 0.2s linear;
  box-shadow: 0 0 8px rgba(79, 70, 229, 0.4);
}

.video-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.action-left, .action-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-control {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
}

.btn-control:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: var(--border-glow);
  transform: translateY(-1px);
}

[data-theme="dark"] .btn-control:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-control.primary {
  background: var(--gradient-brand);
  border: none;
  font-weight: 700;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn-control.primary:hover {
  filter: brightness(1.08);
}

/* Play icon flip for RTL video playback */
#playIcon[data-lucide="play"],
.play-icon-rtl {
  transform: scaleX(-1);
  display: inline-block;
}

/* Lesson Details Section */
.lesson-meta-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
}

.lesson-badge-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-module {
  background: rgba(79, 70, 229, 0.1);
  border: 1px solid rgba(79, 70, 229, 0.25);
  color: var(--accent-indigo);
}

.badge-level {
  background: rgba(8, 145, 178, 0.1);
  border: 1px solid rgba(8, 145, 178, 0.25);
  color: var(--accent-cyan);
}

.badge-time {
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.25);
  color: var(--accent-amber);
}

.lesson-title {
  font-size: 1.55rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
  line-height: 1.4;
  color: var(--text-main);
}

.lesson-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  width: 100%;
  padding-bottom: 2px;
}

.tabs-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 0.75rem 1.1rem;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: var(--transition-fast);
  font-family: inherit;
}

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

.tab-btn.active {
  color: var(--accent-indigo);
}

[data-theme="dark"] .tab-btn.active {
  color: #fff;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--gradient-brand);
  border-radius: var(--radius-full);
}

.tab-content-panel {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.tab-content-panel.active {
  display: block;
}

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

/* --------------------------------------------------------------------------
   TAB PANELS: OVERVIEW, NOTES, EXAM, CERTIFICATE
   -------------------------------------------------------------------------- */
.key-takeaways {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.takeaway-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  padding: 1.1rem;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.takeaway-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.takeaway-card h4 {
  font-size: 0.98rem;
  margin-bottom: 0.45rem;
  color: var(--accent-indigo);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 800;
}

.takeaway-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Notes Tab */
.notes-input-box {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.notes-input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
}

.notes-input:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
}

.note-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: var(--transition-fast);
}

.note-item:hover {
  border-color: var(--border-glow);
}

.note-timestamp {
  background: rgba(79, 70, 229, 0.12);
  color: var(--accent-indigo);
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid rgba(79, 70, 229, 0.25);
  direction: ltr;
}

.note-timestamp:hover {
  background: rgba(79, 70, 229, 0.2);
}

.note-text {
  font-size: 0.9rem;
  color: var(--text-main);
  flex: 1;
}

.btn-delete-note {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.25rem;
  transition: var(--transition-fast);
}

.btn-delete-note:hover {
  color: var(--accent-rose);
}

/* --------------------------------------------------------------------------
   EXAM SECTION (10 QUESTIONS DYNAMIC)
   -------------------------------------------------------------------------- */
.exam-intro-box {
  background: rgba(79, 70, 229, 0.06);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.exam-intro-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.exam-questions-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.exam-question-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  transition: var(--transition-fast);
}

.exam-question-card:hover {
  border-color: var(--border-glow);
}

.exam-q-header {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.exam-q-num {
  background: var(--accent-indigo);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.exam-q-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.6;
}

.exam-options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.exam-option-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.exam-option-label:hover {
  border-color: var(--accent-indigo);
  background: rgba(79, 70, 229, 0.04);
}

.exam-option-label input[type="radio"] {
  accent-color: var(--accent-indigo);
  width: 18px;
  height: 18px;
}

.quiz-feedback {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  display: none;
  font-weight: 700;
}

.quiz-feedback.success {
  display: block;
  background: rgba(5, 150, 105, 0.1);
  border: 1px solid rgba(5, 150, 105, 0.3);
  color: var(--accent-emerald);
}

.quiz-feedback.error {
  display: block;
  background: rgba(225, 29, 72, 0.1);
  border: 1px solid rgba(225, 29, 72, 0.3);
  color: var(--accent-rose);
}

/* --------------------------------------------------------------------------
   CERTIFICATE LOCKED STATE & PREVIEW
   -------------------------------------------------------------------------- */
.cert-locked-box {
  background: var(--bg-primary);
  border: 2px dashed rgba(217, 119, 6, 0.35);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cert-lock-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: rgba(217, 119, 6, 0.12);
  border: 2px solid rgba(217, 119, 6, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 20px rgba(217, 119, 6, 0.2);
}

.cert-locked-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.cert-locked-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 580px;
  line-height: 1.8;
  margin-bottom: 1.25rem;
}

.cert-locked-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.25);
  color: var(--accent-indigo);
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
}

.certificate-preview-box {
  border: 3px double rgba(217, 119, 6, 0.4);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2rem;
  background: linear-gradient(135deg, #ffffff 0%, #fffdf0 100%);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  color: #1e293b;
}

[data-theme="dark"] .certificate-preview-box {
  background: linear-gradient(135deg, rgba(20, 24, 45, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  color: #fff;
}

.cert-logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.25rem;
}

.cert-logo-img {
  height: 64px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(217, 119, 6, 0.3));
}

.cert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: var(--gradient-gold);
  color: #fff;
  font-size: 2rem;
  box-shadow: 0 0 25px rgba(217, 119, 6, 0.3);
  margin-bottom: 1.25rem;
}

.cert-title {
  font-size: 1.65rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #b45309;
}

[data-theme="dark"] .cert-title {
  color: #fbbf24;
}

.cert-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.cert-student-name {
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--text-main);
  text-decoration: underline;
  text-decoration-color: var(--accent-indigo);
  text-underline-offset: 8px;
  margin-bottom: 1.25rem;
}

.cert-details-grid {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.cert-pill-item {
  font-size: 0.85rem;
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.2);
  color: var(--accent-indigo);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.cert-course-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.75rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.cert-meta-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-glass);
  font-size: 0.88rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   RIGHT SIDEBAR: LEARNER PASSPORT & DETAILS
   -------------------------------------------------------------------------- */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card-widget {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-lg);
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.15rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-glass);
}

.widget-title {
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Learner Profile Card */
.learner-profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.5rem 0;
}

.profile-avatar-large {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-full);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  font-weight: 800;
  color: #fff;
  box-shadow: var(--shadow-glow);
  margin-bottom: 0.85rem;
  border: 3px solid #ffffff;
}

.profile-full-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.profile-meta-line {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.profile-phone-text {
  font-size: 0.88rem;
  color: var(--accent-indigo);
  background: rgba(79, 70, 229, 0.1);
  border: 1px solid rgba(79, 70, 229, 0.2);
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-full);
  margin-bottom: 1rem;
  display: inline-block;
  font-weight: 700;
  direction: ltr;
}

.profile-details-mini {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-size: 0.82rem;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.profile-details-mini span {
  color: var(--text-muted);
}

.profile-stats-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.profile-stat-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  text-align: center;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  direction: ltr;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 0.2rem;
}

/* --------------------------------------------------------------------------
   AUTHENTICATION MODAL & TABS
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100%;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-lg);
  max-width: 460px;
  width: 100%;
  margin: auto;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 2rem 1.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 35px rgba(79, 70, 229, 0.15);
  position: relative;
  box-sizing: border-box;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  text-align: right;
  direction: rtl;
}

[data-theme="dark"] .modal-card {
  background: linear-gradient(135deg, rgba(23, 29, 45, 0.98) 0%, rgba(13, 17, 30, 0.98) 100%);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 35px rgba(99, 102, 241, 0.25);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  cursor: pointer;
  color: var(--text-dim);
  padding: 0.35rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-main);
  background: var(--bg-glass);
}

.auth-tabs {
  display: flex;
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 1.5rem;
  gap: 4px;
}

.auth-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: var(--transition-fast);
  font-family: inherit;
}

.auth-tab-btn.active {
  background: var(--bg-secondary);
  color: var(--accent-indigo);
  box-shadow: var(--shadow-sm);
}

.auth-form-wrap {
  display: none;
}

.auth-form-wrap.active {
  display: block;
}

.modal-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(79, 70, 229, 0.1);
  border: 1px solid rgba(79, 70, 229, 0.25);
  color: var(--accent-indigo);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
  min-width: 0;
  width: 100%;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: start;
  width: 100%;
  margin-bottom: 0;
}

.form-row > .form-group {
  min-width: 0;
  width: 100%;
  margin-bottom: 1rem;
}

@media (max-width: 540px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.form-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
  width: 100%;
  text-align: right;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-input {
  width: 100%;
  height: 44px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0 0.85rem;
  color: #0f172a;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
  box-sizing: border-box;
}

[data-theme="dark"] .form-input {
  background: rgba(15, 23, 42, 0.6);
  border-color: var(--border-glass);
  color: #fff;
}

.form-input:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background: #ffffff;
}

[data-theme="dark"] .form-input:focus {
  background: rgba(15, 23, 42, 0.9);
}

/* Iran +98 Fixed Phone Wrapper */
.iran-phone-wrapper {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 44px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  direction: ltr;
  box-sizing: border-box;
  transition: var(--transition-fast);
}

[data-theme="dark"] .iran-phone-wrapper {
  background: rgba(15, 23, 42, 0.6);
  border-color: var(--border-glass);
}

.iran-phone-wrapper:focus-within {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background: #ffffff;
}

[data-theme="dark"] .iran-phone-wrapper:focus-within {
  background: rgba(15, 23, 42, 0.9);
}

.iran-phone-prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0 0.65rem;
  background: rgba(79, 70, 229, 0.08);
  border-right: 1px solid #cbd5e1;
  font-weight: 800;
  color: var(--accent-indigo);
  font-size: 0.82rem;
  user-select: none;
  flex-shrink: 0;
}

[data-theme="dark"] .iran-phone-prefix {
  border-right-color: var(--border-glass);
}

.iran-phone-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0 0.65rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: #0f172a;
  outline: none;
  direction: ltr;
  text-align: left;
  box-sizing: border-box;
}

[data-theme="dark"] .iran-phone-input {
  color: #fff;
}

.btn-submit-enroll {
  width: 100%;
  background: var(--gradient-brand);
  color: #fff;
  border: none;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-glow);
  margin-top: 0.5rem;
  transition: var(--transition-fast);
  font-family: inherit;
}

.btn-submit-enroll:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   ADMIN DASHBOARD & DRAWER
   -------------------------------------------------------------------------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: 0.3s ease;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.admin-drawer {
  position: fixed;
  top: 0;
  left: -850px;
  right: auto;
  width: 100%;
  max-width: 850px;
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-glass);
  z-index: 95;
  box-shadow: 15px 0 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transition: left 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: right;
}

.admin-drawer.open {
  left: 0;
}

.admin-drawer-header {
  padding: 1.25rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-glass);
}

.admin-drawer-header h3 {
  font-size: 1.2rem;
  font-weight: 800;
}

.admin-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Stats Overview Cards */
.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  padding: 1.15rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-card-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card-info {
  display: flex;
  flex-direction: column;
}

.stat-card-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-card-number {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text-main);
}

.admin-section-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.admin-section-title {
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.course-stats-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.course-stat-row {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-actions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.admin-table-wrap {
  overflow-x: auto;
  max-height: 380px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}

.admin-table th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-weight: 800;
  text-align: right;
  z-index: 5;
}

.admin-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-main);
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  right: auto;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glow);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideInLeft 0.3s ease;
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

.spin-animation {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   COMPREHENSIVE MOBILE RESPONSIVE MEDIA QUERIES (RTL / MOBILE-FIRST)
   ========================================================================== */

/* 1. Tablet & Medium Breakpoint (<= 1024px) */
@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
    padding: 1.25rem 1rem 2.5rem 1rem;
    gap: 1.5rem;
  }

  .admin-drawer {
    max-width: 100vw;
    width: 100%;
  }
}

/* 2. Mobile Landscape & Standard Breakpoint (<= 768px) */
@media (max-width: 768px) {
  html, body, #viewCatalog, #viewClassroom, .view-section, .main-container, .player-section, .classroom-topbar {
    overflow-x: clip !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* 1. Header & Navigation Optimization */
  .navbar {
    padding: 8px 12px !important;
    gap: 6px !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
    justify-content: space-between !important;
    align-items: center !important;
  }

  .nav-brand-group {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
  }

  .nav-brand {
    gap: 6px !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    overflow: hidden !important;
  }

  .brand-logo-img {
    height: 28px !important;
    width: auto !important;
    flex-shrink: 0 !important;
  }

  .brand-text {
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .brand-text h1 {
    font-size: 0.85rem !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.25 !important;
  }

  .brand-text span {
    display: none !important; /* Hide long subtitle on mobile to prevent navbar crowding */
  }

  .nav-actions {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
  }

  .btn-nav {
    padding: 6px 8px !important;
    font-size: 0.78rem !important;
    gap: 4px !important;
    border-radius: var(--radius-sm) !important;
    white-space: nowrap !important;
  }

  .btn-nav span {
    display: none !important; /* Icon-only for secondary actions */
  }

  .btn-nav.primary span,
  #btnNavLogin span {
    display: inline !important; /* Keep text visible on primary CTAs */
    font-size: 0.76rem !important;
  }

  .nav-user-pill {
    padding: 3px 6px !important;
    gap: 4px !important;
    background: rgba(79, 70, 229, 0.08) !important;
    border-radius: var(--radius-full) !important;
  }

  .nav-user-pill .user-avatar {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.75rem !important;
    flex-shrink: 0 !important;
  }

  .nav-user-pill .user-info {
    display: none !important; /* Hide user company info on mobile */
  }

  .btn-icon {
    padding: 6px !important;
  }

  /* 2. Classroom Topbar */
  .classroom-topbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 10px 12px 0 12px !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  .active-course-badge {
    font-size: 0.8rem !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 6px 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .main-container {
    grid-template-columns: 1fr !important;
    padding: 10px 12px 24px 12px !important;
    gap: 16px !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .player-section {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* 3. Video Player & Custom Controls Grid */
  .video-card {
    border-radius: 12px !important;
    overflow: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .video-frame-container {
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    height: auto !important;
    background: #000000 !important;
    border-radius: 12px 12px 0 0 !important;
    overflow: hidden !important;
  }

  video#lessonVideo {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: #000000 !important;
    border-radius: inherit !important;
    display: block !important;
  }

  .video-watermark {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    max-width: 85% !important;
    font-size: 11px !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    z-index: 10 !important;
    padding: 3px 8px !important;
    background: rgba(15, 23, 42, 0.85) !important;
    backdrop-filter: blur(6px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 9999px !important;
  }

  .video-statusbar {
    padding: 10px 12px !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* 2-Column Responsive Action Grid for Video Controls */
  .video-action-bar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin-top: 6px !important;
  }

  .action-left, .action-right {
    display: contents !important;
  }

  .video-action-bar .btn-control {
    width: 100% !important;
    padding: 9px 8px !important;
    font-size: 12.5px !important;
    justify-content: center !important;
    text-align: center !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: var(--radius-sm) !important;
    white-space: nowrap !important;
  }

  .video-action-bar #btnPlayPause {
    grid-column: span 2 !important;
    font-size: 14px !important;
    padding: 10px 8px !important;
    font-weight: 800 !important;
  }

  /* 4. Lesson Meta, Badges & Accessible Tabs Nav */
  .lesson-meta-card {
    padding: 14px 12px !important;
    border-radius: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .lesson-badge-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    margin-bottom: 10px !important;
    width: 100% !important;
  }

  .badge {
    font-size: 11.5px !important;
    padding: 3px 8px !important;
    white-space: nowrap !important;
  }

  .lesson-title {
    font-size: 1.2rem !important;
    line-height: 1.35 !important;
    margin-bottom: 6px !important;
  }

  .lesson-desc {
    font-size: 0.88rem !important;
    margin-bottom: 14px !important;
    line-height: 1.6 !important;
  }

  .tabs-nav {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    gap: 8px !important;
    padding: 4px 4px 8px 4px !important;
    border-bottom: 2px solid var(--border-glass) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin-bottom: 14px !important;
    overscroll-behavior-x: contain !important;
  }

  .tabs-nav::-webkit-scrollbar {
    display: none !important;
    height: 0px !important;
  }

  .tab-btn {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    padding: 8px 14px !important;
    gap: 6px !important;
    border-radius: var(--radius-sm) !important;
  }

  /* 5. Key Topics Grid & Feature Cards */
  .key-takeaways {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin-top: 12px !important;
  }

  .takeaway-card {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px 14px !important;
    border-radius: var(--radius-md) !important;
  }

  /* 6. Student Learning Passport / Sidebar - No Left Clipping */
  .sidebar-section {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    box-sizing: border-box !important;
  }

  .card-widget {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
    padding: 16px 14px !important;
    border-radius: 12px !important;
  }

  .learner-profile-card {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 4px 0 !important;
  }

  .profile-avatar-large {
    width: 64px !important;
    height: 64px !important;
    font-size: 1.5rem !important;
    margin-bottom: 8px !important;
  }

  .profile-full-name {
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    word-break: break-word !important;
  }

  .profile-meta-line {
    font-size: 0.8rem !important;
    word-break: break-word !important;
    margin-bottom: 4px !important;
  }

  .profile-phone-text {
    font-size: 0.84rem !important;
    direction: ltr !important;
    margin-bottom: 10px !important;
    padding: 3px 10px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .profile-details-mini {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 10px 12px !important;
    font-size: 0.8rem !important;
    margin-bottom: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }

  .profile-details-mini div {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    text-align: right !important;
    word-break: break-all !important;
    overflow-wrap: break-word !important;
  }

  .profile-stats-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .profile-stat-box {
    padding: 8px 6px !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
  }

  .stat-value {
    font-size: 1.1rem !important;
  }

  .stat-label {
    font-size: 0.72rem !important;
  }

  /* 7. Notes & Exam */
  .notes-input-box {
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .notes-input {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .exam-intro-box,
  .exam-question-card {
    padding: 12px 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .exam-q-title {
    font-size: 0.92rem !important;
    line-height: 1.5 !important;
  }

  .exam-option-label {
    padding: 8px 10px !important;
    font-size: 0.86rem !important;
    gap: 8px !important;
    word-break: break-word !important;
  }

  /* Hero & Catalog Mobile */
  .hero-banner {
    padding: 1.75rem 1rem 1.5rem 1rem !important;
  }

  .hero-pill {
    font-size: 0.75rem !important;
    padding: 0.3rem 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }

  .hero-title {
    font-size: 1.35rem !important;
    line-height: 1.4 !important;
    margin-bottom: 0.6rem !important;
  }

  .hero-desc {
    font-size: 0.88rem !important;
    line-height: 1.7 !important;
  }

  .catalog-container {
    padding: 1.25rem 0.85rem 2.5rem 0.85rem !important;
  }

  .catalog-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.4rem !important;
    margin-bottom: 1.25rem !important;
  }

  .courses-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  .course-card-cover {
    height: 180px !important;
  }

  .course-card-body {
    padding: 1.15rem !important;
  }

  .course-card-title {
    font-size: 1.15rem !important;
  }

  /* Modals & Authentication */
  .modal-overlay {
    padding: 0.75rem !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .modal-card {
    padding: 1.5rem 1.15rem !important;
    border-radius: var(--radius-md) !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: calc(100vh - 1.5rem) !important;
    max-height: calc(100dvh - 1.5rem) !important;
  }

  .modal-title {
    font-size: 1.25rem !important;
  }

  .modal-desc {
    font-size: 0.82rem !important;
    margin-bottom: 1.15rem !important;
  }

  .auth-tab-btn {
    padding: 0.55rem 0.35rem !important;
    font-size: 0.82rem !important;
  }

  .form-row {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  /* Certificate Preview Mobile */
  .certificate-preview-box {
    padding: 1.25rem 0.85rem !important;
    border-radius: var(--radius-md) !important;
  }

  .cert-logo-img {
    height: 44px !important;
  }

  .cert-title {
    font-size: 1.2rem !important;
    margin-bottom: 0.25rem !important;
  }

  .cert-subtitle {
    font-size: 0.82rem !important;
  }

  .cert-student-name {
    font-size: 1.45rem !important;
    margin-bottom: 0.85rem !important;
  }

  .cert-course-name {
    font-size: 0.95rem !important;
    margin-bottom: 1.15rem !important;
  }

  .cert-details-grid {
    gap: 0.4rem !important;
    margin-bottom: 1.15rem !important;
  }

  .cert-pill-item {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.6rem !important;
  }

  .cert-meta-row {
    flex-direction: column !important;
    gap: 0.5rem !important;
    text-align: center !important;
    padding-top: 0.85rem !important;
  }

  /* Admin & Docs Mobile */
  .admin-page-container,
  .docs-container {
    padding: 1rem 0.75rem 3rem 0.75rem !important;
  }

  .admin-card-section,
  .docs-card,
  .docs-hero {
    padding: 1.25rem 1rem !important;
    border-radius: var(--radius-md) !important;
  }

  .toast-container {
    left: 12px !important;
    bottom: 12px !important;
    right: 12px !important;
    width: auto !important;
  }

  .toast {
    width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.82rem !important;
    padding: 0.65rem 1rem !important;
  }
}

/* 3. Small Mobile Breakpoint (<= 480px) */
@media (max-width: 480px) {
  .navbar {
    padding: 6px 8px !important;
  }

  .brand-logo-img {
    height: 24px !important;
  }

  .brand-text h1 {
    font-size: 0.8rem !important;
  }

  .btn-nav.primary span,
  #btnNavLogin span {
    display: none !important; /* Pure icon-only on ultra-compact mobile */
  }

  .btn-nav {
    padding: 5px 6px !important;
  }

  .hero-title {
    font-size: 1.18rem !important;
  }

  .modal-card {
    padding: 1.25rem 1rem !important;
  }

  .auth-tab-btn {
    padding: 0.5rem 0.25rem !important;
    font-size: 0.78rem !important;
    gap: 0.25rem !important;
  }
}

/* --------------------------------------------------------------------------
   PRINT / PDF EXPORT STYLES (GUARANTEED SINGLE PAGE CERTIFICATE)
   -------------------------------------------------------------------------- */
@page {
  size: A4 landscape;
  margin: 10mm;
}

@media print {
  html, body {
    height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide all UI elements except the certificate */
  header,
  .navbar,
  .hero-banner,
  .catalog-container,
  .classroom-topbar,
  .video-card,
  .lesson-badge-group,
  .lesson-title,
  .lesson-desc,
  .tabs-nav,
  #tab-overview,
  #tab-notes,
  #tab-exam,
  .sidebar-section,
  .modal-overlay,
  .admin-drawer,
  .drawer-overlay,
  .toast-container,
  button,
  .btn-control {
    display: none !important;
    visibility: hidden !important;
  }

  .view-section {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .main-container {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .player-section {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .lesson-meta-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #tab-certificate {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Certificate Box Print Optimization */
  .certificate-preview-box {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    visibility: visible !important;
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 175mm !important;
    max-height: 175mm !important;
    margin: 0 auto !important;
    padding: 1.25rem 2rem !important;
    border: 3px double #d97706 !important;
    border-radius: 14px !important;
    background: #ffffff !important;
    color: #0f172a !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
    page-break-before: avoid !important;
    break-before: avoid !important;
    overflow: hidden !important;
  }

  .certificate-preview-box * {
    visibility: visible !important;
  }

  .cert-logo-container {
    margin-bottom: 0.5rem !important;
  }

  .cert-logo-img {
    height: 48px !important;
  }

  .cert-title {
    font-size: 1.4rem !important;
    color: #b45309 !important;
    margin-bottom: 0.2rem !important;
    line-height: 1.2 !important;
  }

  .cert-subtitle {
    font-size: 0.88rem !important;
    color: #475569 !important;
    margin-bottom: 0.4rem !important;
  }

  .cert-student-name {
    font-size: 1.75rem !important;
    color: #0f172a !important;
    margin-bottom: 0.6rem !important;
    text-underline-offset: 4px !important;
  }

  .cert-details-grid {
    display: flex !important;
    justify-content: center !important;
    gap: 0.6rem !important;
    margin-bottom: 0.6rem !important;
  }

  .cert-pill-item {
    font-size: 0.78rem !important;
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
    padding: 0.2rem 0.6rem !important;
  }

  .cert-course-name {
    font-size: 1rem !important;
    color: #1e293b !important;
    margin-bottom: 0.75rem !important;
    line-height: 1.5 !important;
  }

  .cert-meta-row {
    padding-top: 0.6rem !important;
    border-top: 1px solid #e2e8f0 !important;
    font-size: 0.8rem !important;
    color: #475569 !important;
  }
}
