/* ============================================================
   CHAT-BOLD-V1 — Estilo visual (CP3 adendo)
   Paleta e componentes alinhados às referências enviadas por
   Kleberson: fundo claro/creme, bolhas bot (esquerda, cinza) e
   usuário (direita, bege/tan), avatar real, progresso segmentado
   numerado, seletor+modal para múltipla escolha, tela final com
   badge + headline personalizada.
   ============================================================ */

:root {
  --bg: #F3F1EC;
  --bg-card: #FFFFFF;
  --bubble-bot: #EFEEEA;
  --bubble-user: #D9C7A8;
  --text: #1A1A1A;
  --text-muted: #6B6B63;
  --border: #E4E1D8;
  --accent: #C9A876;
  --accent-dark: #B08F5E;
  --cta: #E8722C;
  --cta-hover: #D6631F;
  --progress-track: #E8E6E0;
  --success: #3A8A5C;
  --error: #C0392B;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --avatar-img: url('assets/kewin.png');
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

#app { min-height: 100vh; width: 100%; }

.hidden { display: none !important; }

.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
}
.screen.active { display: flex; }

/* ============================================================
   HERO
   ============================================================ */
#screen-hero {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.hero-inner {
  max-width: 560px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
}

.hero-headline {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  line-height: 1.2;
  margin: 0;
  color: var(--text);
}
.hero-headline .highlight { color: var(--cta); }

.hero-subheadline {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 460px;
  margin: 0;
}

.btn-hero {
  background: var(--cta);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 16px 32px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  width: 100%;
  max-width: 360px;
}
.btn-hero:hover { background: var(--cta-hover); }
.btn-hero:active { transform: scale(0.98); }

.hero-microcopy {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.resume-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  width: 100%;
  max-width: 460px;
  text-align: left;
}
.resume-banner-text { font-size: 14px; color: var(--text); margin-bottom: 12px; }
.resume-banner-actions { display: flex; gap: 8px; }
.btn-resume, .btn-restart {
  flex: 1;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
}
.btn-resume { background: var(--cta); color: #fff; border: none; }
.btn-restart { background: transparent; color: var(--text-muted); }

/* ============================================================
   HEADER (avatar real do Kewin)
   ============================================================ */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--avatar-img) center 20% / cover no-repeat, #111;
  flex-shrink: 0;
}
.chat-header-name { font-weight: 700; font-size: 14px; }
.chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

/* ============================================================
   PROGRESSO SEGMENTADO
   ============================================================ */
.chat-progress-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.chat-progress-bar-done { justify-content: flex-end; }

.progress-segments {
  display: flex;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
.progress-seg {
  height: 5px;
  flex: 1;
  border-radius: 999px;
  background: var(--progress-track);
  transition: background 0.3s ease;
}
.progress-seg.filled { background: var(--accent); }

.progress-counter {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
.progress-counter strong { font-size: 16px; color: var(--text); font-weight: 800; }

/* Compat: barra antiga de preenchimento contínuo (fallback) */
.chat-progress-fill { display: none; }

/* ============================================================
   MENSAGENS
   ============================================================ */
.chat-messages, .capture-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 100%;
  animation: msgIn 0.25s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.bold-msg { justify-content: flex-start; }
.message.user-msg { justify-content: flex-end; }

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--avatar-img) center 20% / cover no-repeat, #111;
  flex-shrink: 0;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 1.45;
  max-width: min(78%, 480px);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.bold-msg .message-bubble {
  background: var(--bubble-bot);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.user-msg .message-bubble {
  background: var(--bubble-user);
  color: #2A2114;
  font-weight: 600;
  border-bottom-right-radius: 4px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  background: var(--bubble-bot);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ============================================================
   SELETOR (rodapé) + MODAL de alternativas
   ============================================================ */
.answer-options {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 20px;
}

.selector-wrap { display: flex; flex-direction: column; gap: 8px; }
.selector-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: center;
}
.selector-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 16px 20px;
  font-size: 15px;
  font-family: var(--font);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: border-color 0.15s ease;
}
.selector-field:hover { border-color: var(--accent); }
.selector-field.selected { border-color: var(--accent-dark); }
.selector-placeholder { color: var(--text-muted); }
.selector-field.selected .selector-placeholder { color: var(--text); font-weight: 600; }
.selector-chevron { color: var(--text-muted); font-size: 14px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 12, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.modal-overlay.visible { opacity: 1; }

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 22px 14px;
}
.modal-title { font-size: 20px; font-weight: 800; margin: 0; }
.modal-close {
  background: var(--bg);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
}
.modal-options {
  overflow-y: auto;
  padding: 0 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-option {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 15px;
  font-family: var(--font);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
  animation: msgIn 0.2s ease backwards;
}
.modal-option:hover, .modal-option:focus-visible {
  border-color: var(--accent);
  background: #FBF9F5;
}

/* ============================================================
   INPUT DE TEXTO (captura)
   ============================================================ */
.chat-input-area {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.consent-row input { margin-top: 2px; }
/* CP4.1 — "Política de Privacidade" em negrito, explicitamente NÃO um link
   (sem cursor:pointer, sem sublinhado, sem :hover) — decisão registrada em
   DECISOES.md D22, a partir de referência visual enviada por Kleberson. */
.consent-policy-label {
  font-weight: 700;
  color: inherit;
  cursor: default;
  text-decoration: none;
}

/* CP4.1 — rótulo "Etapa 1 de 2 — Seus dados" / "Etapa 2 de 2 — Diagnóstico" */
.chat-stage-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-align: center;
  padding: 10px 20px 0;
  text-transform: uppercase;
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 20px;
}
.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: var(--font);
  background: transparent;
  color: var(--text);
  min-width: 0;
}
.chat-input.error { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cta);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-send svg { width: 18px; height: 18px; }
.input-error-msg {
  font-size: 12px;
  color: var(--error);
  padding-left: 20px;
}

/* ============================================================
   PROCESSING
   ============================================================ */
#screen-processing {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.processing-inner {
  max-width: 420px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.processing-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--progress-track);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-intro { font-size: 17px; font-weight: 700; margin: 0; }
