/* ===== Quiz Page Specific Styles ===== */
/* This file provides quiz-specific styling overrides for quiz.html */
/* Complements style.css with additional quiz-page-specific classes */

/* Back Link Navigation */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 0;
  margin-bottom: 12px;
}

.back-link:hover {
  text-decoration: underline;
}

/* Quiz Header: Category/Module + Progress */
.quiz-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.quiz-context {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.context-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(47, 97, 243, 0.08);
  border: 1px solid rgba(47, 97, 243, 0.18);
  color: #244bd3;
  font-weight: 600;
}

/* Progress Bar */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 10px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #2f61f3;
  transition: width 0.25s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--muted);
  min-width: 90px;
  text-align: right;
}

/* ===== Question Image Styles (NEW) ===== */
.question-image-container {
  margin: 16px 0;
  text-align: center;
  border-radius: 12px;
  overflow: hidden;
  background: #f8f9fa;
  border: 2px solid var(--border, #e0e0e0);
  transition: opacity 0.3s ease;
}

.question-image-container.loaded {
  background: transparent;
}

.question-image {
  max-width: 100%;
  max-height: 400px;
  width: auto;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
  /* Re-enable pointer events for question images so users can zoom/inspect */
  pointer-events: auto;
  /* Allow selection for accessibility */
  -webkit-user-select: auto;
  -moz-user-select: auto;
  -ms-user-select: auto;
  user-select: auto;
}

.question-image-error {
  padding: 40px 20px;
  color: #999;
  font-size: 14px;
  font-style: italic;
}

/* Image in review section */
.review-image {
  margin: 12px 0;
  text-align: center;
}

.review-image img {
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border, #e0e0e0);
  pointer-events: auto;
}

/* Mobile adjustments for question images */
@media (max-width: 600px) {
  .question-image-container {
    margin: 12px 0;
  }
  
  .question-image {
    max-height: 300px;
  }
  
  .review-image img {
    max-height: 200px;
  }
}

/* ===== End Question Image Styles ===== */

/* Question Text */
.question-text {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  margin: 14px 0 14px 0;
}

/* Options Form */
.options-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

/* Option Styling */
.option {
  position: relative;
  cursor: pointer;
}

.option input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.option label {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  transition: all 0.2s ease;
  font-size: 15px;
  line-height: 1.5;
}

.option label strong {
  margin-right: 6px;
}

/* Hover effect - light green */
.option label:hover {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.08);
  transform: translateX(4px);
}

/* Selected state - darker green */
.option input:checked + label {
  background: rgba(76, 175, 80, 0.15);
  border-color: #4caf50;
}

/* Disabled input styling */
.option input:disabled + label {
  cursor: not-allowed;
}

.option input:disabled + label:hover {
  transform: none;
  border-color: var(--border);
  background: #fff;
}

/* ===== Answer Feedback Icons (Checkmarks and X marks) ===== */

/* Result icon that appears to the left of the letter */
.result-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  margin-right: 8px;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Green checkmark for correct answers */
.result-icon.correct {
  color: #4caf50 !important;
}

/* Red X for incorrect answers user selected */
.result-icon.wrong {
  color: #f44336 !important;
}

/* ===== SUBMITTED STATE - Override style.css highlighting ===== */

/* After submission - remove ALL background highlighting */
/* This overrides .opt.correct-answer and .opt.wrong-answer from style.css */
.options.submitted .opt label,
.options.submitted .opt input:checked + label,
.options.submitted .opt.correct-answer label,
.options.submitted .opt.wrong-answer label {
  background: #fff !important;
  border-color: var(--border, #e0e0e0) !important;
  cursor: default !important;
  transform: none !important;
}

/* Override the .k badge colors from style.css after submission */
.options.submitted .opt .k,
.options.submitted .opt.correct-answer label .k,
.options.submitted .opt.wrong-answer label .k,
.options.submitted .opt input:checked + label .k {
  background: var(--primary, #2f61f3) !important;
}

/* Disable hover effects after submission */
.options.submitted .opt label:hover {
  background: #fff !important;
  border-color: var(--border, #e0e0e0) !important;
  transform: none !important;
}

/* Single-select: Disable hover AFTER selection is made (but keep selected styling intact) */
.options-form.is-single-select.has-selection .option input:not(:checked) + label:hover {
  border-color: var(--border);
  background: #fff;
  transform: none;
}

/* Single-select: also stop the hover "slide" animation on the selected option */
.options-form.is-single-select.has-selection .option input:checked + label:hover {
  transform: none;
}

/* Submit/Next Button - Target .btn.primary from base styles */
.btn.primary {
  display: block;
  width: 100%;
  font-size: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 800;
}

/* Feedback (Correct/Incorrect) - Small pill, left-aligned */
.feedback {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  text-align: left;
  border: 1px solid transparent;
}

.feedback.ok {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.35);
  color: #2e7d32;
}

.feedback.bad {
  background: rgba(244, 67, 54, 0.12);
  border-color: rgba(244, 67, 54, 0.35);
  color: #b71c1c;
}

.hidden {
  display: none !important;
}

/* Correct Answer Line + Rationale */
#answerLine {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(47, 97, 243, 0.08);
  border: 1px solid rgba(47, 97, 243, 0.20);
  color: #1e3fb3;
  font-size: 14px;
  line-height: 1.4;
}

#rationale {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.10);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* Summary page tweaks */
#summaryBody p {
  margin: 6px 0;
}

#summaryBody strong {
  color: var(--text);
}

/* ===== Fill-in-the-Blank Styles ===== */

.options.fill-in-the-blank {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.fitb-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fitb-instruction {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: var(--muted, #666);
  font-weight: 500;
}

.fitb-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fitb-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text, #333);
  min-width: 70px;
}

.fitb-input {
  flex: 1;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid var(--border, #e0e0e0);
  border-radius: 10px;
  background: #fff;
  color: var(--text, #333);
  transition: border-color 0.2s, box-shadow 0.2s;
  max-width: 400px;
}

.fitb-input:focus {
  outline: none;
  border-color: var(--primary, #2f61f3);
  box-shadow: 0 0 0 3px rgba(47, 97, 243, 0.15);
}

.fitb-input::placeholder {
  color: #999;
}

/* Fill-in-the-blank result states */
.fitb-input.correct {
  border-color: #4caf50 !important;
  background: rgba(76, 175, 80, 0.08);
}

.fitb-input.wrong {
  border-color: #f44336 !important;
  background: rgba(244, 67, 54, 0.08);
}

.fitb-input:disabled {
  opacity: 1;
  cursor: not-allowed;
}

/* ===== Result icons for fill-in-the-blank ===== */
.fitb-result-icon {
  font-size: 20px;
  font-weight: 700;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 8px;
}

.fitb-result-icon.correct {
  color: #4caf50;
  background: rgba(76, 175, 80, 0.15);
}

.fitb-result-icon.wrong {
  color: #f44336;
  background: rgba(244, 67, 54, 0.15);
}

/* Mobile adjustments for fill-in-the-blank */
@media (max-width: 600px) {
  .fitb-input-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .fitb-label {
    min-width: auto;
  }

  .fitb-input {
    max-width: none;
  }

  .fitb-result-icon {
    align-self: flex-start;
    margin-top: 8px;
    margin-left: 0;
  }
}

/* ===== Reset Quiz Button ===== */
#resetBtn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: #f44336;
  color: white;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

#resetBtn:hover:not(:disabled) {
  background: #d32f2f;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

#resetBtn:active:not(:disabled) {
  transform: translateY(0);
}

#resetBtn.hidden {
  display: none !important;
}
