/* ===================================================
   quiz.css — Component styles cho trang Bộ câu hỏi
   Tích hợp vào website chính (không override body/bg)
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@500;600;700;800&display=swap');

/* ── Variables ──────────────────────────────────────── */
:root {
  --qz-accent:   #2d7a4f;   /* màu chủ đạo — xanh y học */
  --qz-accent2:  #1e5c3a;
  --qz-teal:     #0d9488;
  --qz-ok:       #16a34a;
  --qz-no:       #dc2626;
  --qz-warn-bg:  #fef2f2;
  --qz-card-bg:  #ffffff;
  --qz-border:   #e5e7eb;
  --qz-text:     #111827;
  --qz-muted:    #6b7280;
  --radius:      14px;
  --radius-sm:   8px;
}

/* ── Card ────────────────────────────────────────────── */
.qz-card {
  background: var(--qz-card-bg);
  border: 1px solid var(--qz-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 2px 16px rgba(0,0,0,.07);
}
.qz-card-header {
  text-align: center;
  margin-bottom: 24px;
}
.qz-card-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--qz-text);
  margin-bottom: 8px;
}
.qz-card-header p { color: var(--qz-muted); margin: 0; }
.qz-icon { display: block; font-size: 48px; margin-bottom: 10px; }

/* ── Fields ─────────────────────────────────────────── */
.qz-field { margin-bottom: 16px; }
.qz-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--qz-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.qz-field .req { color: var(--qz-no); }

