/* =========================
   QUIZ LAYOUT (GLOBAL SAFE)
   ========================= */

.quiz-layout {
  display: grid;
  grid-template-columns: 3fr 1.2fr;
  gap: 24px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* LEFT */
.quiz-main {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
}

/* RIGHT */
.quiz-sidebar {
  background: #fff;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #eee;
}

/* =========================
   QUESTION
   ========================= */

.quiz-question {
  display: none;
}

.quiz-question.active {
  display: block;
}

.quiz-question-title {
  font-size: 18px;
  margin-bottom: 12px;
}

/* =========================
   QUESTION CONTENT
   ========================= */

.question-text {
  font-size: 16px;
  margin-bottom: 16px;
}

.question-image img {
  max-width: 100%;
  height: auto;
  display: block;
  margin-bottom: 16px;
}

/* =========================
   ANSWERS
   ========================= */

.question-answers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.answer {
  border: 2px solid #e5e5e5;
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.answer:hover {
  border-color: #ff7a18;
}

.answer.selected {
  border-color: #ff7a18;
  background: #fff5ee;
}

.answer img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* =========================
   SIDEBAR
   ========================= */

.quiz-sidebar-title {
  font-size: 16px;
  margin-bottom: 12px;
}

.question-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.nav-item {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-weight: 600;

  /* CENTER TEXT */
  display: flex;
  align-items: center;
  justify-content: center;

  /* chống theme override */
  padding: 0;
  line-height: 1;
  margin-right: 5px;
}

.nav-item:hover {
  border-color: #ff7a18;
}

.nav-item.active {
  border-color: #ff7a18;
  color: #ff7a18;
}


.nav-item.done {
  background: #eafaf3;
  border-color: #3bb77e;
  color: #2e7d5b;
}


/* lát xem lại */
.nav-item.review {
  background: #a8277b;
  border-color: #951141;
  color: #ffffff;
}

/* vừa trả lời + review (ưu tiên review) */
.nav-item.done.review {
   background: #a8277b;
  border-color: #951141;
  color: #ffffff;
}
/* =========================
   SUBMIT
   ========================= */

.quiz-actions #btn-submit-quiz {
  width: 100%;
  padding: 5px;
  background: #ff7a18;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.quiz-actions #btn-submit-quiz:hover {
  opacity: 0.9;
}

.quiz-actions #btn-review-jump {
  width: 100%;
  padding: 5px;
  background: #a8277b;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.quiz-actions #btn-review-jump:hover {
  opacity: 0.9;
}

/* =========================
   LEGEND
   ========================= */

.quiz-legend {
  margin-top: 16px;
  font-size: 14px;
}

.quiz-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  
}
.quiz-legend p {
margin-bottom: 5px;
}
.quiz-legend .todo {
  background: #ccc;
}

.quiz-legend .done {
  background: #3bb77e;
}
.quiz-legend .review {
  background: #a8277b;
}
.answer {
  position: relative;
  border: 2px solid #e5e5e5;
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
}

.answer-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ff7a18;
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.answer-content img {
  max-width: 100%;
  display: block;
  margin-bottom: 6px;
}

.answer-text {
  font-size: 15px;
}


/* =========================
   QUIZ TIMER
   ========================= */

.quiz-timer {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: 10px;

  padding: 14px 18px;
  margin-bottom: 18px;

  font-size: 18px;
  font-weight: 600;

  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 2px solid #fb923c;
  border-radius: 10px;

  color: #9a3412;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

/* icon + text */
.quiz-timer::before {
  content: "⏱";
  font-size: 22px;
}

/* số thời gian */
#quiz-timer-text {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ea580c;
  min-width: 80px;
  text-align: center;
}

/* =========================
   SẮP HẾT GIỜ
   ========================= */
.quiz-timer.warning {
  background: linear-gradient(135deg, #fff1f2, #ffe4e6);
  border-color: #f43f5e;
  color: #be123c;
}

.quiz-timer.warning #quiz-timer-text {
  color: #e11d48;
  animation: pulse 1s infinite;
}

/* =========================
   HẾT GIỜ
   ========================= */
.quiz-timer.time-up {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border-color: #dc2626;
  color: #7f1d1d;
}

.quiz-timer.time-up #quiz-timer-text {
  color: #dc2626;
  animation: none;
}

.quiz-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 12px;
}
.quiz-controls button {
    padding: 5px 20px;
    border: 1px solid #d1d5db;
    background-color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.2s;
    color: #374151;
    text-transform: math-auto;
    line-height: 16px;
}
/* bên trái */
.quiz-controls .btn-review {
 
}

/* bên phải */
.quiz-controls-right {
  display: flex;
  gap: 10px;
}

.quiz-controls-right button {
    padding: 5px 20px;
    border: 1px solid #d1d5db;
    background-color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.2s;
    color: #374151;
    text-transform: math-auto;
    line-height: 16px;
}

/* prev */
.quiz-controls-right .btn-prev {
 background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}

/* next */
.quiz-controls-right .btn-next {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.quiz-controls button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.quiz-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}



.mark-review-waper{
    margin-top: 20px;
}
.mark-review-waper button {
    padding: 5px 20px;
    border: 1px solid #d1d5db;
    background-color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    color: #374151;
    text-transform: math-auto;
}

/* =========================
   ANIMATION
   ========================= */
@keyframes pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/*-----POPUP ------ */
.quiz-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.quiz-popup.show {
  display: flex;
}

.quiz-popup-inner {
  background: #fff;
  width: 100%;
  max-width: 800px;
  padding: 24px;
  border-radius: 12px;
  position: relative;
}

.quiz-popup-close {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 22px;
  cursor: pointer;
}



/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 768px) {

  .quiz-layout {
    grid-template-columns: 1fr;
  }

  .quiz-sidebar {
    order: -1; /* sidebar lên trên mobile */
  }

  .question-answers {
    grid-template-columns: 1fr;
  }

  .question-nav {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* =========================
   QUIZ RESULT POPUP
   ========================= */

.qr-wrap {
  text-align: center;
  padding: 10px 0;
}

.qr-icon {
  font-size: 4rem;
  margin-bottom: 10px;
  display: block;
}

.qr-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 20px;
}

.qr-score-big {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}

.qr-score-num {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
  color: #1e293b;
}

.qr-score-sep {
  font-size: 2rem;
  color: #94a3b8;
}

.qr-score-total {
  font-size: 2rem;
  color: #64748b;
  font-weight: 700;
}

.qr-score-label {
  font-size: .9rem;
  color: #64748b;
  margin: 0 0 16px;
}

.qr-percent-bar {
  width: 100%;
  max-width: 400px;
  height: 10px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  margin: 0 auto 8px;
}

.qr-percent-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 1s ease;
}

.qr-percent-text {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0 0 20px;
}

.qr-desc {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 20px;
  text-align: left;
  max-width: 500px;
  margin: 0 auto 20px;
}

.qr-desc h3 {
  font-size: .9rem;
  font-weight: 700;
  color: #475569;
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.qr-desc p {
  font-size: .95rem;
  color: #334155;
  line-height: 1.7;
  margin: 0;
}

.qr-close-btn {
  background: #1e293b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 32px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s;
}

.qr-close-btn:hover { opacity: .85; }
