.al-chat,
.al-chat-abrir {
  --al-fundo: #faf9f7;
  --al-superficie: #ffffff;
  --al-texto: #242527;
  --al-suave: #66686d;
  --al-borda: #e5e2dd;
  --al-marca: #c92635;
  --al-marca-hover: #a51a29;
  --al-marca-clara: #fff0f1;
  --al-contraste: #ffffff;
  --al-foco: #1664b2;
  --al-sombra: 0 12px 44px #23242724;
  --al-raio: 16px;
  --al-espaco: 24px;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}
.al-chat *,
.al-chat-abrir {
  box-sizing: border-box;
}
.al-chat input,
.al-chat button {
  font: inherit;
}
.al-chat [hidden],
.al-chat[hidden] {
  display: none !important;
}
.al-chat button:focus-visible,
.al-chat input:focus-visible,
.al-chat a:focus-visible,
.al-chat-abrir:focus-visible {
  outline: 3px solid var(--al-foco);
  outline-offset: 3px;
}

.al-chat-abrir {
  left: 16px;
  right: auto !important;
  bottom: 16px;
}
.al-chat {
  left: 16px;
  right: auto !important;
}
html body #al-chat.al-chat .al-chat-cabecalho {
  background: var(--al-texto) !important;
  color: var(--al-contraste) !important;
}
html body #al-chat.al-chat .al-chat-titulo h2,
html body #al-chat.al-chat .al-chat-titulo p {
  color: var(--al-contraste) !important;
}
html body #al-chat.al-chat .al-chat-mensagem p {
  color: var(--al-texto) !important;
}
html body #al-chat.al-chat .al-chat-form input {
  background: var(--al-superficie) !important;
  color: var(--al-texto) !important;
}
html body #al-chat.al-chat .al-chat-form button {
  background: var(--al-marca) !important;
  color: var(--al-contraste) !important;
}
html body #al-chat.al-chat .al-chat-utilidades {
  justify-content: space-between;
  gap: 16px;
}
html body #al-chat.al-chat .al-chat-utilidades button {
  background: transparent !important;
  color: var(--al-suave) !important;
  border: 0;
  box-shadow: none;
  padding: 5px 0;
  min-width: 0;
  font-size: 11px;
}
html body #al-chat.al-chat .al-chat-icone {
  background: transparent !important;
  color: var(--al-contraste) !important;
}
html body #al-chat.al-chat .al-chat-alerta {
  background: var(--al-marca-clara) !important;
  color: var(--al-marca) !important;
}
html body #al-chat.al-chat .al-chat-avaliacao button {
  background: transparent !important;
  color: var(--al-suave) !important;
  min-width: 30px;
  min-height: 30px;
  padding: 6px;
}
html body #al-chat.al-chat .al-chat-voto-positivo[aria-pressed="true"] {
  color: var(--al-voto-positivo) !important;
  background: color-mix(in srgb, var(--al-voto-positivo) 12%, transparent) !important;
}
html body #al-chat.al-chat .al-chat-voto-negativo[aria-pressed="true"] {
  color: var(--al-voto-negativo) !important;
  background: color-mix(in srgb, var(--al-voto-negativo) 12%, transparent) !important;
}
html body #al-chat.al-chat .al-chat-acao {
  color: var(--al-texto) !important;
  background: var(--al-superficie) !important;
}
html body #al-chat.al-chat .al-chat-info {
  color: var(--al-contraste) !important;
}
html body #al-chat.al-chat .al-chat-info-texto {
  color: var(--al-texto) !important;
  background: var(--al-superficie) !important;
}

