/* Painel do ASSISTENTE VIRTUAL — visual de conversa do WhatsApp.
   O cliente escreve a dúvida aqui e SÓ ENTÃO é levado ao WhatsApp do bot (8331),
   já com a mensagem pronta. Markup injetado por assets/js/bot.painel.js.

   Camadas (ver "Camadas" no style.css): 1030 = flutuantes · 1040 = backdrop do
   Bootstrap · 1050+ = modal. O painel fica em 1045: acima dos flutuantes e do
   backdrop, abaixo do modal de analista, para os dois nunca disputarem a tela. */

.bot-painel {
  position: fixed;
  right: 18px;
  /* --painel-base: distância do pé da tela. Vira valor maior quando o banner de
     cookies está na tela e vira a altura do teclado virtual quando ele sobe
     (o JS mede pela visualViewport). */
  bottom: var(--painel-base, 92px);
  width: 370px;
  max-width: calc(100vw - 28px);
  height: min(560px, var(--painel-max-h, calc(100vh - 130px)));
  z-index: 1045;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  background: #ECE5DD;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  margin: 0;
  padding: 0;                 /* blindagem: regras globais do tema não entram aqui */
  opacity: 0;
  transform: translateY(14px) scale(.98);
  transition: opacity .22s ease, transform .22s ease, bottom .18s ease;
}

.bot-painel.aberto {
  display: flex;
  opacity: 1;
  transform: none;
}

/* O banner de cookies (z 99999) é uma barra no pé da tela e tapava o campo de
   escrever justamente na PRIMEIRA visita — quando o lead é novo. Enquanto ele
   estiver na tela, o painel sobe a altura real dele (medida no main.js). */
body.cookies-visivel .bot-painel {
  --painel-base: calc(var(--cookies-h, 120px) + 24px);
  --painel-max-h: calc(100vh - 150px - var(--cookies-h, 120px));
}

/* Com o painel aberto no celular ele cobre o botão flutuante — e o pixel do botão
   passava a ser o "enviar". Some com os flutuantes enquanto a conversa está aberta. */
body.bot-painel-aberto .wpp-float,
body.bot-painel-aberto .back-to-top {
  opacity: 0;
  pointer-events: none;
}

/* ---------- cabeçalho ---------- */
.bot-painel__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  background: #075E54;
  color: #fff;
}

.bot-painel__avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bot-painel__avatar img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

.bot-painel__quem {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

.bot-painel__nome {
  font-family: Poppins, sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-painel__status {
  font-size: 11.5px;
  color: #d7f0e7;             /* contraste AA sobre o verde #075E54 */
  display: flex;
  align-items: center;
  gap: 5px;
}

.bot-painel__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #25D366;
  flex-shrink: 0;
}

.bot-painel__fechar {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  width: 44px;                /* alvo de toque de 44px (era 27x30) */
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  border-radius: 8px;
  opacity: .9;
}

.bot-painel__fechar:hover {
  opacity: 1;
  background: rgba(255, 255, 255, .14);
}

.bot-painel__fechar:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, .14);
  outline: 3px solid #fff;    /* foco de teclado VISÍVEL (antes era outline:none) */
  outline-offset: -3px;
}

/* ---------- corpo da conversa ---------- */
.bot-painel__corpo {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;  /* rolar aqui não arrasta a página atrás */
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 10px;
  /* mesma trama clarinha do fundo de conversa do WhatsApp, em SVG inline */
  background-color: #ECE5DD;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='42'%3E%3Cg fill='%23d9d2c9' fill-opacity='.45'%3E%3Ccircle cx='7' cy='7' r='1.6'/%3E%3Ccircle cx='28' cy='19' r='1.6'/%3E%3Ccircle cx='15' cy='33' r='1.6'/%3E%3C/g%3E%3C/svg%3E");
}

.bot-painel__balao {
  position: relative;
  max-width: 86%;
  margin-bottom: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #fff;
  color: #202c33;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .12);
}

.bot-painel__balao::after {
  content: "";
  position: absolute;
  top: 0;
  left: -7px;
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-top-color: #fff;
  border-right: 0;
  border-left: 0;
  border-left: 7px solid transparent;
}

.bot-painel__balao strong { color: #075E54; }

.bot-painel__hora {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  color: #5c6b73;             /* contraste AA sobre o balão branco */
  text-align: right;
}

/* sugestões: preenchem o campo, não enviam sozinhas */
.bot-painel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 2px 0 6px;
}

.bot-painel__chip {
  background: #fff;
  border: 1px solid #cfd8d5;
  color: #075E54;
  font-size: 12.5px;
  font-weight: 600;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.bot-painel__chip:hover {
  background: #e7f5ef;
  border-color: #25D366;
}

.bot-painel__chip:focus-visible {
  background: #e7f5ef;
  outline: 3px solid #075E54;
  outline-offset: 2px;
}

/* ---------- rodapé: escrever e enviar ---------- */
.bot-painel__pe {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 10px;
  background: #F0F2F5;
}

.bot-painel__campo {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 20px;
  padding: 11px 14px;
  font-size: 16px;            /* 16px é obrigatório: abaixo disso o iOS dá zoom ao focar */
  line-height: 1.35;
  font-family: inherit;
  color: #202c33;
  background: #fff;
  resize: none;
  max-height: 96px;
  overflow-y: auto;
}

.bot-painel__campo:focus {
  outline: 2px solid #25D366;
  outline-offset: -2px;
}

.bot-painel__enviar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #128C7E;        /* verde mais escuro: o ícone branco fica legível (AA) */
  color: #fff;
  font-size: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}

.bot-painel__enviar:hover:not(:disabled) { background: #0e7367; }
.bot-painel__enviar:focus-visible { outline: 3px solid #0D2C64; outline-offset: 2px; }

.bot-painel__enviar:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.bot-painel__aviso {
  flex-shrink: 0;
  margin: 0;                  /* <p> vem com margem do navegador e abria faixa no rodapé */
  padding: 0 12px 9px;
  background: #F0F2F5;
  font-size: 10.5px;
  color: #4a5860;             /* contraste AA sobre #F0F2F5 */
  text-align: center;
  line-height: 1.4;
}

/* ---------- celular ---------- */
@media (max-width: 575.98px) {
  .bot-painel {
    right: 10px;
    left: 10px;
    bottom: var(--painel-base, 10px);
    width: auto;
    max-width: none;
    height: min(78vh, var(--painel-max-h, calc(100vh - 20px)));
    border-radius: 12px;
    /* respeita a barra de gestos do iPhone */
    margin-bottom: env(safe-area-inset-bottom, 0px);
  }

  body.cookies-visivel .bot-painel {
    --painel-base: calc(var(--cookies-h, 120px) + 14px);
    --painel-max-h: calc(100vh - 40px - var(--cookies-h, 120px));
  }
}

/* Tela baixa (celular deitado, notebook pequeno): sem isto o painel passava por
   cima do header e a conversa ficava espremida. */
@media (max-height: 620px) {
  .bot-painel {
    height: min(var(--painel-max-h, calc(100vh - 96px)), calc(100vh - 96px));
    bottom: var(--painel-base, 12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bot-painel { transition: none; }
}
