/* ==========================================================================
   FE EXAM MODULE STYLES - JPD123 EDTECH UI/UX
   ========================================================================== */

.fe-exam-wrapper {
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 4px 40px;
}

/* HEADER CARD */
.fe-header-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #f8fafc;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.fe-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.fe-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.fe-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fe-badge {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.fe-badge-official {
  background: #10b981;
  color: #fff;
}

.fe-badge-retake {
  background: #f59e0b;
  color: #fff;
}

.fe-badge-code {
  background: #6366f1;
  color: #fff;
  letter-spacing: 0.5px;
}

.fe-header-desc {
  font-size: 0.92rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* CONTROLS TOOLBAR */
.fe-controls-toolbar {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.fe-selector-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fe-select-exam {
  background: #334155;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
  min-width: 220px;
  max-width: 100%;
}

@media (max-width: 640px) {
  .fe-controls-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .fe-selector-group {
    flex-direction: column;
    align-items: stretch;
  }
  .fe-select-exam {
    width: 100%;
    min-width: 0;
  }
  .btn-fe-shuffle {
    width: 100%;
    justify-content: center;
  }
  .fe-timer-box {
    justify-content: center;
    width: 100%;
  }
  .btn-fe-submit {
    width: 100%;
    text-align: center;
  }
}

.fe-select-exam:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.3);
}

.btn-fe-shuffle {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-fe-shuffle:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}

.fe-timer-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  font-weight: 700;
  color: #38bdf8;
  cursor: pointer;
  transition: all 0.2s;
}

.fe-timer-box:hover {
  border-color: #64748b;
  background: #1e293b;
}

.fe-timer-box.fe-timer-idle {
  color: #cbd5e1;
  border-color: #475569;
}

.fe-timer-warning {
  color: #fbbf24 !important;
  border-color: #f59e0b !important;
}

.fe-timer-danger {
  color: #ef4444 !important;
  border-color: #ef4444 !important;
  animation: pulseTimer 1s infinite;
}

@keyframes pulseTimer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.btn-fe-submit {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.3);
  transition: all 0.2s;
}

.btn-fe-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(16, 185, 129, 0.4);
}

/* PROGRESS BAR */
.fe-progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: #334155;
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 10px;
}

.fe-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  width: 0%;
  transition: width 0.3s ease;
}

/* MAIN EXAM ARENA LAYOUT */
.fe-arena-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 960px) {
  .fe-arena-grid {
    grid-template-columns: 1fr;
  }
}

/* QUESTION CARD */
.fe-question-panel {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.fe-question-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #f8fafc;
}

.fe-q-meta-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fe-q-num-badge {
  background: #6366f1;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 8px;
}

.fe-q-type-badge {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 600;
}

.btn-fe-flag {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #64748b;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-fe-flag.flagged {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #d97706;
}

/* QUESTION BODY & IMAGE */
.fe-question-body {
  padding: 20px;
}

.fe-img-container {
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  padding: 10px;
  overflow: hidden;
  margin-bottom: 20px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.fe-exam-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 6px;
}

.btn-fe-zoom {
  background: #0f172a;
  color: #fff;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-fe-zoom:hover {
  background: #1e293b;
  transform: translateY(-1px);
}

/* OPTIONS LIST */
.fe-options-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 12px;
}

.fe-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .fe-options-grid {
    grid-template-columns: 1fr;
  }
}

.fe-option-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.fe-option-card:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.fe-option-card.selected {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.fe-opt-letter {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #e2e8f0;
  color: #475569;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.fe-option-card.selected .fe-opt-letter {
  background: #3b82f6;
  color: #ffffff;
}

.fe-opt-label {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

/* NAVIGATION FOOTER */
.fe-question-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
}

.btn-fe-nav {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-fe-nav:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-fe-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* PALETTE CARD (RIGHT COLUMN) */
.fe-palette-panel {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  padding: 18px;
  box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 80px;
}

.fe-palette-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fe-palette-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.76rem;
  color: #64748b;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.fe-leg-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.fe-leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.fe-palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.fe-pal-btn {
  height: 38px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  color: #334155;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fe-pal-btn:hover {
  border-color: #6366f1;
  background: #eef2ff;
}

.fe-pal-btn.answered {
  background: #3b82f6;
  border-color: #2563eb;
  color: #ffffff;
}

.fe-pal-btn.current {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px #c7d2fe;
  font-weight: 900;
}

.fe-pal-btn.flagged::after {
  content: '🚩';
  position: absolute;
  top: -4px;
  right: -3px;
  font-size: 0.65rem;
}

/* POST EXAM GRADING & REVIEW STYLES */
.fe-result-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  color: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.fe-score-circle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 6px solid #10b981;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.1);
}

.fe-score-num {
  font-size: 2rem;
  font-weight: 900;
  color: #34d399;
  line-height: 1;
}

.fe-score-max {
  font-size: 0.8rem;
  color: #94a3b8;
}

.fe-result-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.fe-stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fe-stat-val {
  font-size: 1.4rem;
  font-weight: 800;
}

.fe-stat-label {
  font-size: 0.82rem;
  color: #cbd5e1;
}