.al-chat-abrir {
  width: 56px;
  height: 56px;
  min-height: 56px;
  padding: 14px;
  justify-content: center;
  border-radius: 50%;
}
.al-chat-abrir:not(.al-chat-aberto) span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
html body .al-chat-abrir.al-chat-abrir {
  background: var(--al-marca) !important;
  border: 0 !important;
  color: var(--al-contraste) !important;
}
html body #al-chat.al-chat .al-chat-form button {
  border-color: var(--al-marca) !important;
}
html body #al-chat.al-chat .al-chat-acao {
  border-color: var(--al-borda) !important;
}
html body #al-chat.al-chat .al-chat-icone {
  border-color: #66686d !important;
}

/* O atendimento fica acima do cabeçalho fixo, inclusive no celular. */
html body #al-chat.al-chat {
  z-index: 100000;
  bottom: max(16px, env(safe-area-inset-bottom));
  max-height: calc(100dvh - 32px - env(safe-area-inset-bottom));
}
html body .al-chat-abrir {
  z-index: 99999;
}
html body #al-chat .al-chat-cabecalho {
  flex: 0 0 auto;
}

/* Fechado à esquerda; janela aberta à direita, no lugar do WhatsApp. */
html body #al-chat.al-chat {
  left: auto !important;
  right: max(16px, env(safe-area-inset-right)) !important;
}
html body.chatbot-aberto .al-chat-abrir {
  display: none !important;
}
html body.chatbot-aberto .whatsapp-float {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}
.whatsapp-float {
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}
html body #al-chat.al-chat.al-chat-embutido {
  position: relative !important;
  inset: auto !important;
  bottom: auto !important;
  width: 100% !important;
  height: min(650px, 75dvh);
  max-height: none;
  box-shadow: none;
  z-index: 1;
}
.al-chat-embutido .al-chat-controles button,
.al-chat-embutido .al-chat-alerta {
  display: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .whatsapp-float {
    transition: none;
  }
}

html body .al-chat-abrir[hidden] {
  display: none !important;
}

html body .al-chat-abrir {
  bottom: max(16px, env(safe-area-inset-bottom));
}

html body #al-chat.al-chat .al-chat-minimizar {
  background: var(--al-marca) !important;
  color: var(--al-contraste) !important;
  border-color: var(--al-marca) !important;
}
html body #al-chat.al-chat .al-chat-minimizar:hover {
  filter: brightness(0.9);
}

/* Cabeçalho e utilidades não herdam tamanhos dos títulos e botões do site. */
html body #al-chat .al-chat-cabecalho {
  position: relative;
  gap: 10px;
  padding: 12px 14px;
}
html body #al-chat .al-chat-titulo {
  min-width: 0;
  flex: 1 1 auto;
}
html body #al-chat .al-chat-titulo h2 {
  font-size: 14px !important;
  line-height: 1.3;
  margin: 0 !important;
  overflow-wrap: anywhere;
}
html body #al-chat .al-chat-titulo p {
  font-size: 11px !important;
  line-height: 1.4;
  margin: 3px 0 0 !important;
}
html body #al-chat .al-chat-controles {
  flex: 0 0 auto;
  gap: 8px;
}
html body #al-chat .al-chat-info {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  margin: 0;
  background: transparent;
  font-size: 12px;
}
html body #al-chat .al-chat-info-texto[hidden] {
  display: none !important;
}
html body #al-chat .al-chat-info-texto:not([hidden]) {
  display: block;
  visibility: visible;
  opacity: 1;
}
html body #al-chat .al-chat-utilidades button {
  display: inline-flex !important;
  flex: 0 1 auto;
  align-items: center;
  gap: 5px;
  width: auto;
  min-height: 30px;
  line-height: 1.3;
}
html body #al-chat .al-chat-utilidades svg {
  flex: 0 0 13px;
  width: 13px !important;
  height: 13px !important;
  max-width: 13px;
  max-height: 13px;
}

/* Botão do robô na cor do cabeçalho do site (Meu site → Aparência): preto com o robô branco;
   o vermelho fica para o WhatsApp. Contorno discreto para aparecer também sobre o rodapé escuro. */
