/* Williams Education Training Portal – Custom Styles */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: #f8fafc; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Layout ── */
#app { min-height: 100vh; }

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

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1e3a8a 0%, #1d4ed8 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.1rem; font-weight: 700; color: white; text-decoration: none;
}
.sidebar-logo i { font-size: 1.4rem; color: #fbbf24; }

.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-section { padding: 8px 20px 4px; font-size: 0.65rem; font-weight: 600; color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 0.08em; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.15s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active { background: rgba(255,255,255,0.15); color: white; font-weight: 600; border-right: 3px solid #fbbf24; }
.nav-item i { width: 18px; text-align: center; font-size: 0.9rem; }
.nav-badge { margin-left: auto; background: #ef4444; color: white; font-size: 0.65rem; font-weight: 700; padding: 1px 6px; border-radius: 10px; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.12); }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #3b82f6; display: flex; align-items: center; justify-content: center; font-weight: 700; color: white; font-size: 0.85rem; flex-shrink: 0; }
.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 0.82rem; font-weight: 600; color: white; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 0.7rem; color: rgba(255,255,255,0.55); text-transform: capitalize; }

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

.topbar {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: #1e293b; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-content { flex: 1; padding: 28px 28px 40px; width: 100%; min-width: 0; box-sizing: border-box; }

/* ── Cards ── */
.card {
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); }
.card-header { padding: 18px 20px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 0.95rem; font-weight: 700; color: #1e293b; }
.card-body { padding: 20px; }

/* ── Stat cards ── */
.stat-card {
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: #1e293b; line-height: 1; }
.stat-label { font-size: 0.78rem; color: #64748b; margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; }
.btn-ghost { background: transparent; color: #64748b; border: 1px solid #e2e8f0; }
.btn-ghost:hover { background: #f8fafc; color: #1e293b; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 0.72rem; border-radius: 5px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #1e293b;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-textarea { min-height: 100px; resize: vertical; font-family: inherit; }
.form-hint { font-size: 0.75rem; color: #9ca3af; margin-top: 3px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.855rem; }
thead th { background: #f8fafc; padding: 10px 14px; text-align: left; font-size: 0.75rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid #e2e8f0; }
tbody td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; color: #334155; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── Progress bars ── */
.progress-bar { background: #e2e8f0; border-radius: 20px; height: 8px; overflow: hidden; }
.progress-fill { background: linear-gradient(90deg, #2563eb, #3b82f6); height: 100%; border-radius: 20px; transition: width 0.4s ease; }
.progress-fill.green { background: linear-gradient(90deg, #10b981, #34d399); }
.progress-fill.yellow { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

/* ── Module cards ── */
.module-card {
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
}
.module-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); border-color: #bfdbfe; }
.module-card-cover { height: 120px; background: linear-gradient(135deg, #1e3a8a, #3b82f6); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; color: rgba(255,255,255,0.7); }
.module-card-body { padding: 16px; }
.module-card-title { font-size: 0.95rem; font-weight: 700; color: #1e293b; margin-bottom: 6px; line-height: 1.3; }
.module-card-desc { font-size: 0.78rem; color: #64748b; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 12px; }
.module-card-meta { display: flex; gap: 12px; font-size: 0.75rem; color: #94a3b8; }

/* ── Lesson viewer ── */
.lesson-content { line-height: 1.75; color: #334155; }
.lesson-content h1, .lesson-content h2 { color: #1e293b; font-weight: 700; margin: 1.5em 0 0.5em; }
.lesson-content h2 { font-size: 1.2rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 6px; }
.lesson-content h3 { font-size: 1rem; color: #1d4ed8; margin: 1.2em 0 0.4em; }
.lesson-content p { margin: 0.8em 0; }
.lesson-content ul, .lesson-content ol { padding-left: 1.5em; margin: 0.8em 0; }
.lesson-content li { margin: 0.3em 0; }
.lesson-content table { border-collapse: collapse; margin: 1em 0; width: auto; }
.lesson-content table th, .lesson-content table td { border: 1px solid #e2e8f0; padding: 8px 12px; }
.lesson-content table th { background: #f8fafc; font-weight: 700; }
.lesson-content strong { color: #1d4ed8; }
.lesson-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 0.88em; }
.lesson-content iframe { width: 100%; height: 450px; border: none; border-radius: 8px; margin: 1em 0; }

/* ── Quiz ── */
.quiz-question { background: white; border-radius: 10px; border: 1px solid #e2e8f0; padding: 20px; margin-bottom: 16px; }
.quiz-question-text { font-size: 0.95rem; font-weight: 600; color: #1e293b; margin-bottom: 14px; }
.quiz-option { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 2px solid #e2e8f0; border-radius: 8px; margin-bottom: 8px; cursor: pointer; transition: all 0.15s; }
.quiz-option:hover { border-color: #93c5fd; background: #eff6ff; }
.quiz-option.selected { border-color: #2563eb; background: #eff6ff; }
.quiz-option.correct { border-color: #10b981; background: #d1fae5; }
.quiz-option.incorrect { border-color: #ef4444; background: #fee2e2; }
.quiz-option input { accent-color: #2563eb; }
/* Multi-select quiz options use square checkboxes visually */
.quiz-option-multi { border-radius: 8px; }
.quiz-option-multi.selected { border-color: #2563eb; background: #eff6ff; }
.quiz-option-multi input[type="checkbox"] { accent-color: #2563eb; }

/* ── Q&A ── */
.question-thread { border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.question-thread-header { padding: 14px 16px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.answer-bubble { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; display: flex; gap: 12px; }
.answer-bubble:last-child { border-bottom: none; }
.answer-bubble.admin-answer { background: #eff6ff; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: white; border-radius: 14px; width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.05rem; font-weight: 700; color: #1e293b; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f1f5f9; display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 1.2rem; color: #94a3b8; cursor: pointer; }
.modal-close:hover { color: #1e293b; }

/* ── Login page ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #3b82f6 100%); }
.login-card { background: white; border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 24px 64px rgba(0,0,0,0.25); }
.login-logo { font-size: 3rem; color: #2563eb; margin-bottom: 8px; }
.login-title { font-size: 1.5rem; font-weight: 800; color: #1e293b; margin-bottom: 4px; }
.login-subtitle { color: #64748b; font-size: 0.9rem; margin-bottom: 32px; }

/* ── Alert/Toast ── */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  padding: 12px 20px;
  border-radius: 10px;
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transform: translateX(110%);
  transition: transform 0.3s ease;
  max-width: 360px;
  display: flex; align-items: center; gap: 10px;
}
.toast.show { transform: translateX(0); }
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.info { background: #2563eb; }
.toast.warning { background: #f59e0b; }

/* ── Quill rich text editor ── */
.quill-block-wrap { border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.quill-block-wrap .ql-toolbar.ql-snow {
  border: none;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 8px 8px 0 0;
  padding: 6px 8px;
}
.quill-block-wrap .ql-container.ql-snow {
  border: none;
  font-size: 0.9rem;
  font-family: inherit;
}
.quill-editor-area { min-height: 200px; }
.quill-block-wrap .ql-editor { min-height: 200px; padding: 12px 16px; line-height: 1.7; }
.quill-block-wrap .ql-editor:focus { box-shadow: 0 0 0 3px rgba(37,99,235,0.08) inset; }
.quill-block-wrap .ql-editor.ql-blank::before { color: #94a3b8; font-style: italic; }
/* Legacy editor classes kept for any leftover references */
.editor-toolbar { display: none; }
.editor-btn { display: none; }
.editor-area { display: none; }

/* ── Quill custom font families ── */
.ql-font-arial,       .ql-editor .ql-font-arial       { font-family: Arial, sans-serif; }
.ql-font-georgia,     .ql-editor .ql-font-georgia      { font-family: Georgia, serif; }
.ql-font-times-new-roman, .ql-editor .ql-font-times-new-roman { font-family: 'Times New Roman', Times, serif; }
.ql-font-trebuchet,   .ql-editor .ql-font-trebuchet    { font-family: 'Trebuchet MS', sans-serif; }
.ql-font-verdana,     .ql-editor .ql-font-verdana      { font-family: Verdana, Geneva, sans-serif; }
.ql-font-tahoma,      .ql-editor .ql-font-tahoma       { font-family: Tahoma, Geneva, sans-serif; }
.ql-font-courier-new, .ql-editor .ql-font-courier-new  { font-family: 'Courier New', Courier, monospace; }
.ql-font-palatino,    .ql-editor .ql-font-palatino     { font-family: Palatino, 'Palatino Linotype', serif; }
.ql-font-garamond,    .ql-editor .ql-font-garamond     { font-family: Garamond, 'EB Garamond', serif; }
.ql-font-comic-sans,  .ql-editor .ql-font-comic-sans   { font-family: 'Comic Sans MS', cursive; }

/* Quill font picker — show font names in their own typeface */
.ql-picker.ql-font .ql-picker-label[data-value=arial]::before,
.ql-picker.ql-font .ql-picker-item[data-value=arial]::before   { content: 'Arial'; font-family: Arial, sans-serif; }
.ql-picker.ql-font .ql-picker-label[data-value=georgia]::before,
.ql-picker.ql-font .ql-picker-item[data-value=georgia]::before { content: 'Georgia'; font-family: Georgia, serif; }
.ql-picker.ql-font .ql-picker-label[data-value=times-new-roman]::before,
.ql-picker.ql-font .ql-picker-item[data-value=times-new-roman]::before { content: 'Times New Roman'; font-family: 'Times New Roman', serif; }
.ql-picker.ql-font .ql-picker-label[data-value=trebuchet]::before,
.ql-picker.ql-font .ql-picker-item[data-value=trebuchet]::before { content: 'Trebuchet MS'; font-family: 'Trebuchet MS', sans-serif; }
.ql-picker.ql-font .ql-picker-label[data-value=verdana]::before,
.ql-picker.ql-font .ql-picker-item[data-value=verdana]::before { content: 'Verdana'; font-family: Verdana, sans-serif; }
.ql-picker.ql-font .ql-picker-label[data-value=tahoma]::before,
.ql-picker.ql-font .ql-picker-item[data-value=tahoma]::before  { content: 'Tahoma'; font-family: Tahoma, sans-serif; }
.ql-picker.ql-font .ql-picker-label[data-value=courier-new]::before,
.ql-picker.ql-font .ql-picker-item[data-value=courier-new]::before { content: 'Courier New'; font-family: 'Courier New', monospace; }
.ql-picker.ql-font .ql-picker-label[data-value=palatino]::before,
.ql-picker.ql-font .ql-picker-item[data-value=palatino]::before { content: 'Palatino'; font-family: Palatino, serif; }
.ql-picker.ql-font .ql-picker-label[data-value=garamond]::before,
.ql-picker.ql-font .ql-picker-item[data-value=garamond]::before { content: 'Garamond'; font-family: Garamond, serif; }
.ql-picker.ql-font .ql-picker-label[data-value=comic-sans]::before,
.ql-picker.ql-font .ql-picker-item[data-value=comic-sans]::before { content: 'Comic Sans'; font-family: 'Comic Sans MS', cursive; }

/* Quill pixel size picker labels */
.ql-picker.ql-size .ql-picker-label[data-value="10px"]::before,
.ql-picker.ql-size .ql-picker-item[data-value="10px"]::before { content: '10px'; }
.ql-picker.ql-size .ql-picker-label[data-value="12px"]::before,
.ql-picker.ql-size .ql-picker-item[data-value="12px"]::before { content: '12px'; }
.ql-picker.ql-size .ql-picker-label[data-value="14px"]::before,
.ql-picker.ql-size .ql-picker-item[data-value="14px"]::before { content: '14px'; }
.ql-picker.ql-size .ql-picker-label[data-value="18px"]::before,
.ql-picker.ql-size .ql-picker-item[data-value="18px"]::before { content: '18px'; }
.ql-picker.ql-size .ql-picker-label[data-value="24px"]::before,
.ql-picker.ql-size .ql-picker-item[data-value="24px"]::before { content: '24px'; }
.ql-picker.ql-size .ql-picker-label[data-value="32px"]::before,
.ql-picker.ql-size .ql-picker-item[data-value="32px"]::before { content: '32px'; }
.ql-picker.ql-size .ql-picker-label[data-value="48px"]::before,
.ql-picker.ql-size .ql-picker-item[data-value="48px"]::before { content: '48px'; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .stat-card { flex-direction: column; text-align: center; }
}

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.25s ease forwards; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { animation: spin 0.8s linear infinite; }

/* ── Empty states ── */
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state i { font-size: 3rem; margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: #64748b; margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; }

/* ── Sidebar toggle ── */
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #64748b; }
@media (max-width: 768px) { .sidebar-toggle { display: block; } }

/* ── WhatsApp button ── */
.whatsapp-btn { background: #25d366; color: white; }
.whatsapp-btn:hover { background: #128c7e; }

/* ── Content type icons ── */
.content-type-text { color: #3b82f6; }
.content-type-video { color: #ef4444; }
.content-type-pdf { color: #f59e0b; }
.content-type-image { color: #10b981; }
.content-type-embed { color: #8b5cf6; }

/* ── Rich content preview ── */
.video-wrapper { position: relative; padding-top: 56.25%; background: #000; border-radius: 8px; overflow: hidden; margin: 12px 0; }
.video-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* ── Block-based lesson editor ── */
.lesson-editor-canvas {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lesson-block-wrapper {
  position: relative;
}

.lesson-block-card {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.lesson-block-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 2px 12px rgba(37,99,235,0.08);
}

.lesson-block-card:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.lesson-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  gap: 8px;
}

.lesson-block-type-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lesson-block-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.block-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #64748b;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.12s;
  padding: 0;
}

.block-action-btn:hover { background: #f1f5f9; color: #1e293b; border-color: #cbd5e1; }
.block-action-btn.danger:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

.lesson-block-body {
  padding: 12px;
}

/* Text block: editor-area inherits existing .editor-area styles but scoped per block */
.block-text-editor {
  border-radius: 0 0 8px 8px;
  min-height: 140px;
}

/* URL / media blocks */
.block-url-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.block-media-preview {
  margin-top: 8px;
  border-radius: 8px;
  overflow: hidden;
}

.block-media-preview img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

.block-media-preview .video-wrapper {
  margin: 0;
}

/* Add-block bar */
.add-block-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 2px dashed #e2e8f0;
  border-radius: 10px;
  flex-wrap: wrap;
}

.add-block-bar span {
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.add-block-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  background: white;
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: all 0.12s;
}
.add-block-btn:hover { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }

/* Lesson viewer: multi-block rendering */
.lesson-blocks-viewer {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lesson-block-view {
  /* Individual block in viewer */
}

.lesson-block-view + .lesson-block-view {
  padding-top: 4px;
  border-top: 1px solid #f1f5f9;
}

/* Drag handle (future enhancement placeholder) */
.drag-handle {
  cursor: grab;
  color: #cbd5e1;
  padding: 0 4px;
  font-size: 0.9rem;
}
.drag-handle:active { cursor: grabbing; }

/* ── Video block: tab switcher ── */
.block-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 12px;
}

.block-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.15s;
}
.block-tab-btn:hover { color: #1e293b; background: #f8fafc; }
.block-tab-btn.active { color: #2563eb; border-bottom-color: #2563eb; }

/* ── Upload dropzone ── */
.block-upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 32px 20px;
  border: 2px dashed #bfdbfe;
  border-radius: 10px;
  background: #f0f7ff;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.block-upload-dropzone:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

/* ── Upload success banner ── */
.block-upload-success {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  border-radius: 8px;
  font-size: 0.85rem;
}

/* ── Upload progress bar lives inside .progress-bar/.progress-fill (reused) ── */
.upload-filename { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Video viewer (HTML5) in lesson page ── */
.lesson-video-player {
  width: 100%;
  border-radius: 8px;
  background: #000;
  display: block;
  max-height: 480px;
}

/* ── Drag-and-drop states ── */
.lesson-block-wrapper.dragging { opacity: 0.4; }
.lesson-block-wrapper.drag-over .lesson-block-card {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}
.lesson-sort-row.drag-over {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* ── Font selector in editor toolbar ── */
.editor-font-select {
  padding: 3px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: white;
  font-size: 0.78rem;
  color: #374151;
  cursor: pointer;
  height: 28px;
}
.editor-font-select:hover { border-color: #93c5fd; }

/* ── Lesson content lists (ensure bullets render) ── */
.lesson-content ul,
.lesson-block-view ul {
  list-style: disc;
  margin: 8px 0 8px 24px;
  padding: 0;
}
.lesson-content ol,
.lesson-block-view ol {
  list-style: decimal;
  margin: 8px 0 8px 24px;
  padding: 0;
}
.lesson-content li,
.lesson-block-view li {
  margin-bottom: 4px;
  line-height: 1.6;
}
/* Also fix lists inside the editor area */
.block-text-editor ul { list-style: disc; margin: 6px 0 6px 20px; }
.block-text-editor ol { list-style: decimal; margin: 6px 0 6px 20px; }
.block-text-editor li { margin-bottom: 2px; }

/* ── Multi-page lesson navigation ── */
.lesson-page-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}
.lesson-page-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 14px;
  border: 1.5px solid #e2e8f0;
  background: white;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.12s;
}
.lesson-page-dot:hover { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }
.lesson-page-dot.active {
  background: #2563eb;
  border-color: #2563eb;
  color: white;
}
.lesson-page-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

/* ── Page-break block in editor ── */
.lesson-page-break-card .lesson-block-header {
  background: transparent;
  border-bottom: none;
}

/* ── Badge system ── */
@keyframes badge-pop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.badge-earned-img {
  animation: badge-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ── Admin module grid ── */
.main-content { overflow-x: hidden; }

.admin-module-group {
  margin-bottom: 32px;
  width: 100%;
}

.admin-module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  min-width: 0;
}

.admin-module-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  user-select: none;
}

.admin-module-card.drag-over-card {
  outline: 2px dashed #2563eb;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}

@media (max-width: 1100px) {
  .admin-module-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .admin-module-grid { grid-template-columns: 1fr; }
}

/* ── Lesson editor page sections ── */
.editor-page-section {
  margin-bottom: 4px;
}

.editor-page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 6px;
}

.editor-page-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.editor-page-blocks {
  padding: 4px 0;
  min-height: 40px;
}

/* Page-break divider */
.page-break-wrapper {
  margin: 8px 0;
}

.editor-page-break-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}

.editor-page-break-line {
  flex: 1;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    #cbd5e1 0, #cbd5e1 8px,
    transparent 8px, transparent 16px
  );
  border-radius: 2px;
}

.editor-page-break-label {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 5px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.editor-page-break-remove {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  transition: background 0.1s;
}
.editor-page-break-remove:hover { background: #fee2e2; }

/* =====================================================
   Lesson text display view — Quill 2.x content rendering

   Quill 2.x saves lists as FLAT structure inside a single
   ul (bullets) or ol (ordered). Indented items use
   class="ql-indent-N" on the <li>, NOT nested lists.

   Bullet:  <ul><li data-list="bullet"><span class="ql-ui"></span>Text</li>
                 <li data-list="bullet" class="ql-indent-1"><span class="ql-ui"></span>Indented</li></ul>
   Ordered: <ol><li data-list="ordered"><span class="ql-ui"></span>Text</li></ol>

   The .ql-ui span::before renders the actual bullet/number character.
   Indentation is achieved purely via padding-left on each <li>.
   ===================================================== */

.lesson-text-content {
  line-height: 1.7;
  color: inherit;
  font-size: inherit;
  word-wrap: break-word;
}

/* Reset all native list styling — Quill renders markers via .ql-ui::before */
/* Quill 2.x saves ALL list types inside <ol> — both bullets and ordered */
.lesson-text-content ol,
.lesson-text-content ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Every li: suppress native marker, set up relative context for .ql-ui */
.lesson-text-content li {
  list-style: none;
  position: relative;
  padding-left: 1.5em; /* gutter for the .ql-ui marker */
}

/* .ql-ui is the marker span Quill injects; it sits in the left gutter */
.lesson-text-content li > .ql-ui {
  position: absolute;
  left: 0;
  width: 1.2em;
  display: inline-block;
  text-align: right;
  white-space: nowrap;
}

/* ── Bullet markers — data-list="bullet" inside <ol> ── */
.lesson-text-content li[data-list="bullet"]             > .ql-ui::before { content: '\2022'; } /* • */
.lesson-text-content li[data-list="bullet"].ql-indent-1 > .ql-ui::before { content: '\25E6'; } /* ◦ */
.lesson-text-content li[data-list="bullet"].ql-indent-2 > .ql-ui::before { content: '\25AA'; } /* ▪ */
.lesson-text-content li[data-list="bullet"].ql-indent-3 > .ql-ui::before { content: '\2022'; }
.lesson-text-content li[data-list="bullet"].ql-indent-4 > .ql-ui::before { content: '\25E6'; }

/* ── Ordered counters — data-list="ordered" inside <ol> ── */
/* Reset all counters when a non-list block appears */
.lesson-text-content p,
.lesson-text-content h1, .lesson-text-content h2, .lesson-text-content h3,
.lesson-text-content h4, .lesson-text-content h5, .lesson-text-content h6 {
  counter-reset: list-0 list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;
  margin: 0; padding: 0;
}
.lesson-text-content li[data-list="ordered"]             { counter-increment: list-0; counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9; }
.lesson-text-content li[data-list="ordered"].ql-indent-1 { counter-increment: list-1; counter-reset: list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9; }
.lesson-text-content li[data-list="ordered"].ql-indent-2 { counter-increment: list-2; counter-reset: list-3 list-4 list-5 list-6 list-7 list-8 list-9; }
.lesson-text-content li[data-list="ordered"].ql-indent-3 { counter-increment: list-3; counter-reset: list-4 list-5 list-6 list-7 list-8 list-9; }
.lesson-text-content li[data-list="ordered"].ql-indent-4 { counter-increment: list-4; counter-reset: list-5 list-6 list-7 list-8 list-9; }

.lesson-text-content li[data-list="ordered"]             > .ql-ui::before { content: counter(list-0, decimal)     '. '; }
.lesson-text-content li[data-list="ordered"].ql-indent-1 > .ql-ui::before { content: counter(list-1, lower-alpha) '. '; }
.lesson-text-content li[data-list="ordered"].ql-indent-2 > .ql-ui::before { content: counter(list-2, lower-roman) '. '; }
.lesson-text-content li[data-list="ordered"].ql-indent-3 > .ql-ui::before { content: counter(list-3, decimal)     '. '; }
.lesson-text-content li[data-list="ordered"].ql-indent-4 > .ql-ui::before { content: counter(list-4, lower-alpha) '. '; }

/* ── Indent levels — each adds 3em of left padding ── */
.lesson-text-content li.ql-indent-1 { padding-left: 4.5em;  }
.lesson-text-content li.ql-indent-2 { padding-left: 7.5em;  }
.lesson-text-content li.ql-indent-3 { padding-left: 10.5em; }
.lesson-text-content li.ql-indent-4 { padding-left: 13.5em; }
.lesson-text-content li.ql-indent-5 { padding-left: 16.5em; }

/* Headings */
.lesson-text-content h1 { font-size: 2em;    font-weight: bold; }
.lesson-text-content h2 { font-size: 1.5em;  font-weight: bold; }
.lesson-text-content h3 { font-size: 1.17em; font-weight: bold; }

/* Blockquote */
.lesson-text-content blockquote {
  border-left: 4px solid #ccc;
  margin: 5px 0;
  padding-left: 16px;
}

/* Font families */
.lesson-text-content .ql-font-arial           { font-family: Arial, sans-serif; }
.lesson-text-content .ql-font-georgia         { font-family: Georgia, serif; }
.lesson-text-content .ql-font-times-new-roman { font-family: 'Times New Roman', Times, serif; }
.lesson-text-content .ql-font-trebuchet       { font-family: 'Trebuchet MS', sans-serif; }
.lesson-text-content .ql-font-verdana         { font-family: Verdana, Geneva, sans-serif; }
.lesson-text-content .ql-font-tahoma          { font-family: Tahoma, Geneva, sans-serif; }
.lesson-text-content .ql-font-courier-new     { font-family: 'Courier New', Courier, monospace; }
.lesson-text-content .ql-font-palatino        { font-family: Palatino, 'Palatino Linotype', serif; }
.lesson-text-content .ql-font-garamond        { font-family: Garamond, 'EB Garamond', serif; }
.lesson-text-content .ql-font-comic-sans      { font-family: 'Comic Sans MS', cursive; }

/* ══════════════════════════════════════════════════════════════
   MODULE DETAIL — RESPONSIVE LAYOUT
   ══════════════════════════════════════════════════════════════ */

/* Desktop: two-column (lessons | quizzes+ask) */
.module-detail-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}
.module-detail-main    { min-width: 0; }
.module-detail-sidebar { min-width: 0; }

@media (max-width: 680px) {
  /* Single column — sidebar drops below lessons */
  .module-detail-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Hero banner: tighten padding, reduce font sizes */
  .module-hero {
    padding: 18px 16px !important;
    border-radius: 10px !important;
    margin-bottom: 16px !important;
  }
  .module-hero-title   { font-size: 1.15rem !important; }
  .module-hero-desc    { font-size: 0.82rem !important; }
  .module-hero-meta    { font-size: 0.75rem !important; gap: 10px !important; }
  .module-hero-pct     { font-size: 1.4rem  !important; }
}

/* ══════════════════════════════════════════════════════════════
   LESSON VIEW — RESPONSIVE LAYOUT
   ══════════════════════════════════════════════════════════════ */

/* Breadcrumb row */
.lesson-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.lesson-breadcrumb-module {
  color: #94a3b8;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.lesson-breadcrumb-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Desktop two-column grid */
.lesson-view-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 20px;
  align-items: start;
}
.lesson-view-main  { min-width: 0; }
.lesson-view-sidebar { min-width: 0; }
.lesson-sections-card { position: sticky; top: 80px; }

/* Prev / Next bar */
.lesson-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 8px;
  flex-wrap: wrap;
}
.lesson-nav-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lesson-nav-label   { display: inline; }

/* Mobile horizontal sections strip — hidden on desktop */
.lesson-mobile-nav {
  display: none;
}

/* ── Mobile breakpoint ── */
@media (max-width: 680px) {

  /* Breadcrumb: tighten up */
  .lesson-breadcrumb { margin-bottom: 12px; gap: 5px; }
  .lesson-breadcrumb-module { max-width: 100px; font-size: 0.72rem; }
  .lesson-breadcrumb-title  { max-width: 140px; font-size: 0.78rem; }

  /* Collapse to single column; sidebar moves below content */
  .lesson-view-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Hide the desktop sticky sidebar on mobile */
  .lesson-view-sidebar { display: none; }

  /* Show the horizontal scrollable sections strip */
  .lesson-mobile-nav {
    display: flex;
    align-items: stretch;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 0;
  }
  .lesson-mobile-nav::-webkit-scrollbar { display: none; }

  .lesson-mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    flex-shrink: 0;
    max-width: 110px;
    text-align: center;
    transition: background 0.15s;
  }
  .lesson-mobile-nav-item.active {
    border-bottom-color: #2563eb;
    background: #eff6ff;
  }
  .lesson-mobile-nav-item:not(.active):active { background: #f8fafc; }

  .lesson-mobile-nav-circle {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .lesson-mobile-nav-label {
    font-size: 0.68rem;
    color: #475569;
    line-height: 1.25;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .lesson-mobile-nav-item.active .lesson-mobile-nav-label {
    color: #1d4ed8;
    font-weight: 600;
  }

  /* Nav bar: stack vertically, full-width buttons */
  .lesson-nav-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .lesson-nav-bar > * { width: 100%; }
  .lesson-nav-actions { flex-direction: column; }
  .lesson-nav-actions .btn { width: 100%; justify-content: center; }
  .lesson-nav-prev,
  .lesson-nav-next { justify-content: center; }

  /* Truncate long lesson titles in nav buttons */
  .lesson-nav-label {
    display: inline-block;
    max-width: 180px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: middle;
  }

  /* Card padding tighter on small screens */
  .card-body { padding: 12px 14px; }
  .card-header { padding: 10px 14px; }
}
