/* ============================================================
   exam.css — Exam Page Styles
   comtobooks.com
   วาง: /assets/css/exam.css
   ใช้กับ: pages/exam.php (ทุก mode)
   ============================================================ */

/* ── Mode 1 & 2: เลือกวิชา / เลือกชุด ── */

/* Subject card (mode 1) */
.subject-card-link {
  text-decoration: none;
  display: block;
  transition: transform var(--duration-md) var(--ease), box-shadow var(--duration-md) var(--ease);
}
.subject-card-link:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.subject-card-disabled {
  opacity: .42;
  cursor: not-allowed;
  pointer-events: none;
}
.subject-card-disabled .subject-icon {
  filter: grayscale(1);
}

/* Set card (mode 2) */
.set-card {
  transition: transform var(--duration-md) var(--ease), box-shadow var(--duration-md) var(--ease);
}
.set-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* ── Mode 3: ทำข้อสอบ ── */

/* ซ่อน sidebar ในหน้าสอบ */
.exam-full-page .layout-main    { display: block; }
.exam-full-page .sidebar        { display: none !important; }
.exam-full-page .layout-content { padding: 0; }
.exam-full-page .bottom-nav     { display: none !important; }

/* Sticky exam topbar */
.exam-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy-800);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-md);
}
.exam-topbar-title { font-size: 14px; font-weight: 700; color: white; }
.exam-topbar-sub   { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 1px; }

.exam-progress-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.1);
  border-radius: var(--r-full);
  padding: 6px 14px;
  flex-shrink: 0;
}
.exam-progress-txt {
  font-size: 13px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.exam-pill-divider {
  width: 1px; height: 14px;
  background: rgba(255,255,255,.2);
  margin: 0 4px;
}

/* Thin progress bar under topbar */
.exam-prog-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,.12);
  background: var(--navy-700);
}
.exam-prog-bar-fill {
  height: 100%;
  background: var(--blue-400);
  transition: width .4s var(--ease-out);
}

/* Exam content area */
.exam-content {
  max-width: 80%;
  margin: 0 auto;
  padding: 20px 24px 140px;
}

/* Q-nav dot strip */
.q-nav-strip {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.q-nav-strip-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
}
.q-dot {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  background: white;
  transition: all var(--duration) var(--ease);
  flex-shrink: 0;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.q-dot:hover           { border-color: var(--blue-400); color: var(--blue-600); }
.q-dot.answered        { background: var(--success); color: white; border-color: var(--success); }

/* Question block */
.q-block {
  width: 80%; /* เพิ่มบรรทัดนี้: กำหนดความกว้าง 80% */
  margin: 0 auto 16px auto; /* แก้ไขบรรทัดนี้: จัดกึ่งกลางซ้าย-ขวา และเว้นล่าง 16px */
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  scroll-margin-top: calc(var(--navbar-h) + 64px);
  transition: border-color var(--duration) var(--ease);
}
.q-block.answered {
  border-color: rgba(16,185,129,.3);
}

.q-block-head {
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(90deg, var(--navy-800), var(--navy-700));
}
.q-block.answered .q-block-head {
  background: linear-gradient(90deg, #064e3b, #047857);
}
.q-block-num {
  background: rgba(255,255,255,.15);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--r-full);
}
.q-block-tag  { font-size: 11px; color: rgba(255,255,255,.5); margin-left: auto; }
.q-block-check{ font-size: 14px; }

.q-block-body { padding: 20px 18px; }
.q-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: 16px;
}
.q-img {
  max-width: 100%;
  border-radius: var(--r-md);
  margin-bottom: 14px;
}

/* Choice items */
.choices { display: flex; flex-direction: column; gap: 9px; }

.choice-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 15px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  background: white;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.choice-item:hover:not(.correct):not(.wrong):not(.skip-dim) {
  border-color: var(--blue-400);
  background: var(--blue-50);
}
.choice-item.selected  { border-color: var(--blue-600); background: var(--blue-50); }
.choice-item.correct   { border-color: var(--success);  background: var(--success-bg); pointer-events: none; }
.choice-item.wrong     { border-color: var(--danger);   background: var(--danger-bg);  pointer-events: none; }
.choice-item.skip-dim  { opacity: .5; pointer-events: none; }

