/* ═══════════════════════════════════════════════════════
   QUIZ MODAL — Pop-up Chat Style (Typebot Emulation)
   Design System: Navy + Gold + Offwhite
   ═══════════════════════════════════════════════════════ */

/* ── OVERLAY ──────────────────────────────────────────── */
.quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(5, 28, 81, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.4s;
}

.quiz-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── MODAL CONTAINER ──────────────────────────────────── */
.quiz-modal {
  position: fixed;
  z-index: 10001;
  top: 50%;
  left: 50%;
  width: min(94vw, 480px);
  max-height: 92dvh;
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.4s;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: #FBFAF8;
  box-shadow: 0 24px 80px rgba(5, 28, 81, 0.25),
              0 0 0 1px rgba(5, 28, 81, 0.06);
}

.quiz-modal.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* ── HEADER ───────────────────────────────────────────── */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  background: #051C51;
  color: #F6F6F6;
  position: relative;
}

.quiz-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #A37940, #E9D199, #A37940);
}

.quiz-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(233, 209, 153, 0.4);
  flex-shrink: 0;
}

.quiz-header-info {
  flex: 1;
  min-width: 0;
}

.quiz-header-name {
  font-family: var(--font-heading, 'MADE Evolve Sans', sans-serif);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.quiz-header-role {
  font-family: var(--font-body, 'MADE Evolve Sans', sans-serif);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(233, 209, 153, 0.85);
  margin-top: 2px;
}

.quiz-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(246, 246, 246, 0.1);
  transition: background 0.3s;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
  color: #F6F6F6;
}

.quiz-close:hover {
  background: rgba(246, 246, 246, 0.2);
}

.quiz-close svg {
  width: 18px;
  height: 18px;
}

/* ── PROGRESS BAR ─────────────────────────────────────── */
.quiz-progress {
  height: 4px;
  background: rgba(5, 28, 81, 0.06);
  position: relative;
  flex-shrink: 0;
}

.quiz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #A37940, #E9D199);
  border-radius: 0 2px 2px 0;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  width: 0%;
}

/* ── CHAT BODY ────────────────────────────────────────── */
.quiz-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  min-height: 340px;
  max-height: 55dvh;
}

/* Custom scrollbar dentro do chat */
.quiz-body::-webkit-scrollbar {
  width: 4px;
}

.quiz-body::-webkit-scrollbar-track {
  background: transparent;
}

.quiz-body::-webkit-scrollbar-thumb {
  background: rgba(163, 121, 64, 0.25);
  border-radius: 2px;
}

/* ── CHAT BUBBLES ─────────────────────────────────────── */
.quiz-bubble {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 18px;
  font-family: var(--font-body, 'MADE Evolve Sans', sans-serif);
  font-size: 0.92rem;
  line-height: 1.55;
  font-weight: 400;
  animation: quizBubbleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  position: relative;
}

/* Balão do "bot" (Dr. Dharien) — esquerda */
.quiz-bubble--bot {
  align-self: flex-start;
  background: #FFFFFF;
  color: #051C51;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(5, 28, 81, 0.06);
  border: 1px solid rgba(5, 28, 81, 0.05);
}

/* Balão do usuário — direita */
.quiz-bubble--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #A37940, #c9a050);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(163, 121, 64, 0.25);
}

@keyframes quizBubbleIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Emoji no balão */
.quiz-bubble--bot .quiz-emoji {
  font-size: 1.1em;
}

/* ── TYPING INDICATOR ─────────────────────────────────── */
.quiz-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 16px 20px;
  align-self: flex-start;
  background: #FFFFFF;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(5, 28, 81, 0.06);
  border: 1px solid rgba(5, 28, 81, 0.05);
}

.quiz-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(5, 28, 81, 0.2);
  animation: quizTypingPulse 1.4s ease-in-out infinite;
}

.quiz-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.quiz-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes quizTypingPulse {
  0%, 60%, 100% { 
    transform: translateY(0);
    background: rgba(5, 28, 81, 0.15);
  }
  30% { 
    transform: translateY(-6px);
    background: rgba(163, 121, 64, 0.5);
  }
}

