/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Base ===== */
body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(135deg, #0d1b2a 0%, #1b3a4b 100%);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 48px;
  color: #1a202c;
}

/* ===== Layout principal ===== */
.app-wrapper {
  width: 100%;
  max-width: 760px;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  margin-bottom: 24px;
  color: #ffffff;
}

.app-header h1 {
  font-size: 2rem;
  font-weight: 700;
}

.app-header .subtitle {
  font-size: 0.95rem;
  color: #cbd5f5;
  margin-top: 6px;
}

/* ===== Card principal ===== */
.card {
  background: #ffffff;
  border-radius: 20px;
  padding: 32px 36px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Utilidades ===== */
.hidden {
  display: none !important;
}

/* ===== Botões gerais ===== */
.btn-primary,
.btn-next,
.btn-restart,
.btn-logout,
.auth-tab {
  border: none;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.btn-primary,
.btn-next {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: #ffffff;
  font-size: 1rem;
}

.btn-primary:hover,
.btn-next:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-primary:active,
.btn-next:active,
.btn-restart:active,
.btn-logout:active {
  transform: scale(0.98);
}

.btn-restart {
  padding: 14px 32px;
  background: linear-gradient(135deg, #0d1b2a, #1b3a4b);
  color: #ffffff;
  font-size: 1rem;
}

.btn-restart:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-logout {
  padding: 10px 14px;
  background: #0f172a;
  color: #ffffff;
  font-size: 0.9rem;
}

.btn-logout:hover {
  opacity: 0.9;
}

/* ===== TELA DE AUTENTICAÇÃO ===== */
.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 12px 16px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.95rem;
}

.auth-tab.active {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: #ffffff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form h2 {
  font-size: 1.4rem;
  color: #0f172a;
  margin-bottom: 8px;
}

.auth-form label {
  font-size: 0.92rem;
  font-weight: 600;
  color: #334155;
}

.auth-form input {
  width: 100%;
  padding: 14px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.95rem;
  outline: none;
  transition: 0.2s;
}

.auth-form input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
}

.auth-message {
  margin-bottom: 18px;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.auth-message.success {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.auth-message.error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

/* ===== Topo do quiz ===== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#user-name-display {
  font-size: 0.98rem;
  font-weight: 700;
  color: #0f172a;
}

#user-email-display {
  font-size: 0.84rem;
  color: #64748b;
}

/* ===== Meta do Quiz ===== */
.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 12px;
}

#score-display {
  background: #0d1b2a;
  color: #ffffff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
}

/* ===== Barra de progresso ===== */
.progress-bar-container {
  background: #e2e8f0;
  border-radius: 999px;
  height: 8px;
  margin-bottom: 28px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #06b6d4, #0284c7);
  transition: width 0.4s ease;
}

/* ===== Categoria ===== */
.category-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0284c7;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

/* ===== Texto da pergunta ===== */
#question-text {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.6;
  color: #0f172a;
  margin-bottom: 28px;
}

/* ===== Opções ===== */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 0.95rem;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  text-align: left;
  transition: 0.2s;
}

.option-btn:hover:not(:disabled) {
  border-color: #06b6d4;
  background: #f0f9ff;
  transform: translateX(4px);
}

.option-btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

/* Letra A B C D */
.option-btn .label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #e2e8f0;
  font-weight: 700;
  font-size: 0.8rem;
  color: #475569;
}

/* ===== Resposta correta ===== */
.option-btn.correct {
  border-color: #22c55e;
  background: #f0fdf4;
  color: #166534;
}

.option-btn.correct .label {
  background: #22c55e;
  color: #ffffff;
}

/* ===== Resposta errada ===== */
.option-btn.wrong {
  border-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
}

.option-btn.wrong .label {
  background: #ef4444;
  color: #ffffff;
}

/* ===== Feedback ===== */
.feedback-area {
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 20px;
}

.feedback-area.correct-feedback {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.feedback-area.wrong-feedback {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.feedback-area .explanation {
  margin-top: 8px;
  color: #374151;
}

.feedback-icon {
  margin-right: 6px;
}

/* ===== Tela final ===== */
.end-content {
  text-align: center;
  padding: 16px 0;
}

.end-emoji {
  font-size: 4rem;
  margin-bottom: 16px;
}

.end-content h2 {
  font-size: 1.7rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 12px;
}

.end-score {
  font-size: 1.1rem;
  color: #475569;
}

.end-percent {
  font-size: 3rem;
  font-weight: 700;
  color: #0284c7;
  margin: 8px 0;
}

.end-message {
  font-size: 1rem;
  color: #64748b;
  margin-bottom: 20px;
}

/* ===== Caixa de aprovação ===== */
.approval-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}

#approval-status {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}

#approval-rule {
  font-size: 0.9rem;
  color: #64748b;
}

.certificate-actions {
  margin-bottom: 20px;
}

/* ===== Certificado ===== */
.certificate-template {
  position: fixed;
  left: -99999px;
  top: 0;
  width: 1123px;
  background: #ffffff;
  padding: 40px;
}

.certificate-box {
  width: 100%;
  min-height: 794px;
  border: 10px solid #0284c7;
  border-radius: 24px;
  padding: 70px 60px;
  text-align: center;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.certificate-box h1 {
  font-size: 2.6rem;
  color: #0f172a;
  margin-bottom: 16px;
}

.certificate-subtitle {
  font-size: 1.2rem;
  color: #0284c7;
  margin-bottom: 34px;
  font-weight: 600;
}

.certificate-text {
  font-size: 1.15rem;
  color: #334155;
  margin-bottom: 12px;
}

#certificate-name {
  font-size: 2rem;
  color: #0f172a;
  margin: 10px 0 20px;
}

.certificate-grade {
  font-size: 3rem;
  font-weight: 700;
  color: #0284c7;
  margin: 10px 0 20px;
}

.certificate-date {
  margin-top: 24px;
  font-size: 1rem;
  color: #475569;
}

/* ===== Responsivo ===== */
@media (max-width: 640px) {
  .card {
    padding: 24px 20px;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }

  #question-text {
    font-size: 1.05rem;
  }

  .auth-tabs {
    flex-direction: column;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .quiz-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .end-percent {
    font-size: 2.4rem;
  }

  .btn-restart,
  .btn-logout,
  .btn-primary {
    width: 100%;
  }
}