/* ==========================================================================
   Funil de conversa da Mya (estilo Typebot) — mobile first
   Coluna de até 480px, 16px de respiro lateral, funciona a partir de 360px.
   ========================================================================== */

:root {
  --sai-dark: #0E2A3A;        /* botões e negrito */
  --sai-dark-hover: #173F55;
  --sai-cyan: #1FB6C9;        /* destaques (nunca como cor de texto sobre branco) */
  --lead: #0B6E7F;            /* balão do lead: branco sobre ele = 5,9:1 (WCAG AA) */
  --text: #1F2933;
  --muted: #5A6C75;           /* 5,5:1 sobre branco */
  --bg: #FFFFFF;
  --line: #E3E8EB;
  --soft: #F1F4F6;
  --error: #B42318;
  --google-star: #FBBC04;

  --avatar: 36px;
  --gap: 10px;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
p { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Foco: teal sobre fundo branco (ciano sobre branco teria só 2,4:1); ciano dentro da agenda escura */
:focus-visible { outline: 3px solid var(--lead); outline-offset: 2px; }
.cal :focus-visible { outline-color: var(--sai-cyan); }

/* ── Coluna ─────────────────────────────────────────────────────────────── */
.app {
  flex: 1 0 auto;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Mensagens do bot: texto puro + avatar ao lado da última do grupo ───── */
.bot-group {
  display: flex;
  align-items: flex-end;
  gap: var(--gap);
}

.avatar {
  flex: 0 0 var(--avatar);
  width: var(--avatar);
  height: var(--avatar);
  border-radius: 50%;
  object-fit: cover;
  background: var(--soft);
}

.msgs {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg { overflow-wrap: anywhere; }
.msg strong { font-weight: 700; color: var(--sai-dark); }

/* "digitando..." */
.typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 13px 15px;
  border-radius: 18px;
  background: var(--soft);
}
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8A9AA3;
  animation: typing 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.fade-in { animation: fadeIn .28s ease-out both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ── Resposta do lead ────────────────────────────────────────────────────── */
.lead-row {
  display: flex;
  justify-content: flex-end;
  padding-left: calc(var(--avatar) + var(--gap));
}
.lead-bubble {
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 16px;
  background: var(--lead);
  color: #fff;
  overflow-wrap: anywhere;
}

/* ── Entradas (alinhadas à coluna de texto do bot) ───────────────────────── */
.inline { margin-left: calc(var(--avatar) + var(--gap)); }

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--sai-dark);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s ease, transform .1s ease;
}
.btn-choice:hover { background: var(--sai-dark-hover); }
.btn-choice:active { transform: scale(.985); }

.btn-link { letter-spacing: .01em; }

/* Campo de texto: cartão branco com sombra + botão "Enviar" ao lado */
.input-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.input-card {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 2px 14px rgba(14, 42, 58, .14);
  transition: border-color .15s ease;
}
.input-card:focus-within { border-color: var(--lead); }

.input-card input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px; /* ≥16px: o iPhone não dá zoom ao focar */
}
.input-card input::placeholder { color: var(--muted); opacity: 1; }

.phone-prefix {
  flex: 0 0 auto;
  padding-right: 8px;
  border-right: 1px solid var(--line);
  font-weight: 600;
  white-space: nowrap;
}

.btn-send {
  flex: 0 0 auto;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--sai-dark);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-send:hover { background: var(--sai-dark-hover); }

.input-error {
  flex: 1 0 100%;
  margin: 2px 2px 0;
  color: var(--error);
  font-size: 14.5px;
  font-weight: 600;
}
.input-error:empty { display: none; }

/* Honeypot: fora da tela, invisível para pessoas */
.hp {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Em telas estreitas o campo usa a largura toda (senão o número não cabe) */
@media (max-width: 419px) {
  .input-row.inline { margin-left: 0; }
}

/* ── Cartão da avaliação do Google ───────────────────────────────────────── */
.review {
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(14, 42, 58, .06);
}
.review-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.review-avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.review-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7B1FA2; /* roxo das iniciais do Google; branco sobre ele = 8,2:1 */
  color: #fff;
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
}
.review-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.review-name {
  font-size: 16px;
  font-weight: 700;
}
.review-source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}
.review-source svg { flex: 0 0 14px; width: 14px; height: 14px; }
.review-stars {
  display: flex;
  gap: 2px;
  margin: 10px 0 6px;
}
.review-stars svg { width: 18px; height: 18px; }
.review-text {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

/* ── Agenda (estilo Cal.com) ─────────────────────────────────────────────── */
.cal {
  padding: 18px 16px 16px;
  border-radius: 16px;
  background: var(--sai-dark);
  color: #fff;
  box-shadow: 0 10px 30px rgba(14, 42, 58, .22);
}

.cal-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.cal-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  color: rgba(255, 255, 255, .82);
  font-size: 14px;
}
.cal-meta li { display: flex; align-items: center; gap: 8px; }
.cal-meta svg { flex: 0 0 16px; width: 16px; height: 16px; color: var(--sai-cyan); }

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 6px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}
.cal-month { font-size: 16px; font-weight: 700; }
.cal-month span { color: rgba(255, 255, 255, .6); font-weight: 400; }
.cal-arrows { display: flex; gap: 4px; }
.cal-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.cal-arrow:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }
.cal-arrow:disabled { opacity: .25; cursor: default; }
.cal-arrow svg { width: 20px; height: 20px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.cal-wd {
  padding: 6px 0;
  color: rgba(255, 255, 255, .55);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-align: center;
}
.cal-day {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, .3);
  font-size: 15px;
}
.cal-day.is-avail {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.cal-day.is-avail:hover { background: rgba(255, 255, 255, .18); }
.cal-day.is-sel,
.cal-day.is-sel:hover { background: var(--sai-cyan); color: var(--sai-dark); }
.cal-day.is-today::after {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: currentColor;
}

.cal-day-label {
  margin: 18px 0 10px;
  font-size: 15px;
  font-weight: 700;
}

.cal-times {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
@media (min-width: 440px) {
  .cal-times { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.cal-time {
  min-height: 44px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.cal-time:hover { border-color: var(--sai-cyan); }
.cal-time.is-sel { border-color: var(--sai-cyan); background: var(--sai-cyan); color: var(--sai-dark); }

.cal-confirm,
.cal-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--sai-cyan);
  color: var(--sai-dark);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.cal-confirm:disabled { cursor: default; opacity: .85; }

.cal-notice {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(31, 182, 201, .16);
  font-size: 14.5px;
  font-weight: 600;
}

.cal-text {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, .9);
  font-size: 15.5px;
}

.cal-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, .85);
  font-size: 15px;
}

.spinner {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Resumo depois de agendar */
.cal-done { display: flex; flex-direction: column; gap: 4px; }
.cal-done-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sai-cyan);
  font-size: 15px;
  font-weight: 700;
}
.cal-done-title svg { width: 20px; height: 20px; }
.cal-done-when { font-size: 18px; font-weight: 700; }
.cal-done-meta { color: rgba(255, 255, 255, .75); font-size: 14px; }

/* ── Rodapé ──────────────────────────────────────────────────────────────── */
.foot {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px calc(18px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
.foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

.noscript { color: var(--text); }
.noscript a { color: var(--lead); }

/* ── Movimento reduzido ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: none; }
  .typing span { animation: none; opacity: .7; }
  .btn-choice, .input-card { transition: none; }
  .spinner { animation-duration: 1.6s; }
}