/* ── INPUT AREA ───────────────────────────────────────── */
.quiz-input-area {
  padding: 16px 20px;
  border-top: 1px solid rgba(5, 28, 81, 0.06);
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* Texto de input */
.quiz-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-input {
  flex: 1;
  padding: 14px 18px;
  border: 1.5px solid rgba(5, 28, 81, 0.1);
  border-radius: 12px;
  background: #FBFAF8;
  font-family: var(--font-body, 'MADE Evolve Sans', sans-serif);
  font-size: 16px; /* >= 16px para evitar zoom no iOS */
  font-weight: 400;
  color: #051C51;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.quiz-input::placeholder {
  color: rgba(5, 28, 81, 0.3);
  font-weight: 300;
}

.quiz-input:focus {
  border-color: #A37940;
  box-shadow: 0 0 0 3px rgba(163, 121, 64, 0.12);
}

.quiz-input-send {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A37940, #c9a050);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  border: none;
  transition: transform 0.2s, box-shadow 0.3s;
}

.quiz-input-send:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 16px rgba(163, 121, 64, 0.35);
}

.quiz-input-send:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.quiz-input-send svg {
  width: 20px;
  height: 20px;
}

/* ── OPTION BUTTONS (múltipla escolha) ────────────────── */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
}

.quiz-option-btn {
  width: 100%;
  padding: 13px 18px;
  border: 1.5px solid rgba(5, 28, 81, 0.1);
  border-radius: 12px;
  background: #FFFFFF;
  font-family: var(--font-body, 'MADE Evolve Sans', sans-serif);
  font-size: 0.88rem;
  font-weight: 400;
  color: #051C51;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.quiz-option-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: transparent;
  border-radius: 0 2px 2px 0;
  transition: background 0.3s;
}

.quiz-option-btn:hover {
  border-color: #A37940;
  background: rgba(163, 121, 64, 0.04);
  transform: translateX(4px);
}

.quiz-option-btn:hover::before {
  background: #A37940;
}

.quiz-option-btn:active {
  transform: translateX(4px) scale(0.98);
}

/* ── PHONE INPUT COM MÁSCARA ──────────────────────────── */
.quiz-phone-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-phone-prefix {
  font-family: var(--font-body, 'MADE Evolve Sans', sans-serif);
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(5, 28, 81, 0.45);
  flex-shrink: 0;
  user-select: none;
}

/* ── FINAL: SUCCESS STATE ─────────────────────────────── */
.quiz-success {
  text-align: center;
  padding: 32px 20px;
}

.quiz-success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(163, 121, 64, 0.12), rgba(233, 209, 153, 0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  animation: quizSuccessPop 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.quiz-success-icon svg {
  width: 32px;
  height: 32px;
  color: #A37940;
}

@keyframes quizSuccessPop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.quiz-success-title {
  font-family: var(--font-heading, 'MADE Evolve Sans', sans-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: #051C51;
  margin-bottom: 8px;
}

.quiz-success-text {
  font-family: var(--font-body, 'MADE Evolve Sans', sans-serif);
  font-size: 0.88rem;
  color: rgba(5, 28, 81, 0.65);
  line-height: 1.6;
  margin-bottom: 20px;
}

.quiz-wa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  background: #25D366;
  color: #fff;
  font-family: var(--font-body, 'MADE Evolve Sans', sans-serif);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 50px;
  text-decoration: none;
  transition: background 0.25s, transform 0.2s, box-shadow 0.25s;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
  animation: quizSuccessPop 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.5s both;
}

.quiz-wa-btn:hover {
  background: #1ebe5a;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
}

.quiz-wa-btn:active {
  transform: translateY(0);
}

.quiz-wa-btn svg {
  flex-shrink: 0;
}

/* ── STEP HIDDEN ──────────────────────────────────────── */
.quiz-step {
  display: none;
}

.quiz-step.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── RESPONSIVE MOBILE ────────────────────────────────── */
@media (max-width: 600px) {
  .quiz-modal {
    width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.4s,
                visibility 0.4s;
  }

  .quiz-modal.active {
    transform: translateY(0);
  }

  .quiz-body {
    min-height: 0;
    max-height: none;
    flex: 1;
  }

  .quiz-options {
    max-height: 260px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .quiz-header {
    padding: 16px 18px;
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .quiz-input-area {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* ── REDUCED MOTION ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .quiz-bubble,
  .quiz-success-icon {
    animation: none !important;
  }

  .quiz-modal,
  .quiz-overlay {
    transition-duration: 0.01s !important;
  }
}
