/* Custom styles beyond Tailwind */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

body {
  font-family: 'Inter', sans-serif;
}

/* Question number grid */
.q-grid-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
}

.q-grid-btn.unanswered { background: #e5e7eb; color: #374151; }
.q-grid-btn.answered { background: #3b82f6; color: white; }
.q-grid-btn.current { border-color: #f59e0b; background: #fef3c7; color: #92400e; }
.q-grid-btn.correct { background: #10b981; color: white; }
.q-grid-btn.wrong { background: #ef4444; color: white; }
.q-grid-btn.graded { background: #8b5cf6; color: white; }
.q-grid-btn.ungraded { background: #fbbf24; color: #78350f; }

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-box {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

/* Timer */
.timer-warning { color: #ef4444; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gray { background: #f3f4f6; color: #374151; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  z-index: 100;
  animation: slideIn 0.3s ease;
}
.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-info { background: #3b82f6; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Loading spinner */
.spinner {
  border: 3px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Radio button custom */
.radio-option {
  display: flex;
  align-items: flex-start;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  gap: 12px;
}
.radio-option:hover { border-color: #93c5fd; background: #eff6ff; }
.radio-option.selected { border-color: #3b82f6; background: #eff6ff; }
.radio-option.correct { border-color: #10b981; background: #d1fae5; }
.radio-option.wrong { border-color: #ef4444; background: #fee2e2; }
.radio-option.disabled { pointer-events: none; opacity: 0.7; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }

/* v2.0.2: A modal marked with Tailwind's hidden class must stay hidden.
   This selector is more specific than .modal-overlay { display: flex; }. */
.modal-overlay.hidden {
  display: none !important;
}

/* v3.0.0: native hidden state and protected-page auth gate. */
[hidden] { display: none !important; }
html.auth-pending body { visibility: hidden !important; }
.topic-panel[hidden] { display: none !important; }

/* v3.4.0: responsive quiz/exam editor. */
.quiz-editor-overlay {
  align-items: flex-start;
  overflow-y: auto;
  padding: clamp(0.75rem, 3vh, 2rem);
}

.quiz-editor-modal {
  width: min(96vw, 1120px);
  max-width: 1120px;
  max-height: calc(100vh - clamp(1.5rem, 6vh, 4rem));
  overflow-y: auto;
  padding: clamp(1rem, 2vw, 1.75rem);
}

@media (max-width: 640px) {
  .quiz-editor-overlay {
    padding: 0;
    align-items: stretch;
  }

  .quiz-editor-modal {
    width: 100vw;
    max-width: none;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }
}

/* Essays that were submitted blank are automatically locked at zero. */
.score-input-locked {
  background: #f3f4f6;
  color: #6b7280;
  cursor: not-allowed;
}

/* v3.4.0: variable-option MCQs and Question Set navigation. */
.q-grid-btn.partial { background: #bae6fd; color: #075985; }
.q-grid-btn.question-set-grid-btn {
  width: auto;
  min-width: 52px;
  padding: 0 10px;
}
.option-label-circle {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  border-radius: 9999px;
  border: 2px solid #d1d5db;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.option-label-circle.selected {
  border-color: #3b82f6;
  background: #3b82f6;
  color: white;
}
.question-set-passage > :first-child { margin-top: 0; }
.question-set-passage > :last-child { margin-bottom: 0; }
.question-set-passage p { margin: 0.75rem 0; }
.question-set-passage ul,
.question-set-passage ol { margin: 0.75rem 0; padding-left: 1.5rem; }
.question-set-passage ul { list-style: disc; }
.question-set-passage ol { list-style: decimal; }