.processing-items {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.processing-item {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-align: left;
}
.processing-item.visible { opacity: 1; transform: translateY(0); }
.processing-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.processing-item-text { font-size: 14px; }
.processing-conclusion {
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.3s ease;
  margin: 0;
}
.processing-conclusion.visible { opacity: 1; }

/* ============================================================
   RESULTADO FINAL
   ============================================================ */
#screen-result.result-screen-final {
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px 60px;
  overflow-y: auto;
}
.result-final-wrap {
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.result-final-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.result-final-badge {
  display: inline-block;
  border: 1px solid var(--accent-dark);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 6px 14px;
  border-radius: 999px;
}
.result-final-headline {
  font-size: clamp(24px, 4.5vw, 32px);
  font-weight: 800;
  line-height: 1.25;
  margin: 0;
}
.result-final-sub {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0;
  max-width: 440px;
}

.result-final-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
}

.result-profile-row { display: flex; gap: 14px; align-items: flex-start; }
.result-profile-icon { font-size: 30px; flex-shrink: 0; }
.result-profile-name { font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.result-profile-desc { font-size: 14px; color: var(--text-muted); line-height: 1.5; }

.result-reasons {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.result-reason {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.result-reason-check {
  color: var(--success);
  font-weight: 800;
  flex-shrink: 0;
}

.result-cta-card { text-align: center; }
.result-cta-eyebrow { font-size: 13px; font-weight: 700; color: var(--text-muted); margin: 0 0 6px; }
.result-cta-price {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 18px;
}
.result-cta-price span { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.result-waitlist-intro {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 18px;
}

.btn-cta-final {
  background: var(--cta);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 16px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn-cta-final:hover { background: var(--cta-hover); }
.btn-cta-final:active { transform: scale(0.98); }
.btn-cta-final:disabled { opacity: 0.7; cursor: default; }
.btn-cta-waitlist.joined { background: var(--success); }

.result-cta-note {
  font-size: 13px;
  color: var(--text-muted);
  margin: 12px 0 0;
}
.result-cta-note-error { color: var(--error); }

/* ============================================================
   ERRO
   ============================================================ */
.error-banner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 20px;
  background: #FBEAE7;
  color: var(--error);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--radius-sm);
}
.error-retry-btn {
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   RESPONSIVO — mobile
   ============================================================ */
@media (max-width: 640px) {
  .chat-messages, .capture-messages, .answer-options, .chat-input-area { padding-left: 14px; padding-right: 14px; }
  .message-bubble { max-width: 82%; font-size: 14.5px; }
  .chat-header, .chat-progress-bar { padding-left: 14px; padding-right: 14px; }
  .hero-inner { gap: 14px; }
  .btn-hero { padding: 15px 24px; }
  .modal-card { max-height: 85vh; }
  .result-final-card { padding: 20px; }
  #screen-result.result-screen-final { padding: 28px 14px 40px; }
}

/* Telas muito pequenas (garante zero overflow/corte) */
@media (max-width: 360px) {
  .message-bubble { max-width: 86%; font-size: 14px; }
  .selector-field, .modal-option { padding: 14px 16px; font-size: 14px; }
  .progress-counter strong { font-size: 14px; }
}
