@font-face {
  font-family: TOTVS;
  src: url(https://midias-totvs.totvs.com/fonts/totvs/TOTVS-Light.woff2) format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: TOTVS;
  src: url(https://midias-totvs.totvs.com/fonts/totvs/TOTVS-Regular.woff2) format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: TOTVS;
  src: url(https://midias-totvs.totvs.com/fonts/totvs/TOTVS-SemiBold.woff2) format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: TOTVS;
  src: url(https://midias-totvs.totvs.com/fonts/totvs/TOTVS-Bold.woff2) format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --totvs-primary: #00dbff;
  --totvs-primary-dark: #00a3be;
  --totvs-secondary: #00c9eb;
  --totvs-navy: #002233;
  --totvs-navy-soft: #0a3349;
  --totvs-purple: #a44dff;
  --totvs-text: #e7edf0;
  --totvs-text-soft: #9fb3ba;
  --totvs-bg: #0b1b24;
  --totvs-surface: #112733;
  --totvs-bot-bubble: #14303d;
  --totvs-user-bubble: linear-gradient(135deg, #00a3be, #00748a);
  --totvs-border: #1f3b48;
  --totvs-danger: #dc3545;
  --totvs-success: #1fae57;
  --chip-bg: #14303d;
  --chip-border: #234a59;
  --chip-active-bg: var(--totvs-primary);
  --chip-active-text: #002233;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: TOTVS, -apple-system, system-ui, sans-serif;
  color: var(--totvs-text);
  background: var(--totvs-bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: var(--totvs-bg);
  position: relative;
}

/* ---------- Topbar ---------- */
.topbar {
  flex: 0 0 auto;
  background: linear-gradient(120deg, var(--totvs-navy) 0%, var(--totvs-navy-soft) 65%, #00566a 100%);
  color: #fff;
  padding: 14px 18px 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.logo-img {
  height: 52px;
  width: auto;
  display: block;
  grid-row: 1;
}
.topbar-meta {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: right;
}
.topbar-meta strong { font-size: 13px; font-weight: 600; }
.topbar-meta span { font-size: 11px; font-weight: 300; color: var(--totvs-primary); }
.progress {
  grid-column: 1 / -1;
  height: 4px;
  background: rgba(255,255,255,.15);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-fill {
  height: 100%;
  width: 4%;
  background: var(--totvs-primary);
  border-radius: 4px;
  transition: width .45s ease;
}

/* ---------- Chat thread ---------- */
.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 84%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: rise .32s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; align-items: flex-end; }

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: var(--shadow-soft);
}
.msg.bot .bubble {
  background: var(--totvs-bot-bubble);
  color: var(--totvs-text);
  border-bottom-left-radius: 6px;
}
.msg.user .bubble {
  background: var(--totvs-user-bubble);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.bot .bubble strong { color: var(--totvs-primary); }
.msg.bot .bubble a { color: var(--totvs-primary-dark); font-weight: 600; }

.social-links {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1.5px solid var(--chip-border);
  color: var(--totvs-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: border-color .15s ease, color .15s ease;
}
.social-link svg { flex: none; color: var(--totvs-primary); }
.social-link:hover { border-color: var(--totvs-primary-dark); color: var(--totvs-primary); }

.bubble.legal {
  font-size: 12.5px;
  color: var(--totvs-text-soft);
  background: var(--totvs-surface);
  border: 1px solid var(--totvs-border);
}
.bubble.legal a { color: var(--totvs-primary-dark); font-weight: 600; }

.bubble-time {
  font-size: 10.5px;
  color: var(--totvs-text-soft);
  padding: 0 4px;
}

/* typing indicator */
.msg.typing .bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--totvs-text-soft);
  opacity: .5;
  animation: bounce 1.1s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: .15s; }
.dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Composer ---------- */
.composer {
  flex: 0 0 auto;
  max-height: 45vh;
  overflow-y: auto;
  background: var(--totvs-surface);
  border-top: 1px solid var(--totvs-border);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.composer input[type="text"],
.composer input[type="email"],
.composer input[type="tel"],
.composer textarea {
  flex: 1;
  padding: 13px 16px;
  border: 1px solid var(--totvs-border);
  border-radius: 24px;
  font-size: 16px;
  font-family: inherit;
  color: var(--totvs-text);
  background: var(--totvs-bg);
  min-height: 48px;
}
.composer textarea { border-radius: var(--radius-sm); resize: none; min-height: 64px; }
.composer input:focus, .composer textarea:focus {
  outline: none;
  border-color: var(--totvs-primary);
  box-shadow: 0 0 0 3px rgba(0,219,255,.25);
}

.send-btn {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--totvs-navy);
  color: var(--totvs-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, background .15s ease;
}
.send-btn:hover { background: var(--totvs-navy-soft); }
.send-btn:active { transform: scale(.92); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }

.skip-link {
  align-self: center;
  background: none;
  border: none;
  color: var(--totvs-text-soft);
  font-size: 13px;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 2px;
}

/* chips: single/multi choice + suggestions */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  border: 1.5px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--totvs-text);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .1s ease;
  min-height: 44px;
}
/* lista com muitas opções (soluções do evento): a lista rola dentro de si, não o
   composer inteiro, pra o botão Avançar nunca sair da tela. O corte na borda de baixo
   e o aviso deixam explícito que existe mais opção abaixo */
.composer-lista-longa { max-height: 64vh; }
.chip-row-compacta { gap: 6px; }
.chip-row-compacta .chip {
  padding: 9px 14px;
  font-size: 13.5px;
  min-height: 40px;
}
.chip-row-rolavel {
  max-height: 38vh;
  overflow-y: auto;
  padding-bottom: 6px;
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}
.chip-row-rolavel.no-fim {
  mask-image: none;
  -webkit-mask-image: none;
}
.scroll-hint {
  align-self: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--totvs-primary);
  letter-spacing: .01em;
  margin-top: -2px;
}

.chip:hover { border-color: var(--totvs-primary-dark); }
.chip:active { transform: scale(.96); }
.chip.selected {
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
  border-color: var(--chip-active-bg);
}
.chip.suggestion {
  font-weight: 400;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}
.chip.suggestion .sugg-cnpj { font-size: 11.5px; color: var(--totvs-text-soft); font-weight: 400; }
.chip.manual {
  font-weight: 400;
  color: var(--totvs-text-soft);
  border-style: dashed;
}

.chip.manual.chip-attention {
  animation: attention-pulse 0.5s ease-in-out 3;
  border-style: solid;
  border-width: 2px;
  font-weight: 700;
}
@keyframes attention-pulse {
  0%, 100% {
    border-color: #ff9500;
    background: #ff9500;
    color: #1a1300;
    box-shadow: 0 0 0 0 rgba(255, 149, 0, 0.6);
    transform: scale(1) translateX(0);
  }
  15% { transform: scale(1.07) translateX(-4px); }
  30% { transform: scale(1.07) translateX(4px); }
  50% {
    border-color: #ff9500;
    background: #ff9500;
    color: #1a1300;
    box-shadow: 0 0 0 8px rgba(255, 149, 0, 0.25);
    transform: scale(1.07) translateX(0);
  }
  70% { transform: scale(1.02) translateX(-2px); }
  85% { transform: scale(1.02) translateX(2px); }
}

.chip-green {
  background: rgba(31, 174, 87, .12);
  border-color: rgba(31, 174, 87, .5);
  color: #15803d;
}
.chip-green.selected { background: var(--totvs-success); border-color: var(--totvs-success); color: #fff; }
.chip-yellow {
  background: rgba(255, 193, 7, .14);
  border-color: rgba(217, 164, 6, .55);
  color: #946200;
}
.chip-yellow.selected { background: #ffc107; border-color: #ffc107; color: #1a1300; }
.chip-red {
  background: rgba(220, 53, 69, .1);
  border-color: rgba(220, 53, 69, .5);
  color: var(--totvs-danger);
}
.chip-red.selected { background: var(--totvs-danger); border-color: var(--totvs-danger); color: #fff; }

.hint {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--totvs-text-soft);
  margin-top: 4px;
}

.searching {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--totvs-text-soft);
  padding: 8px 4px;
}
.searching .dot { background: var(--totvs-primary-dark); }

.outro-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}
.outro-inline input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--totvs-border);
  border-radius: 999px;
  font-size: 14px;
  font-family: inherit;
  background: var(--totvs-bg);
  color: var(--totvs-text);
}

.star-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  padding: 4px 0;
}
.star-unit {
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 2px;
  font-family: inherit;
  transition: transform .1s ease;
}
.star-unit:hover { transform: scale(1.12); }
.star-unit:active { transform: scale(.94); }
.star-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--totvs-text-soft);
}
.star-icon {
  font-size: 24px;
  line-height: 1;
  color: var(--chip-border);
  transition: color .12s ease;
}
.star-unit .star-icon.star-filled { color: #ffc107; }
.star-unit .star-number.star-filled { color: var(--totvs-text); }

.confirm-row { display: flex; gap: 10px; }
.confirm-row .chip { flex: 1; text-align: center; }

.primary-btn {
  border: none;
  background: var(--totvs-primary);
  color: var(--totvs-navy);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  border-radius: 24px;
  padding: 13px 20px;
  cursor: pointer;
  transition: background .15s ease;
  min-height: 48px;
}
.primary-btn:hover { background: var(--totvs-primary-dark); color: #fff; }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; }

.field-error {
  font-size: 12.5px;
  color: var(--totvs-danger);
  padding: 0 4px;
}

.success-icon {
  font-size: 34px;
  text-align: center;
  margin-bottom: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .msg, .dot, .chip, .send-btn { animation: none !important; transition: none !important; }
}

@media (min-width: 720px) {
  .app {
    margin: 24px auto;
    height: calc(100dvh - 48px);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,34,51,.18);
  }
}
