/* =====================================================
   Sách Điện Tử — CSS v2
   ===================================================== */

/* ── Sidebar desktop default ─────────────────────── */
@media (min-width: 768px) {
  #sidebar {
    transform: translateX(0) !important;
  }
}

/* Sidebar scroll */
#sidebar, #t-sidebar {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #a5b4fc #e0e7ff;
}

/* ── Page content ─────────────────────────────────── */
#page-content img {
  max-width: 100%;
  border-radius: 0.75rem;
  margin: 0.75rem 0;
}

/* Prose styling */
.prose h2 { font-size: 1.25rem; font-weight: 700; margin: 1.25rem 0 0.5rem; color: #1e293b; }
.prose h3 { font-size: 1.05rem; font-weight: 700; margin: 1rem 0 0.4rem; color: #334155; }
.prose p  { margin-bottom: 0.75rem; }
.prose ul, .prose ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.prose li { margin-bottom: 0.3rem; }
.prose blockquote {
  border-left: 4px solid #818cf8;
  padding: 0.5rem 1rem;
  background: #eef2ff;
  border-radius: 0 0.5rem 0.5rem 0;
  color: #4338ca;
  font-style: italic;
  margin: 1rem 0;
}
.prose strong { color: #1e293b; }

/* ── YouTube / iframe embed ──────────────────────── */
.yt-embed {
  position: relative;
  padding-bottom: 62%;
  height: 0;
  overflow: hidden;
  min-height: 320px;
}
.yt-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* ── Quiz options ─────────────────────────────────── */
.quiz-option { transition: all 0.15s; cursor: pointer; }
.quiz-option:hover { transform: translateX(3px); }
.quiz-option.correct {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
  color: #065f46 !important;
}
.quiz-option.wrong {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
  color: #991b1b !important;
}
.quiz-option.disabled { pointer-events: none; }

/* ── Progress bar ─────────────────────────────────── */
.progress-fill {
  transition: width 0.6s ease;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

/* ── Sidebar nav item ─────────────────────────────── */
.page-nav-item { transition: all 0.12s; }
.page-nav-item.active {
  background: #e0e7ff !important;
  color: #4338ca !important;
  border-left: 3px solid #6366f1;
  padding-left: calc(0.75rem - 3px);
}
.page-nav-item.active i { color: #6366f1 !important; }

/* ── Fade in ──────────────────────────────────────── */
.fade-in { animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ── Toast ────────────────────────────────────────── */
#toast-msg { animation: slideUp 0.3s ease; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}

/* ── Mobile: bottom sheet modals ─────────────────── */
@media (max-width: 639px) {
  [id^="modal-"] > div:not([class*="inset"]) {
    border-radius: 1.25rem 1.25rem 0 0 !important;
    max-height: 92vh;
    overflow-y: auto;
  }
}

/* ── Table ────────────────────────────────────────── */
table { border-collapse: collapse; }

/* ── Chart canvas ─────────────────────────────────── */
canvas { max-width: 100%; }

/* ── Scrollbar (webkit) ───────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c7d2fe; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #a5b4fc; }

/* ── Fullscreen overlay ───────────────────────────── */
.fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #000;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease;
}

.fs-overlay iframe {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
}

#fs-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 100000;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}
#fs-close:hover { background: rgba(255,255,255,0.15); }

/* Embed wrapper fullscreen support */
.yt-embed-wrapper:-webkit-full-screen { width: 100%; height: 100%; background: #000; }
.yt-embed-wrapper:-webkit-full-screen .yt-embed { height: 100%; padding-bottom: 0; }
.yt-embed-wrapper:-webkit-full-screen iframe { position: relative; height: 100%; }
.yt-embed-wrapper:fullscreen { width: 100%; height: 100%; background: #000; }
.yt-embed-wrapper:fullscreen .yt-embed { height: 100%; padding-bottom: 0; }
.yt-embed-wrapper:fullscreen iframe { position: relative; height: 100%; }

/* ── Chapter accordion ────────────────────────────────────── */
.chapter-toggle { outline: none; }
.chapter-toggle:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}
.chapter-chevron {
  transition: transform 0.25s ease;
}
.chapter-pages {
  transition: max-height 0.3s ease, opacity 0.25s ease;
}


/* Chapter block separator */
.chapter-block + .chapter-block {
  border-top: 1px solid #f1f5f9;
  padding-top: 0.125rem;
  margin-top: 0.125rem;
}

/* ══════════════════════════════════════════════════════
   VIDEO QUIZ OVERLAY — Câu hỏi tương tác chèn vào video
   ══════════════════════════════════════════════════════ */

.vq-player-wrap { position: relative; }

.vq-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: vqFadeIn 0.3s ease;
  padding: 1rem;
}

@keyframes vqFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.vq-card {
  background: rgba(255,255,255,0.97);
  border-radius: 1.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
}

.vq-card-header {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.vq-badge {
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.vq-time-label {
  margin-left: auto;
  color: rgba(255,255,255,0.85);
  font-size: 0.75rem;
  font-weight: 600;
}

.vq-card-body { padding: 1.25rem; }

.vq-question {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.vq-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.vq-option-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.875rem;
  border: 2px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #fff;
  font-size: 0.875rem;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}
.vq-option-btn:hover:not(.vq-answered):not(.vq-correct):not(.vq-wrong) {
  border-color: #6366f1;
  background: #eef2ff;
  transform: translateX(3px);
}

.vq-option-label {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.vq-option-btn.vq-correct {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
  color: #065f46 !important;
  animation: vqBounce 0.4s ease;
}
.vq-option-btn.vq-correct .vq-option-label { background: #10b981; color: #fff; }

.vq-option-btn.vq-wrong {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
  color: #991b1b !important;
  animation: vqShake 0.35s ease;
}
.vq-option-btn.vq-wrong .vq-option-label { background: #ef4444; color: #fff; }

.vq-option-btn.vq-answered { pointer-events: none; opacity: 0.5; }

@keyframes vqBounce {
  0%,100% { transform: scale(1); }
  40%  { transform: scale(1.03); }
  70%  { transform: scale(0.98); }
}
@keyframes vqShake {
  0%,100% { transform: translateX(0); }
  20%  { transform: translateX(-5px); }
  40%  { transform: translateX(5px); }
  60%  { transform: translateX(-3px); }
  80%  { transform: translateX(3px); }
}

.vq-feedback {
  margin-top: 0.875rem;
  padding: 0.6rem 0.875rem;
  border-radius: 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  animation: vqFadeIn 0.2s ease;
}
.vq-feedback.vq-fb-correct { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.vq-feedback.vq-fb-wrong   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.vq-continue-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.875rem;
  padding: 0.7rem;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border-radius: 0.75rem;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
  animation: vqFadeIn 0.3s ease 0.15s both;
}
.vq-continue-btn:hover { opacity: 0.9; }

.vq-markers-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  background: #1e293b;
  border-radius: 0 0 0.875rem 0.875rem;
}
.vq-marker-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.07);
}
.vq-marker-chip.vq-chip-done {
  background: rgba(16,185,129,0.2);
  border-color: rgba(16,185,129,0.4);
  color: #6ee7b7;
}
.vq-marker-chip.vq-chip-pending {
  background: rgba(245,158,11,0.2);
  border-color: rgba(245,158,11,0.4);
  color: #fcd34d;
}