html body .al-chat-abrir.al-chat-abrir {
  background: var(--site-cabecalho, #0d0d0f) !important;
  color: var(--site-texto_cabecalho, #ffffff) !important;
  box-shadow: 0 4px 14px #0003, 0 0 0 1px color-mix(in srgb, var(--site-texto_cabecalho, #ffffff) 22%, transparent);
}
html body .al-chat-abrir.al-chat-abrir:not(.al-chat-aberto) {
  padding: 0 !important;
}
html body .al-chat-abrir.al-chat-abrir:not(.al-chat-aberto) svg {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}
html body .al-chat-abrir.al-chat-abrir:hover {
  background: color-mix(in srgb, var(--site-cabecalho, #0d0d0f) 82%, #fff) !important;
}

/* Aviso de problema real no cabeçalho do chat (fica oculto enquanto tudo funciona). */
html body #al-chat.al-chat .al-chat-alerta:not([hidden]) {
  display: inline-grid;
  place-items: center;
  background: #fff4d6 !important;
  color: #9a5b00 !important;
  border: 0 !important;
}
html body #al-chat.al-chat .al-chat-alerta svg {
  width: 18px;
  height: 18px;
}

/* Olhos e boca do robô no botão na mesma cor do fundo (preto), só o rosto branco. */
html body .al-chat-abrir.al-chat-abrir {
  --al-marca: var(--site-cabecalho, #0d0d0f);
}

/* O botão inicial permanece estável durante a preparação da conversa. */
/* Botões das respostas todos iguais: texto à esquerda, ícone (quando houver) antes do texto e seta à direita. */
html body #al-chat.al-chat .al-chat-acoes .al-chat-acao,
html body #al-chat.al-chat .al-chat-acoes :is(a, button).al-chat-acao:is(.public-whatsapp-button, .quote-budget-button) {
  display: flex !important;
  justify-content: flex-start !important;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 12px !important;
  text-align: left;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--al-texto) !important;
  background: var(--al-superficie) !important;
  border: 1px solid var(--al-borda) !important;
  border-radius: 10px;
  opacity: 1;
}
html body #al-chat.al-chat .al-chat-acoes .al-chat-acao::after {
  margin-left: auto;
}
html body #al-chat.al-chat .al-chat-acoes .al-chat-acao .public-action-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
html body #al-chat.al-chat .al-chat-acoes .al-chat-acao:hover {
  border-color: var(--al-marca) !important;
  color: var(--al-marca) !important;
}

/* Mantém a escrita na área visível quando o teclado cobre o viewport de layout. */
@media (max-width: 600px), (max-width: 1100px) and (pointer: coarse) {
  html body #al-chat.al-chat:not(.al-chat-embutido) {
    bottom: calc(var(--al-base-visivel, 0px) + max(16px, env(safe-area-inset-bottom)));
    height: min(570px, var(--al-altura-visivel, calc(100dvh - 32px)));
    max-height: var(--al-altura-visivel, calc(100dvh - 32px));
  }
  html body #al-chat.al-chat .al-chat-mensagens { min-height: 0; }
  html body #al-chat.al-chat .al-chat-form,
  html body #al-chat.al-chat .al-chat-utilidades { flex-shrink: 0; }
  html body #al-chat.al-chat .al-chat-form input { font-size: 16px; }
}

@media (max-width: 600px), (max-width: 1100px) and (pointer: coarse) {
  html body #al-chat.al-chat.al-chat-teclado:not(.al-chat-embutido) {
    bottom: calc(var(--al-base-visivel, 0px) + 8px);
  }
  html body #al-chat.al-chat.al-chat-teclado .al-chat-cabecalho { padding: 4px 10px; }
  html body #al-chat.al-chat.al-chat-teclado .al-chat-titulo p,
  html body #al-chat.al-chat.al-chat-teclado .al-chat-utilidades { display: none !important; }
  html body #al-chat.al-chat.al-chat-teclado .al-chat-form { padding: 8px; }
}
