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

:root {
  --blue: #1a5fd4;
  --blue-bg: #e8f0fe;
  --green: #22c55e;
  --red: #ef4444;
  --text: #0f172a;
  --text2: #475569;
  --text3: #94a3b8;
  --bg: #eef2fb;
  --border: rgba(15, 31, 69, .09);
  --shadow: 0 2px 10px rgba(15, 31, 69, .10);
  --ease: cubic-bezier(.25, .46, .45, .94);
  --av: 37px;
  /* largura avatar + gap para alinhar conteúdo bot */
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: var(--vvh, 100svh);
  height: var(--vvh, 100vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── PROGRESS ───────────────────────────────────── */
#progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), #818cf8);
  width: 5%;
  z-index: 300;
  transition: width .6s var(--ease);
  border-radius: 0 2px 2px 0;
  pointer-events: none;
}

/* ─── HEADER ─────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 14px 20px 10px;
  background: rgba(238, 242, 251, .97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.hd {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -.3px;
  text-decoration: none;
  white-space: nowrap;
}

.logo span {
  color: var(--blue);
}

.pills {
  display: flex;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  white-space: nowrap;
  min-width: 160px;
  justify-content: center;
}

.btn-reiniciar {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: color .15s, border-color .15s;
}

.btn-reiniciar:hover {
  color: var(--text2);
  border-color: var(--text3);
}

.pdot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

#benefit-text {
  transition: opacity 0.35s ease;
}

#benefit-text.fade-out {
  opacity: 0;
}

/* ─── CHAT ───────────────────────────────────────── */
#chat {
  flex: 1;
  min-height: 0;
  /* crítico para flex mobile */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 18px 20px 5px;
}

#ci {
  max-width: 560px;
  margin: 0 auto;
}

/* ─── INPUT FIXO (só para campos de texto) ────────── */
#input-area {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  overflow: visible;
  /* permite dropdown sair para cima */
  display: none;
  /* oculto por padrão */
}

#input-area.show {
  display: block;
}

#ii {
  max-width: 560px;
  margin: 0 auto;
}

