/* =====================================================
   MS. MARIAM ABDO PLATFORM — Custom CSS (RTL)
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
  --primary: #1a56db;
  --primary-dark: #1e429f;
  --primary-light: #ebf5ff;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --dark-bg: #0f172a;
  --dark-card: #1e293b;
  --dark-border: #334155;
  --sidebar-width: 280px;
  --header-height: 70px;

  /* ── Semantic tokens (light mode defaults) ── */
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --input-bg: #f8fafc;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --page-bg: #f1f5f9;
  --hover-bg: #f8fafc;
}

/* ── Dark theme overrides (toggled via class on <html>) ── */
.dark-theme {
  --card-bg: #1e293b;
  --card-border: #334155;
  --input-bg: #0f172a;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border-color: #334155;
  --page-bg: #0f172a;
  --hover-bg: #0f172a;
}

/* ── Missing-students card dark/light compatibility ── */
.missing-student-card {
  background: var(--card-bg) !important;
  border-color: var(--border-color) !important;
  transition: box-shadow 0.2s, transform 0.15s;
}

.missing-student-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

/* Select in missing panel */
#hw-missing-list select {
  background: var(--input-bg) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

/* Missing panel box */
#hw-missing-panel {
  background: var(--card-bg);
  border-color: #fca5a5;
}

.dark-theme #hw-missing-panel {
  background: rgba(127, 29, 29, 0.15);
  border-color: #7f1d1d50;
}


/* =====================================================
   GLOBAL IMAGE OPTIMIZATION — object-fit: contain
   Ensures ALL uploaded/content images are fully visible,
   never cropped, never stretched, aspect-ratio preserved.
   ===================================================== */

/* ── Base rule: all images in content areas use contain ── */
.card img,
.card-dark img,
.modal-box img,
main img,
section img,
article img,
[id$="-list"] img,
[id$="-grid"] img,
[id$="-preview"] img,
#admin-books-list img,
#admin-student-books-list img,
#admin-videos-list img,
#admin-exams-list img,
#admin-hw-list img,
#admin-courses-grid img,
#student-books-list img,
#homework-list img,
#books-grid img,
#models-grid img {
  object-fit: contain;
  width: 100%;
  height: 100%;
}

/* ── Exceptions: elements that intentionally need cover ── */
/* Gallery items: always fill the frame edge-to-edge */
.gallery-item img,
/* Video thumbnails: should fill the 16:9 black frame */
.aspect-video img,
[class*="aspect-video"] img,
/* Hero background-style images */
.hero-gradient img,
.animate-hero-img,
/* Student dashboard course cover images on cards */
#admin-courses-grid img,
/* Landing page hero / section covers */
.object-cover {
  object-fit: cover !important;
}

/* ── Ensure container integrity: images never overflow ── */
img {
  max-width: 100%;
  display: block;
}

/* ── Book covers: contain within their fixed-ratio boxes ── */
.aspect-\[3\/4\] img,
[style*="aspect-ratio: 3/4"] img,
[style*="aspect-ratio:3/4"] img {
  object-fit: contain;
  background: #f8fafc;
  /* neutral background shows behind letterboxed images */
}

/* ── Admin book cover thumbnail (56×72px strip) ── */
#admin-books-list img {
  object-fit: contain;
  background: #eff6ff;
}

/* ── Dark mode: use dark neutral for letterbox background ── */
html.dark .aspect-\[3\/4\] img,
html.dark #admin-books-list img {
  background: #1e293b;
}



html {
  direction: rtl;
  scroll-behavior: smooth;
}

body {
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  overflow-x: hidden;
  min-height: 100vh;
  zoom: 80%;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ---- Sidebar Layout ---- */
.sidebar {
  width: var(--sidebar-width);
  bottom: 0;
  padding-bottom: 80px;
  padding-top: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border-left: 1px solid #334155;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(100%);
  /* Start hidden on mobile */
}

.sidebar.open {
  transform: translateX(0);
}

@media (min-width: 1025px) {
  .sidebar {
    transform: translateX(0);
    /* Always show on desktop */
    padding-top: var(--header-height);
    /* Push nav below the fixed top-header */
  }
}

.main-content {
  margin-right: 0;
  min-height: 125vh;
  transition: margin-right 0.3s ease;
  padding-top: var(--header-height);
}

@media (min-width: 1025px) {
  .main-content {
    margin-right: var(--sidebar-width);
  }
}

/* ---- Sidebar Nav Items ---- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #94a3b8;
  border-radius: 12px;
  margin: 4px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(26, 86, 219, 0.15);
  color: #60a5fa;
}

.nav-item.active {
  background: rgba(26, 86, 219, 0.25);
  color: #93c5fd;
  border-right: 3px solid #3b82f6;
}

.nav-item svg,
.nav-item .nav-icon {
  font-size: 20px;
  min-width: 24px;
}

/* ---- Cards ---- */
.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 20px rgba(0, 0, 0, .04);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
}

.card-dark {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: 16px;
}

/* ---- Stat Cards ---- */
.stat-card {
  border-radius: 16px;
  padding: 24px;
  color: white;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -20px;
  left: -20px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}