.choice-letter {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  background: var(--gray-50);
  color: var(--text-secondary);
  border: 1.5px solid var(--gray-100);
  flex-shrink: 0;
  margin-top: 1px;
  transition: all var(--duration) var(--ease);
}
.choice-item.selected .choice-letter { background: var(--blue-600); color: white; border-color: var(--blue-600); }
.choice-item.correct  .choice-letter { background: var(--success);  color: white; border-color: var(--success); }
.choice-item.wrong    .choice-letter { background: var(--danger);   color: white; border-color: var(--danger); }

.choice-text  { font-size: 14px; color: var(--text-primary); line-height: 1.6; padding-top: 4px; flex: 1; }
.choice-img   { max-height: 140px; margin-top: 8px; border-radius: 6px; }
.choice-icon  { font-size: 18px; flex-shrink: 0; }

/* Explanation box */
.explanation {
  background: var(--blue-50);
  border-left: 3px solid var(--blue-600);
  padding: 10px 13px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 12px;
  line-height: 1.6;
  display: none;
}
.explanation.show { display: block; }

/* Fixed submit bar */
.exam-submit-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: white;
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -4px 16px rgba(15,27,53,.08);
}
.submit-stat {
  font-size: 13px;
  color: var(--text-secondary);
}
.submit-stat strong { color: var(--navy-800); font-weight: 700; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .exam-topbar    { padding: 10px 14px; }
  .exam-content   { padding: 12px 10px 110px; }
  .q-block-body   { padding: 14px 13px; }
  .q-text         { font-size: 14px; }
  .choice-item    { padding: 10px 12px; gap: 9px; }
  .choice-text    { font-size: 13px; }
  .exam-submit-bar{ padding: 10px 14px; }
  .q-nav-strip    { padding: 10px 12px; gap: 3px; }
  .q-dot          { width: 26px; height: 26px; font-size: 10px; }
}

@media (max-width: 480px) {
  .exam-topbar-title { font-size: 13px; }
  .exam-progress-pill{ padding: 5px 10px; }
  .exam-progress-txt { font-size: 12px; }
  .q-block-body   { padding: 12px 12px; }
  .choice-letter  { width: 28px; height: 28px; min-width: 28px; font-size: 12px; }
}

/* ══ Floating Progress Widget (มุมขวาล่าง) ══ */
.exam-float-progress {
  position: fixed;
  bottom: 72px;
  right: 20px;
  z-index: 60;
  background: var(--success, #059669); /* 👈 เปลี่ยนพื้นเป็นสีเขียว */
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 4px 20px rgba(5, 150, 105, 0.4); /* 👈 ปรับเงาให้เป็นโทนเขียว */
  min-width: 140px;
  transition: transform .2s var(--ease), opacity .2s var(--ease);
}
.exam-float-progress:hover { transform: translateY(-2px); }


.efp-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: rgba(255,255,255,.45); margin-bottom: 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.efp-count {
  font-size: 14px; font-weight: 800; color: white;
}
.efp-bar-wrap {
  width: 100%; height: 6px;
  background: rgba(255,255,255,.12);
  border-radius: 3px; overflow: hidden;
  margin-bottom: 5px;
}
.efp-bar-fill {
  height: 100%; border-radius: 3px;
  background: var(--sky-400, #38bdf8);
  transition: width .4s cubic-bezier(.34,1.2,.64,1);
}
.efp-bar-fill.full { background: var(--success, #059669); }
.efp-pct {
  font-size: 11px; color: rgba(255,255,255,.5);
  text-align: right;
}
.efp-done-badge {
  display: none;
  font-size: 11px; font-weight: 700;
  color: var(--success, #059669);
  text-align: center; margin-top: 4px;
}
.efp-done-badge.show { display: block; }

@media (max-width: 575px) {
  .exam-float-progress {
    bottom: 68px;
    right: 12px;
    min-width: 120px;
    padding: 8px 11px;
  }
}

