/* Chat do site — mesmas cores do CRM (escuro com roxo da marca) */
:root {
  color-scheme: dark;
  --bg: #0f0f15;
  --surface-1: #17171f;
  --surface-2: #1f1f2a;
  --surface-3: #292937;
  --border: #2e2e3d;
  --border-strong: #41415a;
  --text: #f3f2f9;
  --text-2: #c9c8d9;
  --text-3: #a09fb6;
  --accent: #7c3aed;
  --accent-hover: #8b4ff5;
  --accent-text: #c4b5fd;
  --accent-ring: rgba(167, 139, 250, 0.55);
  --bubble-in: #2e2552;
  --bubble-out: #7c3aed;
  --whatsapp: #25d366;
  --whatsapp-dark: #128c4b;
  --danger: #f87171;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --app-height: 100dvh;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  height: var(--app-height);
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
@media (min-width: 760px) {
  body { background: radial-gradient(circle at 50% 0%, #241a44 0%, var(--bg) 60%); }
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* Topo */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-logo { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); object-fit: contain; }
.topbar-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.topbar-text strong { font-size: 16px; }
.topbar-text span { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--whatsapp); flex-shrink: 0; }
.wa-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--whatsapp); color: #06301a;
  font-weight: 700; font-size: 14px;
  padding: 8px 12px; border-radius: 999px; text-decoration: none; flex-shrink: 0;
}
.wa-pill:active { transform: scale(0.97); }

/* Mensagens */
.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.intro { text-align: center; padding: 8px 8px 16px; }
.intro img { width: 88px; height: 88px; object-fit: contain; }
.intro h1 { font-size: 21px; line-height: 1.25; margin: 8px 0 6px; }
.intro p { margin: 0 auto; color: var(--text-2); max-width: 420px; font-size: 15px; }
.trust { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.trust li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 13px; color: var(--text-2); }

.msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: pop 0.18s ease-out;
}
.msg.bot { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 5px; }
.msg.user { align-self: flex-end; background: var(--bubble-out); color: #fff; border-bottom-right-radius: 5px; }
.msg.notice { align-self: center; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2); font-size: 14.5px; text-align: center; max-width: 92%; }
.msg.error { align-self: center; background: transparent; color: var(--danger); font-size: 14px; padding: 2px 8px; }
.msg a { color: var(--accent-text); text-decoration: underline; }
.msg.user a { color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .msg { animation: none; } }

.typing { align-self: flex-start; background: var(--bubble-in); border-radius: 16px; border-bottom-left-radius: 5px; padding: 12px 14px; display: flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-text); opacity: 0.4; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.wa-card {
  align-self: stretch;
  margin: 4px 0 6px;
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.16), rgba(37, 211, 102, 0.06));
  border: 1px solid rgba(37, 211, 102, 0.45);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  animation: pop 0.18s ease-out;
}
.wa-card p { margin: 0 0 10px; color: var(--text); font-size: 15px; }
.wa-card small { display: block; margin-top: 8px; color: var(--text-3); font-size: 12.5px; }
.wa-button {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--whatsapp); color: #06301a; font-weight: 800; font-size: 16px;
  border-radius: 12px; padding: 12px 16px; text-decoration: none;
}
.wa-button:active { transform: scale(0.98); }

/* Rodapé: sugestões + campo de digitar */
.composer-wrap {
  flex-shrink: 0;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips:empty, .chips[hidden] { display: none; }
.chip {
  flex-shrink: 0;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 8px 13px; font: inherit; font-size: 14px; cursor: pointer;
}
.chip:active, .chip:hover { border-color: var(--accent); background: var(--surface-3); }

.composer { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 46px;
  max-height: 132px;
  /* 16px or more: iPhone does not zoom in when the field gets focus */
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  caret-color: var(--accent-text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 12px 16px;
  outline: none;
}
.composer textarea::placeholder { color: var(--text-3); -webkit-text-fill-color: var(--text-3); opacity: 1; }
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.composer textarea:disabled { opacity: 0.6; }
.composer button {
  width: 46px; height: 46px; flex-shrink: 0;
  border: 0; border-radius: 50%;
  background: var(--accent); color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.composer button:hover { background: var(--accent-hover); }
.composer button:disabled { background: var(--surface-3); color: var(--text-3); cursor: default; }
.fineprint { margin: 6px 4px 0; font-size: 11.5px; color: var(--text-3); text-align: center; }
.link { background: none; border: 0; padding: 0; color: var(--accent-text); font: inherit; text-decoration: underline; cursor: pointer; }