/* ---- Buttons ---- */
.btn-primary {
  background: linear-gradient(135deg, #1a56db, #1e429f);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(26, 86, 219, 0.35);
}

.btn-secondary {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-danger {
  background: #fef2f2;
  color: #ef4444;
  border: 1px solid #fecaca;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #ef4444;
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

/* ---- Form Inputs ---- */
.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-family: 'Cairo', sans-serif;
  font-size: 15px;
  color: #1e293b;
  background: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* Force native OS dropdown popup on all selects
   Tailwind CDN injects appearance:none via JS after page load,
   which converts selects to DOM-rendered and the fixed sidebar covers options */
select,
select.form-input {
  -webkit-appearance: auto !important;
  -moz-appearance: auto !important;
  appearance: auto !important;
}

select.form-input option {
  padding: 8px;
  direction: rtl;
  text-align: right;
  color: inherit;
  background: inherit;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: white;
}

.form-label {
  display: block;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  font-size: 14px;
}

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 700;
}

.badge-blue {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge-green {
  background: #f0fdf4;
  color: #16a34a;
}

.badge-red {
  background: #fef2f2;
  color: #dc2626;
}

.badge-yellow {
  background: #fefce8;
  color: #ca8a04;
}

.badge-gray {
  background: #f1f5f9;
  color: #475569;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  transform: scale(0.95);
  transition: transform 0.2s;
  direction: rtl;
}

.modal-overlay.open .modal-box {
  transform: scale(1);
}

/* ---- Tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: right;
  font-weight: 700;
  color: #475569;
  font-size: 13px;
  border-bottom: 2px solid #e2e8f0;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
  color: #374151;
}

.data-table tr:hover td {
  background: #f8fafc;
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  animation: slideInLeft 0.3s ease;
  border-right: 5px solid;
  direction: rtl;
  color: #1e293b;
  font-weight: 600;
}

.toast.success {
  border-color: #10b981;
  background: #f0fdf4;
  color: #065f46;
}

.toast.error {
  border-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
}

.toast.info {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
}

/* Dark Mode Toasts */
html.dark .toast {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

html.dark .toast.success {
  background: #064e3b;
  color: #a7f3d0;
  border-color: #10b981;
}

html.dark .toast.error {
  background: #7f1d1d;
  color: #fecaca;
  border-color: #ef4444;
}

html.dark .toast.info {
  background: #1e3a8a;
  color: #bfdbfe;
  border-color: #3b82f6;
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ---- Progress Bar ---- */
.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 50px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a56db, #3b82f6);
  border-radius: 50px;
  transition: width 0.6s ease;
}

/* ---- Video Player ---- */
.video-container {
  position: relative;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 16/9;
}

.video-container video {
  width: 100%;
  height: 100%;
}

/* Plyr YouTube embed — standard 16:9, click-proof */
.plyr__video-wrapper.plyr__video-embed {
  position: relative !important;
  aspect-ratio: 16 / 9 !important;
}

.plyr__video-wrapper.plyr__video-embed iframe {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

/* ---- Anti-Piracy Dynamic Watermark ---- */
.watermark-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* CRITICAL: never block player controls */
  overflow: hidden;
  z-index: 20;
}

.dynamic-watermark {
  position: absolute;
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  font-weight: 700;
  font-family: 'Cairo', sans-serif;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  user-select: none;
  white-space: nowrap;
  letter-spacing: 0.5px;
  /* Use top/left transitions — these work with %-based positioning */
  transition: top 4s linear, left 4s linear;
  top: 10%;
  left: 10%;
}

/* ---- Notification Bell ---- */
.notif-bell {
  position: relative;
  cursor: pointer;
}

.notif-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }
}

/* ---- Leaderboard ---- */
.rank-gold {
  color: #f59e0b;
}

.rank-silver {
  color: #94a3b8;
}

.rank-bronze {
  color: #b45309;
}

.rank-1 {
  background: linear-gradient(135deg, #FFF9C4, #FFF176);
  border: 2px solid #f59e0b;
}

.rank-2 {
  background: linear-gradient(135deg, #F5F5F5, #E0E0E0);
  border: 2px solid #9e9e9e;
}

.rank-3 {
  background: linear-gradient(135deg, #FFE8D6, #FFCCBC);
  border: 2px solid #b45309;
}

/* ---- Section Animations ---- */
.section-panel {
  display: none;
}

.section-panel.active {
  display: block;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Landing Page Hero ---- */
.hero-gradient {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e429f 100%);
  position: relative;
  overflow: hidden;
}

.hero-gradient::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='10'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ---- Gallery Grid ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.gallery-item {
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 4/3;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.gallery-item:hover {
  transform: scale(1.03);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- File Upload ---- */
.file-drop {
  border: 2px dashed #cbd5e0;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.file-drop:hover,
.file-drop.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}

/* ---- Quiz / Exam ---- */
.quiz-option {
  padding: 14px 20px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 15px;
}

.quiz-option:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.quiz-option.selected {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.quiz-option.correct {
  border-color: #10b981;
  background: #f0fdf4;
  color: #065f46;
}

.quiz-option.wrong {
  border-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
}

/* ---- Loading Spinner ---- */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: #94a3b8;
}

.empty-state svg {
  margin: 0 auto 16px;
  opacity: 0.4;
}

/* ---- Header ---- */
.top-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid #e2e8f0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  /* above sidebar z-40 so header always on top */
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

/* ---- Q&A Thread ---- */
.qa-thread {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
}

.qa-question {
  padding: 20px;
  background: #f8fafc;
}

.qa-answer {
  padding: 20px;
  background: white;
  border-top: 1px solid #e2e8f0;
}

.qa-answer-badge {
  background: linear-gradient(135deg, #1a56db, #1e429f);
  color: white;
  padding: 2px 12px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 700;
}

/* ---- Responsive: Tablet ---- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-right: 0 !important;
  }

  .top-header {
    right: 0 !important;
    width: 100% !important;
  }
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .main-content {
    padding: 12px;
    padding-top: calc(var(--header-height) + 12px);
  }

  .top-header {
    padding: 0 12px;
    height: var(--header-height);
  }

  .stat-card {
    padding: 14px;
  }

  .card {
    border-radius: 14px;
  }

  .modal-box {
    padding: 18px;
    margin: 10px;
    max-height: 90vh;
    width: calc(100% - 20px);
  }

  /* Course video modal: fix grid on mobile */
  #add-course-video-modal .grid-cols-3,
  #add-course-video-modal .grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  #add-course-video-modal .col-span-2 {
    grid-column: span 1 !important;
  }

  /* Grid adjustments (Targeted) */
  #admin-courses-grid,
  #landing-courses-grid,
  #books-grid,
  #features-grid {
    grid-template-columns: 1fr !important;
  }

  /* Table scroll */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    font-size: 13px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
    white-space: nowrap;
  }

  /* Flex alignment issues fixed by removing global wrap */
  .flex.items-start {
    gap: 8px;
  }

  /* Buttons */
  .btn-primary,
  .btn-secondary,
  .btn-success,
  .btn-danger {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Typography */
  h2 {
    font-size: 1.25rem !important;
  }

  h3 {
    font-size: 1rem !important;
  }

  /* Form inputs slightly bigger for touch */
  .form-input {
    padding: 10px 14px;
    font-size: 15px;
    min-height: 44px;
  }

  select.form-input {
    min-height: 44px;
    appearance: auto !important;
    -webkit-appearance: auto !important;
    -moz-appearance: auto !important;
  }

  /* Gallery mobile grid */
  .gallery-item {
    width: 100%;
    height: auto;
    aspect-ratio: 4/3;
  }

  /* Video player */
  .aspect-video {
    aspect-ratio: 16/9;
  }

  /* Toast mobile */
  .toast {
    max-width: calc(100vw - 24px);
    left: 12px;
  }
}

/* ---- Responsive: Small Phones ---- */
@media (max-width: 420px) {
  .main-content {
    padding: 8px;
    padding-top: calc(var(--header-height) + 8px);
  }

  .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  .stat-card {
    padding: 12px;
  }

  .card {
    padding: 12px;
  }

  .modal-box {
    padding: 14px;
    margin: 6px;
  }

  h2 {
    font-size: 1.1rem !important;
  }

  .btn-primary,
  .btn-secondary,
  .btn-success,
  .btn-danger {
    padding: 7px 12px;
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 6px 8px;
    font-size: 12px;
  }
}

/* Mobile sidebar toggle button */
.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: white;
  border: 1px solid #e2e8f0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 1024px) {
  .mobile-menu-btn {
    display: flex;
  }
}

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {
  body {
    background: white;
  }

  .no-print,
  .sidebar,
  .top-header {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
}

html.dark select option {
  background-color: #1e1e1e !important;
  color: #e5e7eb !important;
}

html.dark select.form-input {
  background-color: #1e1e1e !important;
  color: #e5e7eb !important;
  border-color: #444 !important;
}

/* =====================================================
   GLOBAL HIGH-END DARK MODE
   ===================================================== */
html.dark body,
html.dark {
  background: #121212 !important;
  color: #e5e7eb !important;
  color-scheme: dark;
}

html.dark .card,
html.dark .modal-box,
html.dark .section-panel,
html.dark .form-input,
html.dark .top-header,
html.dark .bg-white {
  background-color: #1e1e1e !important;
  border-color: #333 !important;
  color: #e5e7eb !important;
}

html.dark .sidebar {
  background: linear-gradient(180deg, #121212 0%, #1a1a1a 100%) !important;
  border-left-color: #333 !important;
}

/* Typography Overrides */
html.dark .text-slate-800,
html.dark .text-slate-700,
html.dark .text-gray-800,
html.dark .text-gray-700,
html.dark .text-slate-900 {
  color: #f3f4f6 !important;
}

html.dark .text-slate-500,
html.dark .text-slate-600,
html.dark .text-gray-500,
html.dark .text-gray-600,
html.dark .text-slate-400 {
  color: #9ca3af !important;
}

/* Backgrounds & Borders */
html.dark .bg-slate-50,
html.dark .bg-slate-100,
html.dark .bg-gray-50,
html.dark .bg-slate-200 {
  background-color: #262626 !important;
  border-color: #333 !important;
}

html.dark .border-slate-100,
html.dark .border-slate-200,
html.dark .border-gray-200,
html.dark .border-b {
  border-color: #333 !important;
}

/* Tables & Lists */
html.dark .hover\:bg-slate-50:hover,
html.dark .hover\:bg-slate-100:hover,
html.dark .hover\:bg-blue-50:hover {
  background-color: #2a2a2a !important;
}

/* Gradients that break dark mode */
html.dark .bg-gradient-to-r.from-slate-50 {
  background-image: none !important;
  background-color: #1e1e1e !important;
}

/* Specialized Overrides */
html.dark .qa-thread {
  border-color: #333 !important;
}

html.dark .qa-question {
  background-color: #262626 !important;
}

html.dark .qa-answer {
  background-color: #1e1e1e !important;
  border-top-color: #333 !important;
}

html.dark .btn-secondary {
  background-color: #262626 !important;
  color: #e5e7eb !important;
  border-color: #444 !important;
}

html.dark .btn-secondary:hover {
  background-color: #333 !important;
}

/* Keep Primary colors intact, just update any local conflicting logic */
html.dark .nav-item:hover,
html.dark .nav-item.active {
  background: rgba(26, 86, 219, 0.25) !important;
}

/* =====================================================
   YOUTUBE PLYR PLAYER — Anti-Branding Masks
   ===================================================== */
.plyr__video-wrapper {
  position: relative !important;
  z-index: 1 !important;
  overflow: hidden !important;
  background: #000;
}

.plyr__video-wrapper iframe {
  z-index: 1 !important;
}

/* Controls above masks */
.plyr__controls {
  z-index: 200 !important;
}

/* Watermark above everything */
.watermark-wrapper {
  z-index: 999999 !important;
}

/* =====================================================
   EXAM QUIZ OPTIONS (Instant Feedback)
   ===================================================== */
.quiz-option {
  padding: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: white;
  transition: all 0.2s;
  color: #1e293b;
}

.quiz-option.clickable:hover {
  background: #f8fafc;
}

.quiz-state-correct {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
  color: #047857 !important;
}

.quiz-state-wrong {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
  color: #b91c1c !important;
}

.quiz-state-disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* ---- Bonus page tabs ---- */
.bonus-tab {
  padding: 12px 22px;
  font-weight: 700;
  font-size: 15px;
  color: #64748b;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.bonus-tab:hover { color: #334155; }

.bonus-tab.active {
  color: #d97706;
  border-bottom-color: #f59e0b;
}

.bonus-page-btn {
  min-width: 38px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.bonus-page-btn:hover:not(:disabled) { background: #f1f5f9; }
.bonus-page-btn.active { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.bonus-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

html.dark .bonus-tab { color: #94a3b8; }
html.dark .bonus-tab.active { color: #fbbf24; border-bottom-color: #f59e0b; }
html.dark .bonus-page-btn { background: #262626; border-color: #444; color: #e5e7eb; }
html.dark .bonus-page-btn:hover:not(:disabled) { background: #333; }

/* Chosen but not confirmed yet — still changeable */
.quiz-state-selected {
  border-color: #3b82f6 !important;
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ---- Confirm-answer bar ---- */
.exam-confirm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 26px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
}

.exam-confirm-bar.is-locked {
  border-style: solid;
  border-color: #10b981;
  background: #ecfdf5;
  justify-content: center;
}

.exam-confirm-note {
  font-size: 14px;
  color: #475569;
  font-weight: 500;
}

.exam-confirm-bar.is-locked .exam-confirm-note {
  color: #047857;
  font-weight: 700;
}

.exam-confirm-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 26px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.exam-confirm-btn:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.exam-confirm-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- Exam confirm modal ---- */
.exam-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(15, 23, 42, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: examModalFade 0.18s ease-out;
}

@keyframes examModalFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.exam-modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 26px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.exam-modal-title {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 14px;
}

.exam-modal-body {
  font-size: 15px;
  color: #475569;
  line-height: 1.7;
}

.exam-modal-body .exam-submit-warn {
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 10px;
  font-weight: 600;
}

.exam-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.exam-modal-btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.exam-modal-btn.confirm { background: #16a34a; color: #fff; }
.exam-modal-btn.confirm:hover { background: #15803d; }
.exam-modal-btn.cancel  { background: #e2e8f0; color: #334155; }
.exam-modal-btn.cancel:hover { background: #cbd5e1; }

/* Dark Mode Quiz Overrides */
html.dark .quiz-option {
  background: #262626;
  border-color: #444;
  color: #e5e7eb;
}

html.dark .quiz-state-selected {
  background: rgba(59, 130, 246, 0.16) !important;
  border-color: #3b82f6 !important;
  color: #93c5fd !important;
}

html.dark .exam-confirm-bar {
  background: #1f1f1f;
  border-color: #444;
}

html.dark .exam-confirm-note { color: #cbd5e1; }

html.dark .exam-confirm-bar.is-locked {
  background: rgba(16, 185, 129, 0.12);
  border-color: #10b981;
}

html.dark .exam-confirm-bar.is-locked .exam-confirm-note { color: #34d399; }

html.dark .exam-modal-box { background: #1f1f1f; }
html.dark .exam-modal-title { color: #f8fafc; }
html.dark .exam-modal-body { color: #cbd5e1; }

html.dark .exam-modal-body .exam-submit-warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

html.dark .exam-modal-btn.cancel { background: #333; color: #e5e7eb; }
html.dark .exam-modal-btn.cancel:hover { background: #444; }

html.dark .quiz-option.clickable:hover {
  background: #333;
}

html.dark .quiz-state-correct {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: #10b981 !important;
  color: #34d399 !important;
}

html.dark .quiz-state-wrong {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: #ef4444 !important;
  color: #f87171 !important;
}


/* =====================================================
   PREMIUM PLYR YOUTUBE PLAYER — Professional Redesign
   Inspired by TutorLMS / Modern E-learning Platforms
   ===================================================== */

/* ---- Poster image (thumbnail shown before play) ---- */
.plyr__poster {
  background-size: cover !important;
  background-position: center !important;
}

/* ---- THE OVERLAID PLAY BUTTON — Big, Solid, Stunning ---- */
.plyr__control--overlaid {
  background-color: #1a2744 !important;
  /* Deep dark navy — fully opaque 100% */
  background: #1a2744 !important;
  /* Force override completely */
  opacity: 1 !important;
  width: 90px !important;
  height: 90px !important;
  border-radius: 50% !important;
  border: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  cursor: pointer !important;
  /* Very subtle shadow, no transparency to background */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5) !important;
  transition: transform 0.2s ease, background-color 0.2s ease !important;

  /* Force it dead center */
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 100 !important;
}

.plyr__control--overlaid:hover {
  background-color: #1a56db !important;
  /* Brighter blue on hover */
  background: #1a56db !important;
  transform: translate(-50%, -50%) scale(1.1) !important;
}

.plyr__control--overlaid:active {
  transform: translate(-50%, -50%) scale(0.95) !important;
}

.plyr__control--overlaid svg {
  width: 36px !important;
  height: 36px !important;
  fill: #ffffff !important;
  position: relative !important;
  left: 4px !important;
  /* Optical centering for play triangle */
}

/* Hide the native YouTube play button by ensuring our poster and button are solid */
.plyr.plyr--youtube.plyr--paused .plyr__poster,
.plyr.plyr--youtube.plyr--stopped .plyr__poster {
  opacity: 1 !important;
  z-index: 99 !important;
  background-color: #000 !important;
}

/* ---- Bottom Controls Bar — Sleek Gradient ---- */
.plyr__controls {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%) !important;
  padding: 32px 16px 12px !important;
  border-radius: 0 0 12px 12px !important;
  z-index: 200 !important;
}

/* Control buttons hover state */
.plyr__controls .plyr__control {
  background: transparent !important;
  border-radius: 6px !important;
  transition: background 0.18s ease !important;
}

.plyr__controls .plyr__control:hover {
  background: rgba(255, 255, 255, 0.18) !important;
}

/* ---- Progress / Seek Bar ---- */
.plyr--full-ui input[type=range] {
  color: #3b82f6 !important;
}

.plyr__progress input[type=range]::-webkit-slider-thumb {
  width: 14px !important;
  height: 14px !important;
}

/* ---- Volume Control ---- */
.plyr__volume input[type=range] {
  color: #3b82f6 !important;
}

/* ---- Time display ---- */
.plyr__time {
  font-family: 'Cairo', monospace !important;
  font-size: 13px !important;
  color: rgba(255, 255, 255, 0.9) !important;
}

/* ---- Full Player wrapper border ---- */
.plyr--video {
  border-radius: 12px !important;
  overflow: hidden !important;
  background: #000 !important;
}

/* =========================================================
   HOMEWORK RESPONSIVE RULES
   ========================================================= */

/* Submissions table: horizontally scrollable on small screens */
.card.overflow-hidden {
  overflow-x: auto;
}

/* Mobile padding for section panels */
@media (max-width: 640px) {
  .section-panel {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Submissions header buttons stack on mobile */
  #hw-submissions-view .flex.flex-wrap {
    gap: 0.5rem;
  }

  /* Admin homework card action row full-width on very small screens */
  #admin-hw-list .flex.flex-wrap.gap-2.mt-3 button {
    flex: 1 1 calc(33% - 0.5rem);
    min-width: 0;
  }

  /* Student homework page title */
  #section-homework h2 {
    font-size: 1.25rem;
  }
}

/* Ensure the hw submit modal is not wider than the screen */
#hw-submit-modal .modal-box {
  max-width: min(440px, 96vw);
}

/* Resend HW modal mobile fix */
#resend-hw-modal .modal-box {
  max-width: min(440px, 96vw);
  margin: 1rem;
}

/* Hero Image Animation */
@keyframes floatHero {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-12px) scale(1.015);
  }
}

.animate-hero-img {
  animation: floatHero 6s ease-in-out infinite;
  transform-origin: bottom center;
}

/* ═══════════════════════════════════════════════
   Admin Course-Videos Section — Playlist Cards
═══════════════════════════════════════════════ */
.cv-custom-scrollbar::-webkit-scrollbar {
  width: 5px;
}

.cv-custom-scrollbar::-webkit-scrollbar-thumb {
  background: #c7d2fe;
  border-radius: 99px;
}

.cv-custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

/* Compact playlist card */
.cv-playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
  background: #fff;
}

.cv-playlist-item:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.cv-playlist-item.active {
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border-color: #818cf8;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.cv-playlist-item .cv-thumb {
  width: 64px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e2e8f0;
}

.cv-playlist-item .cv-thumb-placeholder {
  width: 64px;
  height: 44px;
  border-radius: 8px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cv-playlist-item .cv-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cv-playlist-item.active .cv-num {
  background: #6366f1;
  color: #fff;
}

.cv-playlist-item .cv-info {
  flex: 1;
  min-width: 0;
}

.cv-playlist-item .cv-info .cv-title {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cv-playlist-item.active .cv-info .cv-title {
  color: #4338ca;
}

.cv-playlist-item .cv-info .cv-date {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
}

/* Dark mode for playlist */
html.dark .cv-playlist-item {
  background: var(--dark-card, #1e293b) !important;
  border-color: #334155 !important;
}

html.dark .cv-playlist-item:hover {
  background: #2a3548 !important;
  border-color: #475569 !important;
}

html.dark .cv-playlist-item.active {
  background: rgba(99, 102, 241, 0.15) !important;
  border-color: #6366f1 !important;
}

html.dark .cv-playlist-item .cv-thumb {
  background: #334155 !important;
}

html.dark .cv-playlist-item .cv-num {
  background: #334155 !important;
  color: #cbd5e1 !important;
}

html.dark .cv-playlist-item.active .cv-num {
  background: #6366f1 !important;
  color: #fff !important;
}

html.dark .cv-playlist-item .cv-info .cv-title {
  color: #f1f5f9 !important;
}

html.dark .cv-playlist-item.active .cv-info .cv-title {
  color: #818cf8 !important;
}

@media (min-width: 1280px) {
  #course-videos-list-wrapper {
    max-height: 680px !important;
  }
}

@media (min-width: 768px) and (max-width: 1279px) {
  #course-videos-list-wrapper {
    max-height: 460px !important;
  }
}

/* Student Videos Playlist — responsive heights */
@media (min-width: 768px) {
  #section-videos #videos-list {
    max-height: 480px !important;
  }
}

@media (min-width: 1280px) {
  #section-videos #videos-list {
    max-height: 680px !important;
  }
}

/* Active lesson row indicator (RTL: border on right) */
.lesson-item-row.border-r-4 {
  border-right: 4px solid #2563eb !important;
  padding-right: calc(0.75rem - 4px);
}

/* Fix: remove white background flash when clicking lesson buttons */
#videos-list button:focus,
#videos-list button:active {
  outline: none;
  background-color: transparent !important;
}


/* =====================================================
   GLOBAL DIM MODE (NAVY BLUE)
   ===================================================== */
html.dim body,
html.dim {
  background: #070c17 !important;
  color: #e5e7eb !important;
  color-scheme: dark;
}

html.dim .card,
html.dim .modal-box,
html.dim .section-panel,
html.dim .form-input,
html.dim .top-header,
html.dim .bg-white {
  background-color: #0d1526 !important;
  border-color: rgba(59, 130, 246, 0.15) !important;
  color: #e5e7eb !important;
}

html.dim .sidebar {
  background: linear-gradient(180deg, #080d1a 0%, #0d1526 60%, #0f1f3a 100%) !important;
  border-left-color: rgba(59, 130, 246, 0.15) !important;
}

html.dim .text-slate-800,
html.dim .text-slate-700,
html.dim .text-gray-800,
html.dim .text-gray-700,
html.dim .text-slate-900 {
  color: #f1f5f9 !important;
}

html.dim .text-slate-500,
html.dim .text-slate-600,
html.dim .text-gray-500,
html.dim .text-gray-600,
html.dim .text-slate-400 {
  color: #94a3b8 !important;
}

html.dim .bg-slate-50,
html.dim .bg-slate-100,
html.dim .bg-gray-50,
html.dim .bg-slate-200 {
  background-color: rgba(255, 255, 255, 0.03) !important;
  border-color: rgba(255, 255, 255, 0.06) !important;
}

html.dim .border-slate-100,
html.dim .border-slate-200,
html.dim .border-gray-200,
html.dim .border-b {
  border-color: rgba(255, 255, 255, 0.06) !important;
}

html.dim select option {
  background-color: #0d1526 !important;
  color: #e5e7eb !important;
}

html.dim select.form-input {
  background-color: #1a2035 !important;
  color: #e5e7eb !important;
  border-color: rgba(255,255,255,0.12) !important;
}

/* =====================================================
   GLOBAL SEPIA MODE (EYE SAVER / READING MODE)
   ===================================================== */
html.sepia body,
html.sepia {
  background: #f4ecd8 !important;
  color: #5c4b37 !important;
}

html.sepia .card,
html.sepia .modal-box,
html.sepia .section-panel,
html.sepia .form-input,
html.sepia .top-header,
html.sepia .bg-white {
  background-color: #fcf9f2 !important;
  border-color: #e6dcc5 !important;
  color: #5c4b37 !important;
}

html.sepia .sidebar {
  background: linear-gradient(180deg, #f0e6d2 0%, #f4ecd8 60%, #fcf9f2 100%) !important;
  border-left-color: #e6dcc5 !important;
}

html.sepia .text-slate-800,
html.sepia .text-slate-700,
html.sepia .text-gray-800,
html.sepia .text-gray-700,
html.sepia .text-slate-900,
html.sepia h1,
html.sepia h2,
html.sepia h3,
html.sepia h4 {
  color: #4a3b2c !important;
}

html.sepia .text-slate-500,
html.sepia .text-slate-600,
html.sepia .text-gray-500,
html.sepia .text-gray-600,
html.sepia .text-slate-400 {
  color: #7a6a58 !important;
}

html.sepia .bg-slate-50,
html.sepia .bg-slate-100,
html.sepia .bg-gray-50,
html.sepia .bg-slate-200 {
  background-color: #f0e6d2 !important;
  border-color: #e6dcc5 !important;
}

html.sepia .border-slate-100,
html.sepia .border-slate-200,
html.sepia .border-gray-200,
html.sepia .border-b {
  border-color: #e6dcc5 !important;
}

html.sepia select option {
  background-color: #fcf9f2 !important;
  color: #5c4b37 !important;
}

/* =====================================================
   SECTION HEIGHT FIX (To prevent layout cutting)
   ===================================================== */
.section-panel {
  min-height: calc(125vh - 70px);
}

/* =====================================================
   CUSTOM SELECT DROPDOWN (replaces native <select>)
   Fixes RTL popup positioning + z-index issues
   ===================================================== */
.csw {
  position: relative;
  width: 100%;
  display: inline-block;
}

.csw-display {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  font-size: 15px;
  color: #1e293b;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 48px;
  box-sizing: border-box;
}

.csw-display:hover {
  border-color: #94a3b8;
}

.csw-display.open {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: white;
}

.csw-arrow {
  flex-shrink: 0;
  transition: transform 0.2s;
  font-style: normal;
  font-size: 12px;
  color: #64748b;
}

.csw-display.open .csw-arrow {
  transform: rotate(180deg);
}

.csw-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  z-index: 99999;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
}

.csw-dropdown.open {
  display: block;
}

.csw-item {
  padding: 10px 16px;
  cursor: pointer;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  font-size: 14px;
  color: #1e293b;
  text-align: right;
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csw-item:first-child { border-radius: 10px 10px 0 0; }
.csw-item:last-child  { border-radius: 0 0 10px 10px; }

.csw-item:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.csw-item.selected {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

/* Dark mode */
html.dark .csw-display,
html.dim .csw-display {
  background: #1e1e1e;
  color: #e5e7eb;
  border-color: #444;
}

html.dark .csw-display.open,
html.dim .csw-display.open {
  background: #252525;
  border-color: #3b82f6;
}

html.dark .csw-dropdown,
html.dim .csw-dropdown {
  background: #1e1e1e;
  border-color: #444;
}

html.dark .csw-item,
html.dim .csw-item {
  color: #e5e7eb;
}

html.dark .csw-item:hover,
html.dim .csw-item:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

html.dark .csw-item.selected,
html.dim .csw-item.selected {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

html.dim .csw-display {
  background: #0d1526;
  border-color: rgba(59,130,246,0.3);
}

html.dim .csw-dropdown {
  background: #0d1526;
  border-color: rgba(59,130,246,0.3);
}

html.dim .csw-item:hover,
html.dim .csw-item.selected {
  background: rgba(59, 130, 246, 0.18);
}

/* Sepia mode */
html.sepia .csw-display {
  background: #fcf9f2;
  color: #5c4b37;
  border-color: #c4a882;
}

html.sepia .csw-dropdown {
  background: #fcf9f2;
  border-color: #c4a882;
}

html.sepia .csw-item {
  color: #5c4b37;
}

html.sepia .csw-item:hover,
html.sepia .csw-item.selected {
  background: #f0e6d3;
}
/* ---- Tables in Math Content ---- */
.math-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  background: var(--card-bg);
}
.math-content th, .math-content td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: center;
}
.math-content th {
  background: var(--hover-bg);
  font-weight: 700;
}



/* =========================================
   PURCHASE MODAL STYLES (THEME AWARE)
========================================= */
.purchase-payment-card {
  background: #eff6ff; /* blue-50 */
  border: 1px solid #bfdbfe; /* blue-200 */
  border-radius: 16px;
  padding: 16px;
}
html.dark .purchase-payment-card {
  background: rgba(30, 58, 138, 0.2); /* dark blue-900 with opacity */
  border: 1px solid rgba(30, 58, 138, 0.5);
}

.purchase-payment-divider {
  border-top: 1px solid #bfdbfe;
}
html.dark .purchase-payment-divider {
  border-top: 1px solid rgba(30, 58, 138, 0.5);
}

.purchase-installment-card {
  background: linear-gradient(to right, #eef2ff, #faf5ff); /* indigo-50 to purple-50 */
  border: 1px solid #c7d2fe; /* indigo-200 */
  border-radius: 16px;
  padding: 16px;
}
html.dark .purchase-installment-card {
  background: linear-gradient(to right, rgba(49, 46, 129, 0.2), rgba(88, 28, 135, 0.1));
  border: 1px solid rgba(49, 46, 129, 0.5);
}

.purchase-plan-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #ffffff;
  border: 2px solid #e2e8f0; /* slate-200 */
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
html.dark .purchase-plan-option {
  background: #1e293b; /* slate-800 */
  border: 2px solid #334155; /* slate-700 */
}
.purchase-plan-option:hover {
  border-color: #60a5fa; /* blue-400 */
}
html.dark .purchase-plan-option:hover {
  border-color: #3b82f6; /* blue-500 */
}

/* Dynamic Payment Method Cards */
.pay-method-card {
  background: #ffffff;
  border: 1px solid #dbeafe; /* blue-100 */
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
html.dark .pay-method-card {
  background: #1e293b; /* slate-800 */
  border: 1px solid #334155; /* slate-700 */
  box-shadow: none;
}

.pay-method-name {
  font-weight: 700;
  color: #334155; /* slate-700 */
}
html.dark .pay-method-name {
  color: #f1f5f9; /* slate-100 */
}

.pay-method-line {
  color: #475569; /* slate-600 */
  font-size: 0.875rem;
  font-family: monospace;
  user-select: all;
  background: #f8fafc; /* slate-50 */
  border-radius: 8px;
  padding: 6px 12px;
  margin-top: 4px;
}
html.dark .pay-method-line {
  color: #cbd5e1; /* slate-300 */
  background: #0f172a; /* slate-900 */
}

.pay-method-empty {
  color: #94a3b8; /* slate-400 */
  font-size: 0.875rem;
  text-align: center;
  padding-top: 4px;
  padding-bottom: 4px;
}
html.dark .pay-method-empty {
  color: #64748b; /* slate-500 */
}

.pay-method-warn {
  background: #fffbeb; /* amber-50 */
  border: 1px solid #fde68a; /* amber-200 */
  border-radius: 12px;
  padding: 12px;
  margin-top: 8px;
}
html.dark .pay-method-warn {
  background: rgba(120, 53, 15, 0.2); /* amber-900/20 */
  border: 1px solid rgba(120, 53, 15, 0.5);
}

.pay-method-warn-text {
  color: #b45309; /* amber-700 */
  font-size: 0.875rem;
  text-align: center;
}
html.dark .pay-method-warn-text {
  color: #fcd34d; /* amber-300 */
}


/* =========================================
   EXAM & QUIZ - SVG AND TABLE FIXES
========================================= */
.exam-question-text svg,
.exam-option-text svg,
.quiz-option svg,
.question-body svg,
.lesson-content svg {
  min-width: 150px;
  max-width: 100%;
  height: auto !important;
  display: inline-block;
}

.exam-question-text table,
.exam-option-text table,
.quiz-option table,
.question-body table,
.lesson-content table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.exam-question-text table td, 
.exam-question-text table th,
.quiz-option table td,
.quiz-option table th,
.question-body table td,
.question-body table th,
.lesson-content table td,
.lesson-content table th {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  text-align: center;
}

html.dark .exam-question-text table td,
html.dark .exam-question-text table th,
html.dark .quiz-option table td,
html.dark .quiz-option table th,
html.dark .question-body table td,
html.dark .question-body table th,
html.dark .lesson-content table td,
html.dark .lesson-content table th {
  border-color: #334155;
}

/* Fix KaTeX SVG inside quiz options getting stretched */
.exam-question-text .katex svg,
.exam-option-text .katex svg,
.quiz-option .katex svg,
.question-body .katex svg,
.lesson-content .katex svg {
    min-width: 0 !important;
    max-width: none !important;
    height: inherit !important;
    display: block !important;
    position: absolute !important;
    width: 100% !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   سهولة الوصول  [audit المرحلة 13]
   ═══════════════════════════════════════════════════════════════════════════ */

/* مؤشر التركيز — من غيره اللي بيتنقّل بالكيبورد مش عارف هو فين في الصفحة.
   :focus-visible بيظهر للكيبورد بس، مش مع كل ضغطة ماوس. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="radio"]:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
  border-radius: 6px;
}
.dark a:focus-visible,
.dark button:focus-visible,
.dark input:focus-visible,
.dark select:focus-visible,
.dark textarea:focus-visible,
.dark [role="radio"]:focus-visible {
  outline-color: #60a5fa;
}

/* اختيارات الاختبار: التركيز لازم يبان بوضوح لأنه بيتنقّل بالأسهم */
.quiz-option[role="radio"]:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, .15);
}

/* رابط "تخطَّ إلى المحتوى" — أول حاجة يوصلها الكيبورد، ومخفي لحد ما يتركّز */
.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  top: -60px;
  z-index: 9999;
  background: #1a56db;
  color: #fff;
  padding: 10px 20px;
  border-radius: 0 0 12px 12px;
  font-weight: 800;
  text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus {
  top: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   دروبداون فلتر الصف — لغة السايدبار بالحرف

   نفس التدرّج الغامق بتاع .sidebar (#0f172a → #1e293b)، ونفس منطق
   .nav-item للخيارات (highlight أزرق شفاف + خط جانبي عند الاختيار).
   الاتنين بالتوكنز دي بالظبط عشان أي تغيير في لون السايدبار ينعكس هنا
   تلقائي لو حد وحّدهم في توكنز بعدين.
   ═══════════════════════════════════════════════════════════════════════ */
.k-grade-dd { position: relative; }

.k-grade-dd-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid #334155;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  font-family: inherit;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
}
.k-grade-dd-btn:hover { border-color: #3b82f6; }
.k-grade-dd-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, .35); }
.k-grade-dd-btn span { flex: 1; text-align: start; }

.k-grade-dd-chevron { flex-shrink: 0; transition: transform .2s ease; }
.k-grade-dd-btn[aria-expanded="true"] .k-grade-dd-chevron { transform: rotate(180deg); }

.k-grade-dd-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  min-width: 100%;
  width: max-content;
  max-width: 260px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid #334155;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  box-shadow: 0 18px 40px rgba(2, 6, 23, .45);
  animation: kGradeDdIn .16s ease-out both;
}
@keyframes kGradeDdIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* نفس .nav-item بالظبط — نفس الألوان ونفس منطق active */
.k-grade-dd-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin: 2px 0;
  border-radius: 10px;
  color: #94a3b8;
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s ease;
  border-inline-end: 3px solid transparent;
}
.k-grade-dd-opt:hover { background: rgba(26, 86, 219, .15); color: #60a5fa; }
.k-grade-dd-opt.active {
  background: rgba(26, 86, 219, .25);
  color: #93c5fd;
  border-inline-end-color: #3b82f6;
}
.k-grade-dd-opt .k-grade-dd-check { opacity: 0; color: #3b82f6; flex-shrink: 0; }
.k-grade-dd-opt.active .k-grade-dd-check { opacity: 1; }

/* نص للقارئ الصوتي بس — مش ظاهر بالعين */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* احترام تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ودجت أنواع الأسئلة الجديدة (المرحلة 2)

   بتاخد نفس لغة .quiz-option الموجودة فوق — نفس نصف القطر ونفس لون الحد
   ونفس مدة الانتقال — عشان السؤال الجديد يحس إنه من نفس المنصة مش ملزوق.

   ملحوظة اتجاه: الأرقام والفهارس متغلّفة بـdir=ltr و unicode-bidi:isolate،
   لأن الصفحة RTL و«3 / 5» بتتقلب لـ«5 / 3» من غير العزل.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── صح أو خطأ ── */
.tf-row { display: flex; gap: 12px; margin-top: 16px; }
.tf-btn {
  flex: 1; padding: 16px 20px; font-size: 17px; font-weight: 700;
  border: 2px solid #e2e8f0; border-radius: 12px; background: #fff;
  cursor: pointer; transition: all 0.2s;
}
.tf-btn:hover:not(:disabled) { border-color: #3b82f6; background: #eff6ff; }
.tf-btn.selected { border-color: #3b82f6; background: #eff6ff; color: #1d4ed8; }
.tf-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── صحّح ما تحته خط ── */
.underlined-word {
  margin: 12px 0 8px; font-size: 14px; font-weight: 700; color: #475569;
}
.underlined-word u { color: #b91c1c; text-decoration-thickness: 2px; }

/* ── أكمل ── */
.blanks { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.blank-row { display: flex; align-items: center; gap: 10px; }
.blank-num {
  flex: 0 0 28px; height: 28px; border-radius: 50%;
  background: #eff6ff; color: #1d4ed8; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  direction: ltr; unicode-bidi: isolate;
}

/* ── اختر أكتر من إجابة ── */
.ms-hint, .arrange-hint {
  font-size: 13px; font-weight: 700; color: #64748b; margin: 12px 0 8px;
}
.quiz-option .opt-check { margin-inline-end: 10px; font-size: 18px; }
.quiz-option .opt-letter {
  margin-inline-end: 10px; font-weight: 700; color: #64748b;
  direction: ltr; unicode-bidi: isolate;
}
.quiz-option .opt-text { flex: 1; }

/* ── وصّل ── */
.match-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.match-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 2px solid #e2e8f0; border-radius: 12px;
}
.match-left { flex: 1; font-weight: 600; }
.match-select { flex: 0 0 45%; min-width: 140px; }

/* ── رتّب ── */
.arrange-list { display: flex; flex-direction: column; gap: 8px; }
.arrange-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 2px solid #e2e8f0; border-radius: 12px;
  background: #fff;
}
.arr-pos {
  flex: 0 0 28px; height: 28px; border-radius: 8px;
  background: #f1f5f9; color: #334155; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  direction: ltr; unicode-bidi: isolate;
}
.arr-text { flex: 1; }
.arr-ctl { display: flex; flex-direction: column; gap: 2px; }
.arr-btn {
  width: 30px; height: 22px; line-height: 1; font-size: 11px;
  border: 1px solid #cbd5e1; border-radius: 6px; background: #fff;
  cursor: pointer; color: #475569;
}
.arr-btn:hover:not(:disabled) { background: #eff6ff; border-color: #3b82f6; }
.arr-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── نوع مش مدعوم ── */
.widget-unknown {
  padding: 16px; border-radius: 12px; margin-top: 16px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  font-size: 14px; font-weight: 700;
}

/* التركيز بالكيبورد لازم يبان — الودجت كلها قابلة للتنقّل */
.tf-btn:focus-visible, .arr-btn:focus-visible,
.match-select:focus-visible, .quiz-option:focus-visible {
  outline: 3px solid #3b82f6; outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .tf-btn, .arr-btn { transition: none; }
}

/* ── السؤال المقالي (المرحلة 4) ── */
.essay-wrap { margin-top: 16px; }
.essay-input {
  width: 100%; min-height: 130px; resize: vertical; line-height: 1.9;
  font-family: inherit; font-size: 15px;
}
.essay-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px; font-size: 12px; color: #94a3b8; font-weight: 700;
}
.essay-marks {
  background: #eff6ff; color: #1d4ed8; padding: 2px 10px; border-radius: 999px;
  unicode-bidi: isolate;
}
.essay-marks::after { content: ' درجة'; }

/* ═══════════════════════════════════════════════════════════════════════════
   منقولة من css/admin-theme.css — الملف ده **مش مرتبط بأي صفحة** في المشروع
   (ثيم داكن مهجور بيفرض background أسود بـ!important). حاطط تنسيقات البانِي
   فيه كان معناه إن التصميم مش بيتحمّل خالص، والمدرّس بيشوف عناصر عريانة.
   ═══════════════════════════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════════════════════════
   بانِي الأسئلة (المرحلة 3)

   البطاقة بتوري حالة السؤال من غير ما المدرّس يدوّر: الحد الأحمر معناه ناقص،
   والرسالة تحت بتقول ناقص إيه بالظبط — **وقت الكتابة** مش وقت الحفظ.
   ═══════════════════════════════════════════════════════════════════════════ */

.eb-card {
  background: #fff; border: 2px solid #e2e8f0; border-radius: 14px;
  padding: 16px; margin-bottom: 14px;
}
.eb-card.eb-invalid { border-color: #fca5a5; background: #fffbfb; }

.eb-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.eb-num {
  flex: 0 0 30px; height: 30px; border-radius: 9px;
  background: #1e293b; color: #fff; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  direction: ltr; unicode-bidi: isolate;
}
.eb-type { flex: 1; min-width: 150px; }
.eb-marks { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #64748b; }
.eb-mark-input { width: 72px; text-align: center; direction: ltr; unicode-bidi: isolate; }

.eb-tools { display: flex; gap: 4px; margin-inline-start: auto; }
.eb-tool {
  width: 30px; height: 30px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 12px; color: #475569;
}
.eb-tool:hover:not(:disabled) { background: #eff6ff; border-color: #3b82f6; }
.eb-tool:disabled { opacity: 0.3; cursor: not-allowed; }
.eb-tool.eb-del:hover { background: #fef2f2; border-color: #ef4444; }

.eb-input {
  padding: 9px 12px; border: 1.5px solid #e2e8f0; border-radius: 9px;
  font-family: inherit; font-size: 14px; background: #fff;
}
.eb-input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.eb-text { width: 100%; resize: vertical; min-height: 60px; }
.eb-svg { width: 100%; font-family: ui-monospace, monospace; font-size: 12px; direction: ltr; }

.eb-label { display: block; font-size: 12px; font-weight: 700; color: #475569; margin: 10px 0 5px; }
.eb-hint { font-size: 11px; color: #64748b; margin: 4px 0 6px; line-height: 1.6; }

/* المعاينة الحية — المدرّس بيشوف المعادلة مرسومة زي الطالب */
.eb-preview { display: none; }
.eb-preview.eb-preview-on {
  display: block; margin: 8px 0 4px; padding: 10px 12px;
  background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 9px;
  font-size: 14px; color: #1e293b;
}

.eb-opts { display: flex; flex-direction: column; gap: 7px; }
.eb-opt { display: flex; align-items: center; gap: 8px; }
.eb-opt-input { flex: 1; }
.eb-opt-letter {
  flex: 0 0 24px; text-align: center; font-weight: 800; font-size: 12px; color: #64748b;
  direction: ltr; unicode-bidi: isolate;
}
.eb-pick { width: 17px; height: 17px; cursor: pointer; accent-color: #3b82f6; }
.eb-x {
  width: 28px; height: 28px; border: none; background: transparent;
  color: #cbd5e1; cursor: pointer; font-size: 14px; border-radius: 7px;
}
.eb-x:hover { color: #ef4444; background: #fef2f2; }
.eb-add {
  align-self: flex-start; margin-top: 4px; padding: 6px 14px;
  border: 1.5px dashed #cbd5e1; border-radius: 9px; background: #fff;
  color: #475569; font-size: 12px; font-weight: 700; cursor: pointer;
}
.eb-add:hover { border-color: #3b82f6; color: #1d4ed8; background: #eff6ff; }

.eb-radios { display: flex; gap: 16px; }
.eb-radio { display: flex; align-items: center; gap: 6px; font-weight: 700; cursor: pointer; }

.eb-match { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 7px; align-items: center; }
.eb-pair { min-width: 110px; }

.eb-extra { margin-top: 12px; }
.eb-extra summary {
  cursor: pointer; font-size: 12px; font-weight: 700; color: #64748b;
  padding: 5px 0; user-select: none;
}
.eb-extra summary:hover { color: #3b82f6; }

/* رسالة النقص — ظاهرة وقت الكتابة، مش مفاجأة وقت الحفظ */
.eb-err {
  margin-top: 10px; padding: 8px 12px; border-radius: 9px;
  background: #fef2f2; color: #b91c1c; font-size: 12px; font-weight: 700;
}

.eb-empty {
  padding: 32px; text-align: center; color: #94a3b8;
  font-size: 14px; font-weight: 700;
  border: 2px dashed #e2e8f0; border-radius: 14px;
}

.eb-addbar { display: flex; gap: 8px; align-items: center; }
.eb-addbar select { min-width: 160px; }

@media (max-width: 640px) {
  .eb-match { grid-template-columns: 1fr; }
  .eb-tools { margin-inline-start: 0; width: 100%; justify-content: flex-end; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   شاشة تصحيح الأسئلة المقالية (المرحلة 4)

   السؤال بيتعرض مرة واحدة فوق، وتحته إجابات كل الطلاب. ده مش تنظيم شكلي —
   ده اللي بيخلي المصحّح متسق: بيقرا نفس السؤال ورا بعضه فمعياره ما يتغيّرش.
   ═══════════════════════════════════════════════════════════════════════════ */

.eg-status { margin-bottom: 14px; font-size: 13px; font-weight: 700; }
.eg-status .eg-pending { color: #92400e; background: #fffbeb; padding: 7px 14px; border-radius: 9px; display: inline-block; }
.eg-status .eg-done { color: #166534; background: #f0fdf4; padding: 7px 14px; border-radius: 9px; display: inline-block; }

.eg-list { max-height: 62vh; overflow-y: auto; padding-inline-end: 4px; }
.eg-empty { padding: 36px; text-align: center; color: #94a3b8; font-weight: 700; }

.eg-qblock { margin-bottom: 22px; }
.eg-qhead {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; background: #1e293b; color: #fff; border-radius: 12px 12px 0 0;
}
.eg-qnum {
  flex: 0 0 26px; height: 26px; border-radius: 8px; background: rgba(255,255,255,.15);
  font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.eg-qtext { flex: 1; font-weight: 700; font-size: 14px; line-height: 1.6; }
.eg-qcount {
  flex: 0 0 auto; background: #3b82f6; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 800;
}
.eg-model {
  padding: 10px 14px; background: #eff6ff; border-inline-start: 3px solid #3b82f6;
  font-size: 13px; color: #1e40af; line-height: 1.7;
}
.eg-model b { display: block; margin-bottom: 3px; font-size: 11px; }

.eg-card {
  border: 1px solid #e2e8f0; border-top: none; padding: 14px;
  background: #fff;
}
.eg-card:last-child { border-radius: 0 0 12px 12px; }
.eg-student { font-weight: 800; font-size: 13px; color: #334155; margin-bottom: 7px; }
.eg-answer {
  padding: 11px 14px; background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 10px; font-size: 14px; line-height: 1.8; white-space: pre-wrap;
  margin-bottom: 11px;
}
.eg-blank { color: #94a3b8; font-style: normal; }

.eg-rubric { margin-bottom: 11px; }
.eg-rubric-title { font-size: 11px; font-weight: 800; color: #64748b; margin-bottom: 6px; }
.eg-point {
  display: flex; align-items: center; gap: 9px; padding: 7px 11px;
  border: 1.5px solid #e2e8f0; border-radius: 9px; margin-bottom: 5px;
  cursor: pointer; font-size: 13px; transition: all .15s;
}
.eg-point:hover { border-color: #3b82f6; background: #eff6ff; }
.eg-point input { width: 16px; height: 16px; accent-color: #10b981; cursor: pointer; }
.eg-point span:nth-child(2) { flex: 1; }
.eg-pt-mark {
  background: #f1f5f9; color: #475569; padding: 1px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 800;
}
.eg-point input:checked ~ .eg-pt-mark { background: #dcfce7; color: #166534; }

.eg-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.eg-mark { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #64748b; }
.eg-mark-input {
  width: 72px; padding: 7px 10px; text-align: center;
  border: 1.5px solid #cbd5e1; border-radius: 9px; font-family: inherit; font-weight: 800;
}
.eg-outof { font-size: 12px; color: #94a3b8; font-weight: 700; }
.eg-note {
  flex: 1; min-width: 150px; padding: 7px 12px;
  border: 1.5px solid #e2e8f0; border-radius: 9px; font-family: inherit; font-size: 13px;
}
.eg-save { padding: 8px 20px !important; font-size: 13px !important; }

/* مجموع درجات المعيار في البانِي */
.eb-rubric-total {
  margin-top: 9px; padding: 7px 12px; background: #f0fdf4;
  border-radius: 9px; font-size: 12px; font-weight: 700; color: #166534;
}

@media (max-width: 640px) {
  .eg-actions { flex-direction: column; align-items: stretch; }
  .eg-save { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   اقتراحات الذكاء الاصطناعي (المرحلة 5)

   لون الثقة مش زينة — هو أداة توزيع انتباه. الأحمر معناه «الـAI نفسه مش
   متأكد»، فالمدرّس يدّي وقته للحالات دي بدل ما يراجع الكل بنفس التركيز.
   ═══════════════════════════════════════════════════════════════════════════ */

.eg-toolbar {
  display: flex; gap: 9px; margin-bottom: 14px; flex-wrap: wrap;
}
.eg-toolbar button:disabled { opacity: .6; cursor: wait; }

.eg-card-ai { border-inline-start: 3px solid #a78bfa; }

.eg-ai {
  margin: 0 0 11px; padding: 11px 13px; border-radius: 10px;
  border: 1.5px solid #e2e8f0; background: #fafafa;
}
.eg-ai-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 6px; }
.eg-ai-tag { font-size: 11px; font-weight: 800; color: #6d28d9; }
.eg-ai-mark {
  background: #ede9fe; color: #5b21b6; padding: 2px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 800;
}
.eg-ai-conf {
  margin-inline-start: auto; font-size: 11px; font-weight: 800;
  padding: 2px 9px; border-radius: 999px;
}
.eg-ai-why { font-size: 13px; line-height: 1.75; color: #334155; }
.eg-ai-note { margin-top: 5px; font-size: 11px; font-weight: 700; color: #64748b; }

/* ثقة منخفضة — الأهم في المراجعة */
.eg-ai-low { border-color: #fca5a5; background: #fef2f2; }
.eg-ai-low .eg-ai-conf { background: #fee2e2; color: #b91c1c; }
.eg-ai-low .eg-ai-note { color: #b91c1c; }

.eg-ai-mid { border-color: #fcd34d; background: #fffbeb; }
.eg-ai-mid .eg-ai-conf { background: #fef3c7; color: #92400e; }

.eg-ai-high { border-color: #a7f3d0; background: #f0fdf4; }
.eg-ai-high .eg-ai-conf { background: #d1fae5; color: #065f46; }

.eg-ai-unknown .eg-ai-conf { background: #f1f5f9; color: #64748b; }

/* ── اختيار وضع الاختبار في لوحة الأدمن ── */
.mode-picker { display: flex; flex-direction: column; gap: 8px; }
.mode-opt {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 14px; border: 2px solid #e2e8f0; border-radius: 12px;
  cursor: pointer; transition: .15s; background: #fff;
}
.mode-opt:hover { border-color: #3b82f6; background: #f8fbff; }
.mode-opt input { margin-top: 3px; width: 17px; height: 17px; accent-color: #3b82f6; flex: 0 0 auto; }
.mode-opt input:checked ~ div b { color: #1d4ed8; }
.mode-opt b { display: block; font-size: 14px; margin-bottom: 3px; }
.mode-opt span { display: block; font-size: 12px; color: #64748b; line-height: 1.65; }

/* ═══════════════════════════════════════════════════════════════════════════
   صفحة حل الاختبار — نفس بنية وتصميم placement-exam.html

   ليه اتكتبت من الأول تاني

   النسخة الأولى كانت CSS بمحدِّدات موضعية (`> .card:first-child`،
   `> .flex:last-child`) مكتوبة على بنية افترضتها في داش بورد الطالب.
   المحدِّدات دي وقعت على عناصر غلط: `> .flex:last-child` طبّق
   position:fixed على العنصر اللي جواه الاختيارات، فالمحتوى ظهر مكرر
   على الشاشة، وزرار Next بقى بيغيّر السؤال في النسخة اللي مش باينة.

   الدرس: محدِّد موضعي على ماركب مش إنت اللي كتبته = فخ. دلوقتي كل جزء
   في الصفحة ليه معرّف صريح، والماركب نفسه اتعمل على شكل «اعرف مستواك».

   ═══ الوضع الليلي والنهاري ═══

   صفحة «اعرف مستواك» صفحة مستقلة بوضع نهاري ثابت، فألوانها متثبتة جواها.
   لكن داش بورد الطالب فيه زرار وضع ليلي (`.dark` على <html>)، والطالب
   اللي شغّاله مش هينفع تجيله شاشة بيضاء في وشه وسط الامتحان — فكل لون
   هنا متعرّف كـtoken للوضعين.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --xam-bg: #f3f4f6;
  --xam-panel: #ffffff;
  --xam-navy: #1a2744;
  --xam-text: #111827;
  --xam-muted: #6b7280;
  --xam-border: #d1d5db;
  --xam-accent: #3b82f6;
  --xam-accent-soft: #eff6ff;
  --xam-bar: #ffffff;
}

html.dark {
  --xam-bg: #0f1419;
  --xam-panel: #1a1f26;
  --xam-navy: #131a26;
  --xam-text: #e5e9ef;
  --xam-muted: #94a3b8;
  --xam-border: #2d3748;
  --xam-accent: #60a5fa;
  --xam-accent-soft: #1a2740;
  --xam-bar: #161c24;
}

/* ── ملء الشاشة ──
   الشاشة نفسها fixed inset:0 بـz-index أعلى من الهيدر (z-60) والسايدبار،
   فهي بتغطي كل حاجة. وبنخفي الهيدر والسايدبار صريح كمان عشان لو المتصفح
   عمل أي حاجة غريبة مع الـstacking context ما يبقاش فيه شريط ظاهر. */
body.exam-fullscreen { overflow: hidden; }

body.exam-fullscreen #main-sidebar,
body.exam-fullscreen #sidebar-overlay,
body.exam-fullscreen .top-header {
  display: none !important;
}

body.exam-fullscreen #exam-taking-view {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--xam-bg);
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

/* ── الشريط العلوي ── */
#exam-topbar {
  background: var(--xam-navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  height: 56px;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}

#exam-topbar .xt-tiny {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: .6;
}

#exam-topbar .xt-big {
  font-size: 14px;
  font-weight: 800;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#exam-topbar .xt-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#exam-topbar .xt-save {
  font-size: 11px;
  opacity: .75;
  transition: opacity .3s;
  white-space: nowrap;
}

#exam-calc-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .26);
  color: #fff;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: .2s;
  white-space: nowrap;
}

#exam-calc-btn:hover { background: rgba(255, 255, 255, .26); }

#exam-timer {
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1.5px;
  transition: color .3s;
  direction: ltr;
  unicode-bidi: isolate;
}

#exam-timer.warn { color: #ffb020; }
#exam-timer.danger { color: #fca5a5; }

#exam-pbar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, .12);
}

#exam-pbar {
  height: 100%;
  width: 0;
  background: var(--xam-accent);
  transition: width .4s ease;
}

/* ── لوحة السؤال ── */
#exam-main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 26px 16px 24px;
  overflow-y: auto;
}

#exam-qpanel {
  width: 100%;
  max-width: 740px;
  align-self: flex-start;
  background: var(--xam-panel);
  color: var(--xam-text);
  border-radius: 18px;
  padding: 26px 28px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .07);
}

html.dark #exam-qpanel { box-shadow: 0 2px 14px rgba(0, 0, 0, .4); }

/* الجافاسكريبت بيرسم بطاقة جوّانية بكلاس .card — اللوحة نفسها بقت هي
   البطاقة، فبنفكّ تنسيق البطاقة الداخلية عشان ما يبقاش فيه إطار جوه إطار */
body.exam-fullscreen #exam-questions-container > .card {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  border-radius: 0;
}

body.exam-fullscreen #exam-questions-container,
body.exam-fullscreen #exam-questions-container p,
body.exam-fullscreen #exam-questions-container label,
body.exam-fullscreen #exam-questions-container span,
body.exam-fullscreen #exam-questions-container div {
  color: var(--xam-text);
}

/* سطر «السؤال ١ من ١٣ — درجتان» — أول عنصر جوه البطاقة */
body.exam-fullscreen #exam-questions-container .exam-q-meta {
  font-size: 13px;
  font-weight: 800;
  color: var(--xam-muted);
  border-bottom: 1px solid var(--xam-border);
  padding-bottom: 10px;
  margin-bottom: 16px;
}

body.exam-fullscreen #exam-questions-container .exam-q-text {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.6;
  margin-bottom: 18px;
}

/* الاختيارات */
body.exam-fullscreen .quiz-option {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  margin-bottom: 9px;
  border: 1.5px solid var(--xam-border);
  border-radius: 10px;
  background: var(--xam-panel);
  color: var(--xam-text);
  font-size: 15px;
  cursor: pointer;
  transition: .15s;
}

body.exam-fullscreen .quiz-option:hover:not(.quiz-state-disabled) {
  border-color: var(--xam-accent);
  background: var(--xam-accent-soft);
}

body.exam-fullscreen .quiz-option.quiz-state-selected {
  border-color: var(--xam-accent);
  background: var(--xam-accent-soft);
}

body.exam-fullscreen .quiz-option.quiz-state-correct {
  border-color: #16a34a;
  background: rgba(22, 163, 74, .12);
}

body.exam-fullscreen .quiz-option.quiz-state-wrong {
  border-color: #dc2626;
  background: rgba(220, 38, 38, .12);
}

body.exam-fullscreen .quiz-option.quiz-state-disabled {
  cursor: default;
  opacity: .85;
}

/* حقول الإدخال (أكمل، مصطلح علمي، علّل …) */
body.exam-fullscreen #exam-questions-container input[type="text"],
body.exam-fullscreen #exam-questions-container input[type="number"],
body.exam-fullscreen #exam-questions-container textarea,
body.exam-fullscreen #exam-questions-container select {
  background: var(--xam-panel);
  color: var(--xam-text);
  border: 1.5px solid var(--xam-border);
}

body.exam-fullscreen #exam-questions-container input:focus,
body.exam-fullscreen #exam-questions-container textarea:focus,
body.exam-fullscreen #exam-questions-container select:focus {
  border-color: var(--xam-accent);
  outline: none;
}

/* ── الشريط السفلي ── */
#exam-bottombar {
  flex-shrink: 0;
  background: var(--xam-bar);
  border-top: 1px solid var(--xam-border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .08);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  min-height: 62px;
}

.xnav-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 26px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  background: var(--xam-navy);
  color: #fff;
  transition: .2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.xnav-btn:hover:not(:disabled) { filter: brightness(1.25); }
.xnav-btn:disabled { opacity: .35; cursor: not-allowed; }

.xnav-btn.ghost {
  background: none;
  color: var(--xam-muted);
  border: 1.5px solid var(--xam-border);
}

.xnav-btn.ghost:hover:not(:disabled) {
  border-color: var(--xam-accent);
  color: var(--xam-accent);
}

.xnav-btn.submit { background: #16a34a; color: #fff; }

/* في الوضع الليلي الكحلي بيبقى تقريبًا نفس لون الشريط نفسه — قِستها في
   المعاينة: الزرار rgb(19,26,38) والشريط rgb(22,28,36)، يعني «السؤال
   التالي» بيختفي خالص. فبقى أزرق فاتح بنص غامق. */
html.dark .xnav-btn {
  background: var(--xam-accent);
  color: #0f1419;
}

html.dark .xnav-btn:hover:not(:disabled) { filter: brightness(1.12); }
html.dark .xnav-btn.submit { background: #22c55e; color: #0f1419; }
html.dark .xnav-btn.ghost { background: none; color: var(--xam-muted); }

/* ترقيم الأسئلة تحت — الجزء اللي كان ناقص خالص */
/* الترقيم بيلف على أكتر من سطر والشريط بيكبر معاه — زي «اعرف مستواك» بالظبط.
   جرّبت الأول max-height: 64px مع overflow-y، وفي المعاينة على شاشة ضيّقة
   (13 سؤال / 344px) السطرين اللي بيوصلوا اتقصّوا لسطر وتلت، والسؤال الحالي
   نفسه خرج بره النظر. الشريط يكبر أحسن من إن الطالب ميعرفش هو فين.
   الـ30vh سقف أمان للامتحانات الطويلة جدًا بس. */
#exam-qdots {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 6px;
  max-height: 30vh;
  overflow-y: auto;
}

.xdot {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--xam-border);
  background: var(--xam-panel);
  color: var(--xam-muted);
  font-size: 12px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  direction: ltr;
  unicode-bidi: isolate;
  flex-shrink: 0;
  padding: 0;
}

.xdot:hover { border-color: var(--xam-accent); }

/* اتجاوب عليه */
.xdot.answered {
  background: var(--xam-accent-soft);
  border-color: var(--xam-accent);
  color: var(--xam-accent);
}

/* السؤال الحالي — أقوى من answered */
.xdot.current {
  background: var(--xam-navy);
  border-color: var(--xam-navy);
  color: #fff;
}

html.dark .xdot.current {
  background: var(--xam-accent);
  border-color: var(--xam-accent);
  color: #0f1419;
}

/* في التدريب بتصحيح فوري: الترقيم بيوضّح صح/غلط */
.xdot.dot-correct {
  background: rgba(22, 163, 74, .14);
  border-color: #16a34a;
  color: #16a34a;
}

.xdot.dot-wrong {
  background: rgba(220, 38, 38, .14);
  border-color: #dc2626;
  color: #dc2626;
}

/* شريط تأكيد الإجابة (بيظهر في وضع التصحيح الفوري بس) */
body.exam-fullscreen .exam-confirm-bar {
  margin: 16px 0 0;
}

@media (max-width: 640px) {
  #exam-topbar { height: 52px; padding: 0 12px; }
  #exam-topbar .xt-big { max-width: 34vw; }
  #exam-timer { font-size: 18px; }
  #exam-calc-btn span:last-child { display: none; }
  #exam-topbar .xt-save { display: none; }
  #exam-main { padding: 16px 10px; }
  #exam-qpanel { padding: 18px 16px; border-radius: 14px; }
  #exam-bottombar { padding: 9px 10px; gap: 8px; }
  .xnav-btn { padding: 9px 16px; font-size: 13px; }
  .xdot { width: 26px; height: 26px; font-size: 11px; border-radius: 7px; }
}

/* حرف الاختيار (A. B. C.) بيجي من الجافاسكريبت بكلاس text-slate-600 —
   ولونه ده على اللوحة الغامقة تقريبًا مش باين */
body.exam-fullscreen .quiz-option > span:first-child { color: var(--xam-muted) !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   الوضع الليلي لودجت الأنواع الجديدة

   ودجت الأحد عشر نوع كلها اتكتبت بألوان نهارية مثبتة (#fff، #e2e8f0،
   #f1f5f9 …) ومن غير أي بديل ليلي — فعلى الوضع الليلي «رتّب» و«وصّل»
   و«صح/خطأ» كانوا بيطلعوا صفوف فاتحة بنص مش باين.

   الودجت دي بتظهر في صفحة الاختبار وفي الواجب التفاعلي، فالقواعد دي
   مربوطة بـhtml.dark مباشرة — مش بـbody.exam-fullscreen — عشان تشتغل في
   المكانين. الألوان من نفس التوكنز المعرّفة على :root فوق.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── صح أو خطأ ── */
html.dark .tf-btn {
  background: var(--xam-panel);
  border-color: var(--xam-border);
  color: var(--xam-text);
}
html.dark .tf-btn:hover:not(:disabled) {
  border-color: var(--xam-accent);
  background: var(--xam-accent-soft);
}
html.dark .tf-btn.selected {
  border-color: var(--xam-accent);
  background: var(--xam-accent-soft);
  color: var(--xam-accent);
}

/* ── صحّح ما تحته خط ── */
html.dark .underlined-word { color: var(--xam-muted); }
html.dark .underlined-word u { color: #f87171; }

/* ── أكمل ── */
html.dark .blank-num {
  background: var(--xam-accent-soft);
  color: var(--xam-accent);
}

/* ── تلميحات ── */
html.dark .ms-hint,
html.dark .arrange-hint { color: var(--xam-muted); }
html.dark .quiz-option .opt-letter { color: var(--xam-muted); }

/* ── وصّل ── */
html.dark .match-row {
  border-color: var(--xam-border);
  background: var(--xam-panel);
  color: var(--xam-text);
}
html.dark .match-select {
  background: var(--xam-panel);
  border-color: var(--xam-border);
  color: var(--xam-text);
}

/* ── رتّب ── */
html.dark .arrange-row {
  background: var(--xam-panel);
  border-color: var(--xam-border);
  color: var(--xam-text);
}
html.dark .arr-pos {
  background: #232a34;
  color: var(--xam-text);
}
html.dark .arr-btn {
  background: #232a34;
  border-color: var(--xam-border);
  color: var(--xam-text);
}
html.dark .arr-btn:hover:not(:disabled) {
  background: var(--xam-accent-soft);
  border-color: var(--xam-accent);
}

/* ── المقالي ── */
html.dark .essay-meta { color: var(--xam-muted); }
html.dark .essay-marks {
  background: var(--xam-accent-soft);
  color: var(--xam-accent);
}

/* ── نوع مش مدعوم ── */
html.dark .widget-unknown {
  background: #2a2315;
  border-color: #5a4a1f;
  color: #fbbf24;
}

/* ═══════════════════════════════════════════════════════════════════════════
   زرار الخروج من الاختبار

   الصفحة بملء الشاشة والسايدبار مخفي، وزرار «رجوع» بتاع المتصفح مبيرجّعش
   (الصفحة واحدة والتنقّل بالجافاسكريبت)، فمكانش فيه أي مخرج غير التسليم.
   ═══════════════════════════════════════════════════════════════════════════ */
#exam-exit-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .2s;
  margin-inline-end: 4px;
}

#exam-exit-btn:hover {
  background: #dc2626;
  border-color: #dc2626;
}

#exam-topbar .xt-left { flex: 1; min-width: 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   موديول إنشاء/تعديل الاختبار — مقاس أكبر

   الموديولين دول مش زي أي موديول تاني في اللوحة: جواهم بانِي أسئلة كامل
   بـ11 نوع، وكل سؤال ليه اختيارات ودرجات ومعيار تصحيح. على 1100px كان
   البانِي بيتخانق على العرض والأدمن بيقعد يمرّر لفوق وتحت.

   المقاس هنا في CSS مش inline: الموديولين بياخدوا نفس الكلاس، فأي تعديل
   في المقاس بيحصل في مكان واحد.
   ═══════════════════════════════════════════════════════════════════════════ */
.modal-box.modal-box-exam {
  max-width: min(1500px, 97vw);
  width: 97vw;
  max-height: 95vh;
  padding: 26px 28px;
}

/* البانِي بياخد كل المساحة المتاحة جوه الموديول الأكبر */
.modal-box-exam #exam-questions-builder,
.modal-box-exam #edit-exam-questions-builder {
  max-height: none;
  overflow: visible;
}

@media (max-width: 900px) {
  .modal-box.modal-box-exam {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    padding: 18px 14px;
  }
}

/* تنبيه تغيير الوضع على امتحان عليه نتائج */
.mode-warn {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.7;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 9px 12px;
}

html.dark .mode-warn {
  color: #fbbf24;
  background: #2a2315;
  border-color: #5a4a1f;
}

/* أزرار الحفظ ملزوقة تحت.
   الموديول بقى بيمرّر كوحدة واحدة (شيلنا تمرير البانِي الداخلي — تمرير
   جوه تمرير مربك)، فمن غير اللزق ده الأدمن بيقعد يمرّر لآخر ٣٠ سؤال
   عشان يوصل لزرار الحفظ. */
.exam-modal-actions {
  position: sticky;
  bottom: -26px;
  background: white;
  padding: 14px 0;
  margin-top: 18px !important;
  border-top: 1px solid #e2e8f0;
  z-index: 5;
}

html.dark .exam-modal-actions {
  background: #1a1f26;
  border-top-color: #2d3748;
}

@media (max-width: 900px) {
  .exam-modal-actions { bottom: -18px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   بنك الأسئلة

   البطاقات شبكة مش قايمة: المدرّس بيمسح بعينه على عشرين سؤال ويقرر، مش
   بيقرا سؤال سؤال. والبطاقات بارتفاع متساوي عشان المسح بالعين يبقى أسرع —
   النص الطويل بيتقطع بـline-clamp.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── أزرار البنك في شريط الإضافة ── */
.qb-open-btn,
.qb-save-btn {
  border: 1.5px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 10px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: .18s;
  white-space: nowrap;
}

.qb-open-btn:hover { background: #e0e7ff; border-color: #818cf8; }

.qb-save-btn {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}
.qb-save-btn:hover { background: #dcfce7; border-color: #4ade80; }

html.dark .qb-open-btn { background: #1e2540; border-color: #3b4a7a; color: #a5b4fc; }
html.dark .qb-open-btn:hover { background: #263056; }
html.dark .qb-save-btn { background: #14251b; border-color: #2f5c3d; color: #86efac; }
html.dark .qb-save-btn:hover { background: #1a3324; }

/* ── الفلاتر ── */
.qb-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px;
  margin-bottom: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
}

html.dark .qb-filters { background: #161c24; border-color: #2d3748; }

.qb-filters .eb-input { min-width: 132px; flex: 0 1 auto; }
.qb-filters .qb-search { flex: 1 1 260px; min-width: 200px; }

.qb-clear {
  border: 1.5px solid #e2e8f0;
  background: none;
  color: #64748b;
  border-radius: 9px;
  padding: 7px 13px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.qb-clear:hover { border-color: #94a3b8; color: #334155; }
html.dark .qb-clear { border-color: #2d3748; color: #94a3b8; }
html.dark .qb-clear:hover { color: #e5e9ef; }

/* ── شبكة النتائج ── */
.qb-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  min-height: 180px;
}

.qb-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: .16s;
  position: relative;
}

.qb-card:hover { border-color: #818cf8; }

.qb-card.is-on {
  border-color: #4f46e5;
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

html.dark .qb-card { background: #1a1f26; border-color: #2d3748; }
html.dark .qb-card:hover { border-color: #6366f1; }
html.dark .qb-card.is-on { background: #1e2540; border-color: #6366f1; }

.qb-check {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: #4f46e5;
}

.qb-body { flex: 1; min-width: 0; }

.qb-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
}

.qb-type {
  font-size: 11px;
  font-weight: 800;
  color: #4338ca;
  background: #eef2ff;
  border-radius: 999px;
  padding: 2px 9px;
}

.qb-marks {
  font-size: 11px;
  font-weight: 800;
  color: #1d4ed8;
  background: #eff6ff;
  border-radius: 999px;
  padding: 2px 9px;
  unicode-bidi: isolate;
}
/* «٣ درجة» بدل «3» لوحده — بس من غير ما الرقم يتقلب في صفحة RTL */
.qb-marks::after { content: ' درجة'; }

.qb-diff { font-size: 11px; font-weight: 800; border-radius: 999px; padding: 2px 9px; }
.qb-diff-easy   { color: #15803d; background: #f0fdf4; }
.qb-diff-medium { color: #b45309; background: #fffbeb; }
.qb-diff-hard   { color: #b91c1c; background: #fef2f2; }

.qb-used {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 2px 9px;
}

html.dark .qb-type   { color: #a5b4fc; background: #1e2540; }
html.dark .qb-marks  { color: #93c5fd; background: #1a2740; }
html.dark .qb-used   { color: #94a3b8; background: #232a34; }
html.dark .qb-diff-easy   { color: #86efac; background: #14251b; }
html.dark .qb-diff-medium { color: #fbbf24; background: #2a2315; }
html.dark .qb-diff-hard   { color: #fca5a5; background: #2a1717; }

.qb-text {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.65;
  color: #1e293b;
  /* البطاقات بارتفاع متقارب — أسرع في المسح بالعين */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

html.dark .qb-text { color: #e5e9ef; }

.qb-class {
  margin-top: 7px;
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
}
html.dark .qb-class { color: #94a3b8; }

.qb-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }

.qb-tag {
  font-size: 10.5px;
  font-weight: 700;
  color: #475569;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 1px 7px;
}
html.dark .qb-tag { color: #cbd5e1; background: #232a34; }

.qb-actions {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  opacity: 0;
  transition: opacity .16s;
}
.qb-card:hover .qb-actions { opacity: 1; }

.qb-del {
  border: none;
  background: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 7px;
  opacity: .55;
}
.qb-del:hover { opacity: 1; background: #fef2f2; }
html.dark .qb-del:hover { background: #2a1717; }

.qb-empty {
  grid-column: 1 / -1;
  padding: 44px 20px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 700;
  color: #64748b;
  line-height: 1.9;
}
html.dark .qb-empty { color: #94a3b8; }

/* ── ترقيم الصفحات ── */
.qb-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.qb-page {
  border: 1.5px solid #e2e8f0;
  background: #fff;
  color: #334155;
  border-radius: 9px;
  padding: 7px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.qb-page:hover:not(:disabled) { border-color: #818cf8; color: #4338ca; }
.qb-page:disabled { opacity: .35; cursor: not-allowed; }

html.dark .qb-page { background: #1a1f26; border-color: #2d3748; color: #e5e9ef; }

.qb-count {
  font-size: 12.5px;
  font-weight: 700;
  color: #64748b;
  unicode-bidi: isolate;
}
html.dark .qb-count { color: #94a3b8; }

/* ── تقرير الأسئلة المرفوضة ── */
.qb-report {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12.5px;
  line-height: 1.8;
  max-height: 240px;
  overflow-y: auto;
}
.qb-report ul { margin: 8px 0 0; padding-inline-start: 18px; }
.qb-report li { margin-bottom: 8px; }
.qb-report li span { font-weight: 700; color: #b45309; }

html.dark .qb-report { background: #2a2315; border-color: #5a4a1f; color: #fbbf24; }
html.dark .qb-report li span { color: #fcd34d; }

@media (max-width: 640px) {
  .qb-results { grid-template-columns: 1fr; }
  .qb-filters { padding: 9px; }
  .qb-filters .eb-input { min-width: 0; flex: 1 1 46%; }
  .qb-actions { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   الوضع الليلي لبانِي الأسئلة وشاشة التصحيح

   بانِي الأسئلة وشاشة التصحيح اتكتبوا بألوان نهارية مثبتة (#fff، #e2e8f0،
   #f8fafc) ومن غير أي بديل ليلي — زي ودجت الطالب بالظبط.

   اللي كان بيحصل: خانة `.eb-input` خلفيتها بيضا ثابتة، ولون النص بييجي
   بالوراثة من الوضع الليلي (فاتح). يعني نص فاتح على خلفية بيضا — المدرّس
   بيكتب سؤال وهو مش شايف حرف. قِستها في المعاينة: الخلفية
   rgb(255,255,255) والنص rgb(229,231,235).

   الظهر ده اتكشف وأنا بعمل فلاتر بنك الأسئلة (بتستخدم نفس `.eb-input`)،
   بس هو موجود في البانِي نفسه من الأول — مش حاجة البنك جابها.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── بطاقة السؤال ── */
html.dark .eb-card {
  background: #1a1f26;
  border-color: #2d3748;
  color: #e5e9ef;
}
html.dark .eb-card.eb-invalid { border-color: #b91c1c; background: #241618; }

html.dark .eb-num { background: #0f1419; color: #e5e9ef; }
html.dark .eb-marks { color: #94a3b8; }
html.dark .eb-label { color: #cbd5e1; }
html.dark .eb-hint { color: #94a3b8; }
html.dark .eb-opt-letter { color: #94a3b8; }

/* ── خانات الإدخال — أهم واحدة هنا ── */
html.dark .eb-input,
html.dark .eb-text,
html.dark .eb-svg,
html.dark .eb-mark-input,
html.dark .eb-pair,
html.dark .eb-opt-input {
  background: #0f1419;
  border-color: #2d3748;
  color: #e5e9ef;
}

html.dark .eb-input::placeholder { color: #64748b; }

html.dark .eb-input:focus,
html.dark .eb-text:focus,
html.dark .eb-svg:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .16);
}

/* ── الأزرار الصغيرة ── */
html.dark .eb-tool {
  background: #232a34;
  border-color: #2d3748;
  color: #e5e9ef;
}
html.dark .eb-tool:hover:not(:disabled) { background: #1a2740; border-color: #60a5fa; }
html.dark .eb-tool.eb-del:hover { background: #2a1717; border-color: #dc2626; }

html.dark .eb-x { color: #4a5568; }
html.dark .eb-x:hover { color: #fca5a5; background: #2a1717; }

html.dark .eb-add {
  background: #232a34;
  border-color: #2d3748;
  color: #cbd5e1;
}
html.dark .eb-add:hover { border-color: #60a5fa; color: #93c5fd; background: #1a2740; }

/* ── المعاينة والرسائل ── */
html.dark .eb-preview.eb-preview-on {
  background: #161c24;
  border-color: #2d3748;
  color: #e5e9ef;
}

html.dark .eb-err { background: #2a1717; color: #fca5a5; }

html.dark .eb-empty { color: #64748b; border-color: #2d3748; }

html.dark .eb-extra summary { color: #94a3b8; }
html.dark .eb-extra summary:hover { color: #60a5fa; }

html.dark .eb-rubric-total { background: #14251b; color: #86efac; }


/* ═══════════════════════════════════════════════════════════════════════════
   شاشة التصحيح
   ═══════════════════════════════════════════════════════════════════════════ */

html.dark .eg-status .eg-pending { color: #fbbf24; background: #2a2315; }
html.dark .eg-status .eg-done { color: #86efac; background: #14251b; }
html.dark .eg-empty { color: #64748b; }

html.dark .eg-qhead { background: #0f1419; color: #e5e9ef; }
html.dark .eg-qcount { background: #2563eb; }

html.dark .eg-model {
  background: #1a2740;
  border-inline-start-color: #60a5fa;
  color: #bfdbfe;
}

html.dark .eg-card { background: #1a1f26; border-color: #2d3748; color: #e5e9ef; }
html.dark .eg-student { color: #cbd5e1; }

html.dark .eg-answer {
  background: #0f1419;
  border-color: #2d3748;
  color: #e5e9ef;
}
html.dark .eg-blank { color: #64748b; }

html.dark .eg-rubric-title { color: #94a3b8; }

html.dark .eg-point {
  border-color: #2d3748;
  background: #1a1f26;
  color: #e5e9ef;
}
html.dark .eg-point:hover { border-color: #60a5fa; background: #1a2740; }
html.dark .eg-pt-mark { background: #232a34; color: #cbd5e1; }
html.dark .eg-point input:checked ~ .eg-pt-mark { background: #14251b; color: #86efac; }

html.dark .eg-mark { color: #94a3b8; }
html.dark .eg-outof { color: #64748b; }

html.dark .eg-mark-input,
html.dark .eg-note {
  background: #0f1419;
  border-color: #2d3748;
  color: #e5e9ef;
}

/* ── اقتراحات الذكاء الاصطناعي ── */
html.dark .eg-ai { background: #161c24; border-color: #2d3748; color: #e5e9ef; }
html.dark .eg-ai-tag { color: #c4b5fd; }
html.dark .eg-ai-mark { background: #2a2340; color: #c4b5fd; }
html.dark .eg-card-ai { border-inline-start-color: #8b5cf6; }

/* ═══════════════════════════════════════════════════════════════════════════
   إظهار وإخفاء أقسام الصفحة الرئيسية (لوحة الأدمن)

   مفتاح فعلي مش checkbox: الحالة لازم تبان من بعد الشاشة، لأن الغلط هنا
   بيظهر على الموقع العام لكل الزوار. والصف المخفي بيبهت كله — مش بس
   المفتاح — عشان المدرّس يعرف بنظرة واحدة إيه المقفول.
   ═══════════════════════════════════════════════════════════════════════════ */
.ls-note {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.85;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 10px 14px;
  margin: 14px 0 16px;
}
html.dark .ls-note { color: #fbbf24; background: #2a2315; border-color: #5a4a1f; }

.ls-list { display: flex; flex-direction: column; gap: 9px; }

.ls-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  transition: opacity .18s, border-color .18s, background .18s;
}
html.dark .ls-row { background: #1a1f26; border-color: #2d3748; }

.ls-row.is-off { opacity: .58; border-style: dashed; }

.ls-info { flex: 1; min-width: 0; }
.ls-info b { display: block; font-size: 14.5px; font-weight: 900; color: #1e293b; }
.ls-info span { display: block; font-size: 12px; font-weight: 700; color: #64748b; margin-top: 3px; }
html.dark .ls-info b { color: #e5e9ef; }
html.dark .ls-info span { color: #94a3b8; }

.ls-state {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 900;
  border-radius: 999px;
  padding: 3px 11px;
  background: #dcfce9;
  color: #15803d;
}
.ls-row.is-off .ls-state { background: #f1f5f9; color: #64748b; }
html.dark .ls-state { background: #14251b; color: #86efac; }
html.dark .ls-row.is-off .ls-state { background: #232a34; color: #94a3b8; }

.ls-switch {
  flex: 0 0 auto;
  width: 52px;
  height: 30px;
  border: none;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  padding: 3px;
  transition: background .2s;
  position: relative;
}
html.dark .ls-switch { background: #3a4658; }
.ls-switch.on { background: #16a34a; }

.ls-knob {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .28);
  /* الحركة بـtransform مش بـmargin: transform بتتحرك على كارت الرسوميات
     من غير إعادة تخطيط */
  transform: translateX(0);
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1);
}
/* الصفحة RTL: المفتاح المفتوح بيروح لليسار بصريًا */
.ls-switch.on .ls-knob { transform: translateX(-22px); }

.ls-switch:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }

@media (max-width: 560px) {
  .ls-row { flex-wrap: wrap; gap: 10px; }
  .ls-info { flex: 1 1 100%; }
}