.qz-inp, .qz-sel {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--qz-text);
  background: #f9fafb;
  transition: border-color .18s, background .18s;
  outline: none;
  appearance: none;
}
.qz-inp:focus, .qz-sel:focus { border-color: var(--qz-accent); background: #fff; }
.qz-inp::placeholder { color: #9ca3af; }
.qz-sel {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232d7a4f' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 36px;
}

/* ── Error ───────────────────────────────────────────── */
.qz-error {
  background: var(--qz-warn-bg);
  border: 1px solid #fecaca;
  color: var(--qz-no);
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  margin-bottom: 16px;
  font-size: 14px;
}

/* ── Loading ─────────────────────────────────────────── */
.qz-spinner {
  width: 44px; height: 44px;
  margin: 0 auto;
  border: 4px solid #e5e7eb;
  border-top-color: var(--qz-accent);
  border-radius: 50%;
  animation: qzSpin .8s linear infinite;
}
@keyframes qzSpin { to { transform: rotate(360deg); } }

/* ── Meta row (số câu / điểm / timer) ───────────────── */
.qz-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.qz-pill {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: #f3f4f6;
  color: var(--qz-text);
  border: 1px solid var(--qz-border);
}
.qz-pill-green { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.qz-pill-orange { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.qz-pill-red    { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ── Progress Bar ────────────────────────────────────── */
.qz-bar {
  height: 6px;
  background: #f3f4f6;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 20px;
}
.qz-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--qz-accent), var(--qz-teal));
  border-radius: 99px;
  transition: width .4s ease;
}

/* ── Question Text ───────────────────────────────────── */
.qz-question {
  font-size: clamp(17px, 3vw, 21px);
  font-weight: 700;
  line-height: 1.5;
  color: var(--qz-text);
  margin-bottom: 20px;
}

/* ── Option Buttons ──────────────────────────────────── */
.qz-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  margin-bottom: 10px;
  border: 2px solid #e5e7eb;
  border-radius: var(--radius-sm);
  background: #f9fafb;
  color: var(--qz-text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: all .17s;
  line-height: 1.5;
}
.qz-opt:hover {
  border-color: var(--qz-accent);
  background: #f0fdf4;
  transform: translateX(3px);
}
.qz-opt .qz-letter {
  font-weight: 800;
  color: var(--qz-accent);
  margin-right: 8px;
}
.qz-opt.ok   { background: #dcfce7 !important; border-color: var(--qz-ok) !important; font-weight: 600; }
.qz-opt.no   { background: #fef2f2 !important; border-color: var(--qz-no) !important; }
.qz-opt.lock { pointer-events: none; }

/* ── Explanation Box ─────────────────────────────────── */
.qz-exp {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  color: #166534;
  font-size: 14px;
  line-height: 1.7;
  margin-top: 16px;
  animation: qzFade .3s ease;
}

/* ── Result Screen ───────────────────────────────────── */
.qz-student-name { font-weight: 700; color: var(--qz-accent); font-size: 15px; margin-bottom: 4px; }
.qz-big-score    { font-size: 56px; font-weight: 900; color: var(--qz-accent); line-height: 1; }
.qz-pct          { font-size: 22px; font-weight: 700; color: var(--qz-teal); margin-bottom: 8px; }
.qz-stat-box {
  padding: 16px 8px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid var(--qz-border);
}
.qz-stat-val { font-size: 28px; font-weight: 800; }
.qz-stat-lbl { font-size: 12px; color: var(--qz-muted); margin-top: 4px; }

/* ── Review ──────────────────────────────────────────── */
.qz-rv {
  background: #fff;
  border: 1px solid var(--qz-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.qz-rv-q   { font-weight: 700; margin-bottom: 8px; color: var(--qz-text); }
.qz-rv-opt { margin: 4px 0 0 12px; font-size: 14px; color: var(--qz-muted); }
.qz-rv-exp { color: #166534; margin-top: 10px; font-size: 13px; line-height: 1.6; background:#f0fdf4; padding:8px 10px; border-radius:6px; }

/* ── Note Box ────────────────────────────────────────── */
.qz-note-box {
  background: #f9fafb;
  border: 1px solid var(--qz-border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 14px;
  color: var(--qz-muted);
  line-height: 1.8;
}
.qz-note-box a { color: var(--qz-accent); }

/* ── Utility ─────────────────────────────────────────── */
.hide { display: none !important; }
@keyframes qzFade { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }

/* ── Back-to-list button fix ─────────────────────────────
   btn-main btn-line trong theme dùng màu transparent trên nền
   trắng → text bị ẩn. Override lại cho context quiz.          */
a.qz-btn-back,
button.qz-btn-back {
  display: block;
  width: 100%;
  text-align: center;
  padding: 11px 20px;
  border-radius: 6px;
  border: 2px solid var(--qz-accent);
  background: transparent;
  color: var(--qz-accent) !important;
  font-weight: 700;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, color .2s;
  text-decoration: none;
  line-height: 1.5;
}
a.qz-btn-back:hover,
button.qz-btn-back:hover {
  background: var(--qz-accent);
  color: #fff !important;
}

/* ── Responsive — Tablet (≤ 992px) ──────────────────────── */
@media (max-width: 992px) {
  /* Quiz list: sidebar goes on top, cards use 2 cols */
  #quizTopicFilter .cat-filter-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
  }
  #quizTopicFilter .cat-filter-title {
    width: 100%;
    margin-bottom: 6px;
  }
  #quizTopicFilter .cat-root-item {
    margin-bottom: 0;
  }
  #quizTopicFilter .cat-root-btn,
  #quizTopicFilter .cat-filter-all {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
  }
}

/* ── Responsive — Mobile (≤ 768px) ──────────────────────── */
@media (max-width: 768px) {
  /* Quiz single: shrink section padding */
  section[style*="padding: 40px"] { padding: 24px 0 40px !important; }

  /* Meta pills — wrap nicely */
  .qz-meta { gap: 6px; }
  .qz-pill { padding: 5px 10px; font-size: 12px; }

  /* Result screen */
  .qz-big-score { font-size: 40px; }
  .qz-pct       { font-size: 18px; }
  .qz-stat-val  { font-size: 22px; }
  .qz-stat-lbl  { font-size: 11px; }

  /* Action buttons stack vertically on mobile */
  .d-flex.gap-2 {
    flex-direction: column;
    gap: 10px !important;
  }
  .d-flex.gap-2 .btn-main {
    width: 100%;
    flex: none !important;
  }

  /* Quiz list: 1 card per row */
  #quiz-list-container .col-sm-6.col-lg-4 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
  }

  /* Card header smaller */
  .qzl-card-header { padding: 20px 16px 18px; }
  .qzl-icon { font-size: 38px; }
}

/* ── Responsive — Small Mobile (≤ 576px) ────────────────── */
@media (max-width: 576px) {
  .qz-card { padding: 18px 14px; }
  .qz-question { font-size: 16px; }
  .qz-opt { padding: 11px 13px; font-size: 14px; }

  /* Start screen selects: stack */
  #screen-start .col-6 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
  }

  /* Subheader topic title too large on mobile */
  #subheader-title { font-size: 1.6rem !important; }

  .qzl-title { font-size: .95rem; }
}

/* ════════════════════════════════════════════════════════
   TOPIC FILTER SIDEBAR — Giống CategoryFilter của blog/page
   (dùng cùng class names để đồng nhất giao diện)
   ════════════════════════════════════════════════════════ */
.cat-filter-wrap {
  font-family: inherit;
  position: sticky;
  top: 90px;               /* dính dưới navbar khi scroll trang */
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #c3d9c7 transparent;
  padding-right: 4px;      /* chỗ cho thanh scroll */
}
.cat-filter-wrap::-webkit-scrollbar { width: 4px; }
.cat-filter-wrap::-webkit-scrollbar-thumb { background: #c3d9c7; border-radius: 99px; }
.cat-filter-title {
  font-size: 14px; font-weight: 700; color: #354e33;
  text-transform: uppercase; letter-spacing: 0.8px;
  border-bottom: 2px solid #354e33; padding-bottom: 8px;
  margin-bottom: 12px;
}
.cat-filter-all {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 6px; cursor: pointer;
  font-weight: 600; font-size: 14px; margin-bottom: 6px;
  transition: background 0.2s; color: #354e33;
  border: 1px solid transparent;
}
.cat-filter-all:hover { background: #e8f5e9; }
.cat-filter-all.active { background: #354e33; color: white; border-color: #354e33; }
.cat-root-item { margin-bottom: 4px; }
.cat-root-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 9px 12px; border-radius: 6px;
  border: 1px solid transparent; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: #333;
  transition: background 0.2s; text-align: left;
}
.cat-root-btn:hover { background: #e8f5e9; }
.cat-root-btn.active { background: #354e33; color: white; border-color: #354e33; }
.cat-root-btn .cat-label { display: flex; align-items: center; gap: 8px; }
.cat-count {
  margin-left: auto; font-size: 11px; opacity: 0.7;
  background: rgba(0,0,0,0.08); border-radius: 10px;
  padding: 1px 6px; flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════
   QUIZ LIST PAGE — Cards dành cho trang danh sách bộ câu hỏi
   ════════════════════════════════════════════════════════ */

/* ── List card container ─────────────────────────────── */
.qzl-card-wrap {
  animation: qzFade .4s ease both;
}
.qzl-card-wrap:nth-child(1) { animation-delay: .05s; }
.qzl-card-wrap:nth-child(2) { animation-delay: .10s; }
.qzl-card-wrap:nth-child(3) { animation-delay: .15s; }
.qzl-card-wrap:nth-child(4) { animation-delay: .20s; }
.qzl-card-wrap:nth-child(5) { animation-delay: .25s; }
.qzl-card-wrap:nth-child(6) { animation-delay: .30s; }

/* ── List card ───────────────────────────────────────── */
.qzl-card {
  background: var(--qz-card-bg);
  border: 1px solid var(--qz-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0,0,0,.07);
  transition: transform .22s ease, box-shadow .22s ease;
  color: var(--qz-text);
  height: 100%;
  display: flex;
  flex-direction: column;
}
.qzl-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 36px rgba(0,0,0,.14);
  color: var(--qz-text);
}

/* ── Card header (gradient area) ────────────────────── */
.qzl-card-header {
  padding: 32px 20px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.qzl-card-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.08);
  pointer-events: none;
}
.qzl-icon {
  font-size: 52px;
  display: block;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.3));
  transition: transform .3s ease;
}
.qzl-card:hover .qzl-icon {
  transform: scale(1.12) rotate(-3deg);
}

/* ── Card body ───────────────────────────────────────── */
.qzl-card-body {
  padding: 20px 20px 22px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.qzl-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--qz-text);
  margin: 0;
  line-height: 1.4;
}

/* ── Meta / badges ───────────────────────────────────── */
.qzl-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}
.qzl-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f3f4f6;
  color: var(--qz-muted);
  border: 1px solid var(--qz-border);
  transition: background .18s;
}
.qzl-badge-green {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}
.qzl-card:hover .qzl-badge-green {
  background: var(--qz-ok);
  color: #fff;
  border-color: var(--qz-ok);
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 576px) {
  .qzl-card-header { padding: 24px 16px 20px; }
  .qzl-icon { font-size: 40px; }
  .qzl-title { font-size: .95rem; }
}

