/* Micro Quiz Component Styles */

.micro-quiz {
  max-width: 700px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: white;
  color-scheme: light;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

.micro-quiz.start-screen,
.micro-quiz.question-screen,
.micro-quiz.completion-screen,
.micro-quiz.loading {
  background: #fff;
  color-scheme: light;
}

/* Loading State */
.micro-quiz.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: #666;
  font-size: 1.1rem;
}

/* Start Screen */
.micro-quiz.start-screen {
  text-align: center;
}

.quiz-header h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.75rem;
  color: #333;
  line-height: 1.3;
}

.quiz-description {
  color: #666;
  font-size: 1rem;
  margin: 0.5rem 0 1.5rem 0;
}

.quiz-meta {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.badge-difficulty {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background: #e3f2fd;
  color: #1976d2;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
}

.estimated-time {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background: #f3e5f5;
  color: #7b1fa2;
  border-radius: 20px;
  font-size: 0.85rem;
}

.quiz-info {
  margin: 1.5rem 0;
  padding: 1rem;
  background: #f5f5f5;
  border-radius: 6px;
  color: #555;
}

.quiz-info p {
  margin: 0;
  font-size: 0.95rem;
}

.quiz-name-entry {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.5rem auto 0;
  max-width: 420px;
  text-align: left;
}

.quiz-name-entry label {
  font-weight: 600;
  color: #111827;
}

.quiz-name-entry input {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #111827;
  font-size: 1rem;
}

.quiz-name-entry input:focus {
  outline: 2px solid rgba(102, 126, 234, 0.35);
  border-color: #667eea;
  background: white;
}

.quiz-name-note {
  margin: 0;
  font-size: 0.9rem;
  color: #6b7280;
}

.quiz-name-error {
  margin: 0;
  font-size: 0.9rem;
  color: #b91c1c;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  display: inline-block;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  margin-top: 1rem;
}

.btn-secondary {
  background: #f5f5f5;
  color: #333;
  border: 2px solid #ddd;
  margin-top: 1rem;
}

.btn-secondary:hover:not(:disabled) {
  border-color: #667eea;
  color: #667eea;
}

/* Progress Bar */
.progress-container {
  margin-bottom: 2rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.progress-text {
  font-size: 0.9rem;
  color: #666;
  font-weight: 600;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transform-origin: left center;
  transition: transform 0.3s ease;
}

.bundle-loader {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  color: #334155;
  font-weight: 600;
}

.bundle-loader.bundle-success {
  color: #166534;
}

.completion-download {
  margin-top: 1.5rem;
}

.loader-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #667eea;
  animation: loader-pulse 1s infinite ease-in-out;
}

@keyframes loader-pulse {

  0%,
  100% {
    opacity: 0.25;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.35);
  }
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.navigation-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.15rem;
  padding-top: 0;
  border-top: none;
}

.micro-quiz .navigation-buttons .quiz-action-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  margin-top: 0;
  height: auto;
  line-height: 1.1;
  border-radius: 6px;
  box-shadow: none;
  background: none;
  color: #374151;
  border: 1px solid #d1d5db;
}

.micro-quiz .navigation-buttons .quiz-action-btn:hover {
  border-color: #667eea;
  color: #667eea;
}


.quiz-start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
}

.quiz-start-actions .btn {
  margin-top: 0;
}

.quiz-start-actions .btn-secondary {
  background: #f5f5f5;
}

.feedback {
  margin-top: 1.5rem;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.question-text {
  margin: 0 0 1.5rem 0;
  font-size: 1.25rem;
  color: #333;
  line-height: 1.5;
}

/* Options Container */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.option-button {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.5rem;
  background: #f9f9f9;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-size: 1rem;
  color: #333;
  color-scheme: light;
}

.option-button:hover:not(:disabled) {
  border-color: #667eea;
  background: #f5f5ff;
}

.option-button:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

.option-button:disabled {
  cursor: not-allowed;
}

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  background: #e0e0e0;
  border-radius: 50%;
  font-weight: 600;
  color: #666;
  flex-shrink: 0;
}

.option-button.selected {
  background: #eef2ff;
  border-color: #667eea;
}

.option-button.correct .option-letter {
  background: #4caf50;
  color: white;
}

.option-button.incorrect .option-letter {
  background: #f44336;
  color: white;
}

.option-text {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0;
}

/* Feedback */
.feedback {
  margin: 1.5rem 0;
  padding: 1rem;
  border-radius: 6px;
  border-left: 4px solid;
  animation: slideIn 0.3s ease;
}

/* Navigation Buttons */
.navigation-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.25rem;
  border-top: none;
}