/* ─── MENSAGENS ──────────────────────────────────── */
.msg {
  display: flex;
  margin-bottom: 20px;
  animation: rise .25s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* bot */
.msg.bot {
  align-items: flex-end;
  gap: 7px;
}

.av {
  width: 30px;
  height: 30px;
  background: var(--blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  align-self: flex-end;
}

.msg.bot .bub {
  position: relative;
  background: #fff;
  border-radius: 3px 16px 16px 16px;
  padding: 12px 16px;
  max-width: 84%;
  box-shadow: var(--shadow);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.65;
  color: var(--text);
  word-break: break-word;
}

/* user */
.msg.user {
  justify-content: flex-end;
}

.msg.user .bub {
  position: relative;
  background: var(--blue);
  color: #fff;
  border-radius: 16px 3px 16px 16px;
  padding: 12px 16px;
  max-width: 76%;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
}

/* ─── HORÁRIO FORA DA BOLHA ─────────────────────── */
.msg .bub .time {
  position: absolute;
  top: calc(100% + 4px);
  right: 4px;
  display: block;
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .2px;
  opacity: .8;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  color: var(--text3, #9ca3af);
}

.msg.bot .bub .time {
  color: var(--text3, #9ca3af);
}

.msg.user .bub .time {
  color: var(--text3, #9ca3af);
}

/* ─── SEPARADOR DE DATA ───────────────────────────── */
.date-sep {
  display: flex;
  justify-content: center;
  margin: 14px 0 10px;
  animation: rise .25s var(--ease) both;
}

.date-sep span {
  background: rgba(255, 255, 255, .85);
  color: var(--text2, #6b7280);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ─── TYPING ─────────────────────────────────────── */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 13px;
}

.typing i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text3);
  animation: tbounce 1.1s ease infinite;
}

.typing i:nth-child(2) {
  animation-delay: .17s;
}

.typing i:nth-child(3) {
  animation-delay: .34s;
}

@keyframes tbounce {

  0%,
  55%,
  100% {
    transform: translateY(0);
    opacity: .6;
  }

  27% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ─── OPÇÕES INLINE (no chat, não no rodapé) ──────── */
.opts {
  margin: 10px 0 6px var(--av);
  /* alinha com as bolhas do bot */
  display: flex;
  flex-direction: column;
  /* empilhadas = mais legíveis */
  gap: 9px;
  animation: rise .3s var(--ease) both;
}

.opts--row {
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
}

.opts--row .ob {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: none;
  justify-content: center;
  text-align: center;
  padding-left: 16px;
  padding-right: 16px;
}

.ob {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 2px solid var(--blue);
  color: var(--blue);
  border-radius: 14px;
  padding: 15px 22px;
  font-size: 17px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  text-align: left;
  width: fit-content;
  max-width: 400px;
  transition: background .15s, color .15s, transform .1s, box-shadow .15s;
  line-height: 1.2;
}

.ob:hover {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 16px rgba(26, 95, 212, .25);
  transform: translateY(-1px);
}

.ob:active {
  transform: scale(.97);
}

/* ─── CAMPO TEXTO (rodapé fixo) ───────────────────── */
.tw {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tw input {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  font-size: 17px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  color: var(--text);
  background: #fff;
  transition: border-color .18s, box-shadow .18s;
}

.tw input::placeholder {
  color: var(--text3);
}

.tw input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 95, 212, .10);
}

.tw input.err {
  border-color: var(--red);
  animation: shake .35s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

.sb {
  width: 44px;
  height: 44px;
  min-width: 44px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s, transform .1s;
  flex-shrink: 0;
}

.sb:hover {
  opacity: .85;
}

.sb:active {
  transform: scale(.93);
}

/* ─── AUTOCOMPLETE CIDADES ──────────────────────── */
.city-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
}

.city-drop {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 -6px 24px rgba(15, 31, 69, .13);
  max-height: 220px;
  overflow-y: auto;
  display: none;
  z-index: 200;
  overscroll-behavior: contain;
}

.city-opt {
  padding: 12px 18px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.city-opt:last-child {
  border-bottom: none;
}

.city-opt:hover,
.city-opt:active {
  background: var(--blue-bg);
  color: var(--blue);
}

.city-opt-name {
  font-weight: 600;
}

.city-opt-uf {
  font-size: 12px;
  color: var(--text3);
  margin-left: 4px;
}

/* ─── TOAST ──────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #166534;
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 18px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
  z-index: 400;
}

#toast.show {
  opacity: 1;
}

/* ─── BADGE 45% ──────────────────────────────────── */
.meds-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  border: 1px solid #86efac;
  border-radius: 14px;
  padding: 12px 16px;
  margin-top: 4px;
}

.meds-badge .pct {
  font-family: 'Playfair Display', serif;
  font-size: 34px;
  font-weight: 900;
  color: #15803d;
  line-height: 1;
}

.meds-badge .pct-lbl {
  font-size: 12.5px;
  font-weight: 600;
  color: #166534;
  line-height: 1.5;
}

/* ─── LOGOS FARMÁCIAS ────────────────────────────── */
.pharmas {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.pharmas img {
  height: 26px;
  width: auto;
  max-width: 88px;
  object-fit: contain;
}

/* ─── RESULT CARDS ───────────────────────────────── */
.rcs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rc {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 15px;
}

.rc-ico {
  font-size: 26px;
  margin-bottom: 6px;
}

.rc-ttl {
  font-weight: 700;
  font-size: 17px;
}

.rc-dsc {
  font-size: 15px;
  color: var(--text2);
  margin: 6px 0 12px;
  line-height: 1.55;
}

.rc-btn {
  display: inline-block;
  padding: 10px 22px;
  background: var(--blue);
  color: #fff !important;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity .15s;
}

.rc-btn:hover {
  opacity: .85;
}

/* ─── GUIA MÉDICO INLINE ─────────────────────────── */
.docs-wrap {
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.docs-hd {
  font-size: 15px;
  font-weight: 600;
  padding: 10px 13px 6px;
}

.spec-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 13px 8px;
}

.sch {
  padding: 4px 12px;
  border: 1px solid var(--blue);
  border-radius: 18px;
  font-size: 11px;
  font-weight: 500;
  color: var(--blue);
  background: #fff;
  cursor: pointer;
  transition: all .15s;
  font-family: 'DM Sans', sans-serif;
}

.sch.on {
  background: var(--blue);
  color: #fff;
}

.docs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 0 13px 13px;
}

.dc {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}

.dc-name {
  font-weight: 600;
  font-size: 15px;
}

.dc-spec {
  font-size: 13px;
  color: var(--blue);
  font-weight: 500;
  margin-top: 2px;
}

.dc-addr {
  font-size: 13px;
  color: var(--text2);
  margin-top: 3px;
}

.dc-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 13px;
  background: var(--blue-bg);
  border: 1px solid rgba(26, 95, 212, .25);
  border-radius: 18px;
  font-size: 13px;
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

/* ─── WHATSAPP CTA ───────────────────────────────── */
.wa-btn {
  display: block;
  background: #25D366;
  color: #fff !important;
  text-align: center;
  padding: 16px 20px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
  transition: opacity .15s;
  margin-top: 4px;
}

.wa-btn:hover {
  opacity: .88;
}

/* ─── VOICE TOGGLE ──────────────────────────────── */
.voice-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  padding: 0;
  line-height: 1;
}

.voice-toggle.on {
  background: var(--blue-bg);
  border-color: var(--blue);
}

/* ─── DESKTOP ────────────────────────────────────── */
@media (min-width: 600px) {
  body {
    background: #d8e0f3;
  }

  .opts--row .ob {
    flex-basis: 0;
    min-width: 0;
  }

  #chat {
    padding-left: max(20px, calc((100% - 560px)/2 + 20px));
    padding-right: max(20px, calc((100% - 560px)/2 + 20px));
  }

  header {
    padding-left: max(20px, calc((100% - 560px)/2 + 20px));
    padding-right: max(20px, calc((100% - 560px)/2 + 20px));
  }

  #input-area {
    padding-left: max(20px, calc((100% - 560px)/2 + 20px));
    padding-right: max(20px, calc((100% - 560px)/2 + 20px));
  }
}

/* ─── WhatsApp CTA (nó whatsapp_redirect) ──────────────────── */
.wa-cta-wrap {
  margin: 8px 0 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.btn-wa {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #25d366;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  padding: 11px 22px;
  border-radius: 28px;
  box-shadow: 0 3px 12px rgba(37, 211, 102, .35);
  transition: background .18s, transform .12s, box-shadow .18s;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-wa:hover,
.btn-wa:focus-visible {
  background: #1ebe5d;
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(37, 211, 102, .45);
  outline: none;
}

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

.wa-caption {
  font-size: 11px;
  color: var(--text2);
  margin: 0;
  padding-left: 4px;
}

/* ─── Human Handoff (nó human_handoff) ─────────────────────── */
.human-handoff-wrap {
  margin: 8px 0 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.btn-contact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--blue-bg, #e8f0fe);
  color: var(--blue, #1a5fd4);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 24px;
  transition: background .15s, transform .12s;
  border: 1.5px solid rgba(26, 95, 212, .2);
}

.btn-contact:hover,
.btn-contact:focus-visible {
  background: #d4e3fc;
  transform: translateY(-1px);
  outline: none;
}

.handoff-info {
  display: inline-block;
  background: var(--surface2, #f1f5f9);
  color: var(--text, #0f172a);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
}