/* ── Card phẳng: chỉ thanh màu gradient bên trái ────── */
.qzl-card-flat {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}
.qzl-card-accent {
  width: 6px;
  flex-shrink: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  transition: width .22s ease;
}
.qzl-card-flat:hover .qzl-card-accent {
  width: 9px;
}
.qzl-card-flat .qzl-card-body {
  padding: 20px 20px 18px;
  flex: 1;
  gap: 12px;
}
.qzl-card-flat .qzl-title {
  font-size: 1rem;
  margin: 0 0 2px;
  line-height: 1.45;
}
@media (max-width: 576px) {
  .qzl-card-flat .qzl-card-body { padding: 16px 16px 14px; }
}

/* ════════════════════════════════════════════════════════
   PAGINATION — Phân trang danh sách bộ câu hỏi
   ════════════════════════════════════════════════════════ */
#qz-pagination {
  flex-wrap: wrap;
  gap: 6px;
}
.qz-page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1.5px solid var(--qz-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--qz-text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .18s, border-color .18s, color .18s, transform .12s;
}
.qz-page-btn:hover:not(:disabled) {
  border-color: var(--qz-accent);
  background: #f0fdf4;
  color: var(--qz-accent);
  transform: translateY(-1px);
}
.qz-page-btn.active {
  background: var(--qz-accent);
  border-color: var(--qz-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(45,122,79,.35);
}
.qz-page-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.qz-page-ellipsis {
  min-width: 32px;
  text-align: center;
  font-size: 16px;
  color: var(--qz-muted);
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 576px) {
  .qz-page-btn { min-width: 34px; height: 34px; font-size: 13px; }
}

/* ── Nộp bài sớm button ──────────────────────────────── */
.btn-submit-early {
  display: block;
  width: 100%;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 2px solid #f59e0b;
  background: transparent;
  color: #b45309;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
  text-align: center;
  letter-spacing: .01em;
}
.btn-submit-early:hover {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-color: transparent;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(239,68,68,.25);
}
.btn-submit-early:active {
  transform: translateY(0);
}