/* Completion Screen */
.micro-quiz.completion-screen {
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  padding-top: 4rem;
}

.completion-screen.review-open {
  padding-top: 10vh;
}

.completion-header {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
}

.completion-screen.review-open .completion-header {
  display: none;
}

.completion-text {
  width: 100%;
  max-width: 720px;
}

.see-answers-btn {
  margin-top: 1rem;
}

.completion-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  color: white;
}

.completion-screen h2 {
  margin: 0;
  font-size: 1.9rem;
  color: #333;
}

.score-summary {
  margin: 1rem 0 0 0;
  padding: 1rem 1.25rem;
  background: #f5f5f5;
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
}

.score-display {
  margin: 0 0 0.5rem 0;
  font-size: 1.15rem;
  color: #333;
}

.performance-message {
  margin: 0;
  font-size: 1rem;
  color: #555;
  line-height: 1.6;
}

.completion-actions {
  margin: 1rem 0 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.review-summary {
  margin-top: 0;
  width: 100%;
}

.review-summary h3 {
  margin-bottom: 1rem;
  font-size: 1.35rem;
  color: #333;
}

.review-list {
  display: grid;
  gap: 1rem;
  max-height: calc(100vh - 12rem);
  overflow: auto;
  padding-right: 0.75rem;
}

.review-item {
  padding: 1rem;
  background: #f5f7ff;
  border-radius: 12px;
  border: 1px solid rgba(102, 126, 234, 0.18);
}

.review-item.correct {
  border-left: 4px solid #4caf50;
}

.review-item.incorrect {
  border-left: 4px solid #f44336;
}

.review-question {
  margin-bottom: 0.75rem;
  font-weight: 700;
  color: #1a202c;
}

.review-answer-row,
.review-explanation {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.review-label {
  font-weight: 600;
  color: #2f4368;
}

.review-answer {
  color: #263238;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .micro-quiz {
    padding: 1rem;
    margin: 1rem;
    border-radius: 6px;
  }

  .quiz-header h2 {
    font-size: 1.5rem;
  }

  .question-text {
    font-size: 1.1rem;
  }

  .option-button {
    padding: 0.5rem;
    gap: 0.75rem;
  }

  .option-letter {
    min-width: 24px;
    height: 24px;
    font-size: 0.9rem;
  }

  .option-text {
    font-size: 0.95rem;
  }

  .completion-badge {
    width: 100px;
    height: 100px;
    font-size: 2rem;
  }

  .btn {
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    width: 100%;
  }

  .navigation-buttons {
    flex-direction: column;
  }

  .quiz-meta {
    flex-direction: column;
    gap: 0.75rem;
  }

  .badge-difficulty,
  .estimated-time {
    width: 100%;
  }

  .progress-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* Fenced code block styles produced by our lightweight markdown converter */
.md-code-block {
  font-size: 0.95rem;
  color: #1a202c;
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: #f6f8fa;
  border: 1px solid #e6edf3;
  border-radius: 6px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', 'Courier New', monospace;
}

.md-code-block code {
  display: block;
  white-space: pre;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {

  .micro-quiz,
  .option-button,
  .progress-fill,
  .feedback {
    animation: none;
    transition: none;
  }
}

/* Force light appearance — quiz is always rendered on a white card regardless of system theme */
@media (prefers-color-scheme: dark) {

  .micro-quiz,
  .micro-quiz.start-screen,
  .micro-quiz.question-screen,
  .micro-quiz.completion-screen {
    background: #ffffff !important;
    color: #111827 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
  }

  .quiz-header h2,
  .question-text,
  .completion-screen h2,
  .review-summary h3,
  .review-question {
    color: #1a202c !important;
  }

  .quiz-description,
  .progress-text,
  .score-display,
  .performance-message,
  .review-answer {
    color: #374151 !important;
  }

  .option-button {
    background: #f9f9f9 !important;
    border-color: #e0e0e0 !important;
    color: #333333 !important;
  }

  .option-button:hover:not(:disabled) {
    background: #f5f5ff !important;
    border-color: #667eea !important;
  }

  .option-button.selected {
    background: #eef2ff !important;
    border-color: #667eea !important;
  }

  .option-text {
    color: #333333 !important;
  }

  .option-letter {
    background: #e0e0e0 !important;
    color: #666666 !important;
  }

  .quiz-info {
    background: #f5f5f5 !important;
    color: #555555 !important;
  }

  .score-summary {
    background: #f5f5f5 !important;
  }

  .btn-secondary {
    background: #f5f5f5 !important;
    color: #333333 !important;
    border-color: #dddddd !important;
  }

  .navigation-buttons {
    background: #ffffff !important;
  }

  .review-item {
    background: #f5f7ff !important;
  }

  .review-label {
    color: #2f4368 !important;
  }

  .progress-bar {
    background: #e0e0e0 !important;
  }
}/* ============================================================
   QuizModule.css
   Styles for the self-contained QuizModule component.
   These mirror the quiz-related rules previously in ModulePage.css
   so QuizModule renders correctly both inside ModulePage and
   on the standalone QuizPage.
   ============================================================ */

/* ── Section wrapper ─────────────────────────────────────── */

.module-quiz-section {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #ffffff;
    color: #111827;
    transition: box-shadow 0.2s ease;
}

.module-quiz-section:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* collapsed: hide the quiz body */
.module-quiz-section.collapsed .micro-quiz {
    display: none;
}

/* expanded: allow fullscreen */
.module-quiz-section.expanded {
    border-color: var(--primary-color, #3b82f6);
}

/* ── Header row ──────────────────────────────────────────── */
.module-quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    flex-wrap: wrap;
}

.module-quiz-header-left {
    min-width: 0;
    display: grid;
    gap: 0.3rem;
}

.module-quiz-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.module-quiz-header h2 {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0;
    color: #111827;
}

.module-quiz-hint {
    font-size: 0.82rem;
    color: #6b7280;
    margin: 0;
}

.quiz-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid #dbe5ef;
    background: #f8fbff;
    color: #475569;
    font-size: 0.73rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.25rem 0.5rem;
}

/* ── Toggle button ───────────────────────────────────────── */
.quiz-toggle {
    white-space: nowrap;
    flex-shrink: 0;
}

.module-quiz-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
    padding: 0 1rem 0.85rem;
}

.quiz-attempts,
.quiz-message {
    font-size: 0.78rem;
    color: #4b5563;
}

.quiz-attempts {
    border: 1px solid #dbe5ef;
    background: #f8fafc;
    border-radius: 999px;
    padding: 0.18rem 0.5rem;
    font-weight: 700;
}

/* ── Fullscreen overrides ────────────────────────────────── */
.module-quiz-section:fullscreen,
.module-quiz-section:-webkit-full-screen {
    overflow-y: auto;
    padding: 2rem;
    background: var(--bg-color, #fff);
    border-radius: 0;
}

/* ── Outside-box header row (visible when quiz is open) ──── */
.quiz-outside-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    /* reduce top padding to tighten gap under the navbar */
    padding: 0.15rem 0.25rem 0.12rem !important;
    /* 0.12rem bottom = ~1/6 of previous 0.6rem */
    flex-wrap: wrap;
}

.quiz-outside-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.quiz-outside-name {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

.quiz-outside-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.quiz-outside-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: #4b5563;
    font-weight: 500;
}

.quiz-outside-label i {
    font-size: 1rem;
    color: #6b7280;
}

.quiz-outside-action-btn {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.3rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.quiz-outside-action-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.quiz-outside-progress {
    font-size: 0.95rem;
    color: #4b5563;
    margin: 0 0 0.5rem 0;
}

/* When the wrapper includes Bootstrap's `mt-4`, reduce it by 50% to tighten top spacing */
.quiz-module-wrapper {
    /* Reduce default top spacing for the quiz wrapper (halved from typical mt-4)
       Use !important to ensure this takes precedence over utility classes. */
    margin-top: 0rem !important;
}

.quiz-module-wrapper.mt-4 {
    margin-top: 0.25rem !important;
}

/* ── Force light appearance in dark OS theme ─────────────── */
@media (prefers-color-scheme: dark) {
    .module-quiz-section {
        background: #ffffff !important;
        border-color: #e5e7eb !important;
        color: #111827 !important;
    }

    .module-quiz-header h2 {
        color: #111827 !important;
    }

    .module-quiz-hint {
        color: #6b7280 !important;
    }

    .quiz-pill {
        background: #f8fbff !important;
        color: #475569 !important;
        border-color: #dbe5ef !important;
    }

    .quiz-attempts,
    .quiz-message {
        color: #4b5563 !important;
    }

    .quiz-outside-label {
        color: #4b5563 !important;
    }

    .quiz-outside-name {
        color: #111827 !important;
    }

    .quiz-outside-action-btn {
        color: #374151 !important;
        border-color: #d1d5db !important;
        background: #ffffff !important;
    }
}

/* When a quiz session is active, reduce the page top padding so
   the module quiz header appears higher on the page. This overrides
   the site-level `.exams-hub` padding which otherwise pushes content down. */
body.quiz-active .exams-hub {
    padding-top: 1.25rem !important;
}