/* EXPLANATION BOX */
.fe-explanation-box {
  background: #f8fafc;
  border-left: 4px solid #6366f1;
  border-radius: 0 12px 12px 0;
  padding: 16px;
  margin-top: 16px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #1e293b;
}

.fe-exp-header {
  font-weight: 800;
  color: #4338ca;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* MODAL CONFIRMATION & LIGHTBOX */
.fe-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(5px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.fe-modal-backdrop.open {
  display: flex !important;
}

#fe-lightbox-img {
  width: min(94vw, 1280px);
  max-width: 94vw !important;
  max-height: 86vh !important;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  object-fit: contain;
  background: #ffffff;
  cursor: zoom-in;
  transition: transform 0.2s ease;
}

#fe-lightbox-img.super-zoom {
  width: auto !important;
  max-width: none !important;
  max-height: none !important;
  transform: scale(1.65);
  transform-origin: top left;
  cursor: zoom-out;
}

.fe-modal-card {
  background: #ffffff;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
  animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Filter buttons in Review Mode */
.btn-fe-filter {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-fe-filter:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-fe-filter.active {
  background: #3b82f6 !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.btn-fe-filter[data-filter="wrong"].active {
  background: #ef4444 !important;
  border-color: #dc2626 !important;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-fe-filter[data-filter="correct"].active {
  background: #10b981 !important;
  border-color: #059669 !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-fe-filter[data-filter="skipped"].active {
  background: #64748b !important;
  border-color: #475569 !important;
  box-shadow: 0 2px 8px rgba(100, 116, 139, 0.25);
}

/* Reading Passage Text & Subquestions */
.fe-reading-passage-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #4f46e5;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.fe-passage-title {
  font-weight: 800;
  color: #1e293b;
  font-size: 0.95rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fe-passage-body {
  font-family: 'M PLUS Rounded 1c', 'HGSeikaishotaiPRO', 'Yu Gothic', 'Meiryo', sans-serif;
  font-size: 1.05rem;
  line-height: 1.85;
  color: #0f172a;
  background: #ffffff;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.fe-subq-block {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.fe-subq-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.98rem;
}

.fe-subq-num {
  background: #6366f1;
  color: #ffffff;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 6px;
}

/* ================================================================
   INSTANT CHECK MODE TOGGLE ("⚡ Xem Đáp Án Ngay")
   ================================================================ */
.fe-instant-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
  border: 1.5px solid #475569;
  border-radius: 999px;
  padding: 6px 13px 6px 11px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.fe-instant-toggle:hover {
  border-color: #94a3b8;
  color: #ffffff;
}

.fe-instant-toggle .fe-switch-track {
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: #475569;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.fe-instant-toggle .fe-switch-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.fe-instant-toggle.active {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-color: #fbbf24;
  color: #ffffff;
  box-shadow: 0 3px 12px rgba(245, 158, 11, 0.38);
}

.fe-instant-toggle.active .fe-switch-track {
  background: rgba(255, 255, 255, 0.35);
}

.fe-instant-toggle.active .fe-switch-thumb {
  transform: translateX(14px);
}

.fe-instant-toggle.autonext-toggle.active {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  border-color: #38bdf8;
  box-shadow: 0 3px 12px rgba(14, 165, 233, 0.38);
}

/* OPTION INSTANT FEEDBACK HIGHLIGHTS */
.fe-option-card.instant-correct {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16) !important;
}

.fe-option-card.instant-correct .fe-opt-letter {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
}

.fe-option-card.instant-correct::after {
  content: '✅';
  margin-left: auto;
  font-size: 1rem;
}

.fe-option-card.instant-wrong {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.fe-option-card.instant-wrong .fe-opt-letter {
  background: #ef4444 !important;
  color: #ffffff !important;
  border-color: #dc2626 !important;
}

.fe-option-card.instant-wrong::after {
  content: '❌';
  margin-left: auto;
  font-size: 1rem;
}

/* INLINE INSTANT EXPLANATION CARD */
.fe-instant-feedback {
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1.5px solid #cbd5e1;
  font-size: 0.9rem;
  line-height: 1.62;
  animation: feInstantPop 0.2s ease-out;
}

@keyframes feInstantPop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.fe-instant-feedback.is-correct {
  background: #ecfdf5;
  border-color: #6ee7b7;
  border-left: 5px solid #10b981;
  color: #064e3b;
}

.fe-instant-feedback.is-wrong {
  background: #fef2f2;
  border-color: #fca5a5;
  border-left: 5px solid #ef4444;
  color: #7f1d1d;
}

.fe-instant-feedback.is-pending {
  background: #f0f9ff;
  border-color: #bae6fd;
  border-left: 5px solid #0284c7;
  color: #0c4a6e;
}

.fe-instant-verdict {
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fe-instant-exp {
  color: #1e293b;
  font-size: 0.88rem;
}

/* PALETTE LIVE GREEN/RED IN INSTANT MODE */
.fe-pal-btn.instant-correct {
  background: #10b981 !important;
  border-color: #059669 !important;
  color: #ffffff !important;
}

.fe-pal-btn.instant-wrong {
  background: #ef4444 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
}

.fe-pal-btn.instant-correct.current,
.fe-pal-btn.instant-wrong.current {
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.28) !important;
}
