/* ============================================================
   Vialixa — widget da copiloto no site BR
   Mesma linguagem visual do site (asfalto + amarelo-sinal).
   Sem dependências: um botão flutuante, um painel e o endpoint
   /br/wp-json/vialixa-br/v1/chat (que já tem compuertas, citações e limite).
   ============================================================ */

.vxw {
  --vxw-asfalto: #1B1A1A;
  --vxw-amarelo: #FFF500;
  --vxw-creme: #F8F6CD;
  --vxw-ink: #171717;
  --vxw-muted: #5A5957;
  --vxw-line: #E2E1D8;
  font-family: "Archivo", system-ui, -apple-system, sans-serif;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9998;
}

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

/* ---------- botão flutuante ---------- */
.vxw-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--vxw-asfalto);
  color: #fff;
  font: 600 15px/1 "Archivo", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
  transition: transform .18s ease, box-shadow .18s ease;
}
.vxw-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0, 0, 0, .28); }
.vxw-btn:focus-visible { outline: 3px solid var(--vxw-amarelo); outline-offset: 3px; }
.vxw-btn img {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; object-position: center 20%;
  border: 2px solid var(--vxw-amarelo);
  background: var(--vxw-creme);
}
.vxw-btn-txt { white-space: nowrap; }

.vxw[data-aberto="1"] .vxw-btn { display: none; }

/* ---------- painel ---------- */
.vxw-painel {
  display: none;
  margin: 0;
  padding: 0;
  width: 392px;
  max-width: calc(100vw - 32px);
  height: 584px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--vxw-line);
}
.vxw[data-aberto="1"] .vxw-painel { display: flex; }

.vxw-topo {
  display: flex;
  margin: 0;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--vxw-asfalto);
  color: #fff;
  flex: 0 0 auto;
}
.vxw-topo img {
  width: 38px; height: 38px; border-radius: 50%;
  object-fit: cover; object-position: center 20%;
  border: 2px solid var(--vxw-amarelo);
}
.vxw-topo b { display: block; font: 700 15px/1.2 "Archivo", sans-serif; }
.vxw-topo span { display: block; font-size: 12px; color: #C9C7C7; margin-top: 2px; }
.vxw-fechar {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.vxw-fechar:hover { background: rgba(255, 255, 255, .12); }

/* ---------- conversa ---------- */
.vxw-msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px;
  background: #FCFCF8;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.vxw-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.vxw-msg--ia {
  align-self: flex-start;
  background: #fff;
  color: var(--vxw-ink);
  border: 1px solid var(--vxw-line);
  border-bottom-left-radius: 4px;
}
.vxw-msg--user {
  align-self: flex-end;
  background: var(--vxw-asfalto);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.vxw-msg a { color: #0b57d0; text-decoration: underline; }
.vxw-msg strong { font-weight: 700; }

.vxw-fontes {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--vxw-line);
  font-size: 12px;
  color: var(--vxw-muted);
  line-height: 1.45;
}
.vxw-fontes b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.vxw-fontes a { color: var(--vxw-muted); }

.vxw-digitando { display: inline-flex; gap: 4px; align-items: center; }
.vxw-digitando i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--vxw-muted);
  animation: vxw-pulso 1.1s infinite ease-in-out;
}
.vxw-digitando i:nth-child(2) { animation-delay: .16s; }
.vxw-digitando i:nth-child(3) { animation-delay: .32s; }
@keyframes vxw-pulso { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- entrada ---------- */
.vxw-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--vxw-line);
  background: #fff;
  flex: 0 0 auto;
}
.vxw-input {
  flex: 1 1 auto;
  border: 1px solid var(--vxw-line);
  border-radius: 12px;
  padding: 11px 12px;
  font: 400 14.5px/1.3 "Archivo", system-ui, sans-serif;
  color: var(--vxw-ink);
  resize: none;
  max-height: 96px;
  min-height: 44px;
}
.vxw-input:focus { outline: 2px solid var(--vxw-asfalto); outline-offset: 0; }
.vxw-enviar {
  flex: 0 0 auto;
  width: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--vxw-amarelo);
  color: var(--vxw-asfalto);
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
}
.vxw-enviar:disabled { opacity: .45; cursor: not-allowed; }

.vxw-rodape {
  padding: 0 12px 10px;
  font-size: 11px;
  color: var(--vxw-muted);
  text-align: center;
  background: #fff;
}

@media (max-width: 520px) {
  .vxw { right: 12px; bottom: 12px; }
  .vxw-btn-txt { display: none; }
  .vxw-btn { padding: 8px; }
  .vxw-painel { width: calc(100vw - 24px); height: calc(100vh - 96px); }
}
@media (prefers-reduced-motion: reduce) {
  .vxw-btn, .vxw-digitando i { transition: none; animation: none; }
}
