/* ==========================================================================
   AMANA TAIPU • Chatbot "Amana" — estilos do widget
   BEM (.chat__*), mobile-first, tokens herdados de style.css (:root)
   ========================================================================== */

.chat {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 999;
  font-family: var(--font, "Seiva Display", "Jost", sans-serif);
  font-weight: 300;
}

/* ------------------------------------------------------------------ bolha */
.chat__bolha {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--olive, #333609);
  color: var(--sand, #e9daca);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(51, 54, 9, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chat__bolha:hover { transform: scale(1.06); }
.chat__bolha:focus-visible {
  outline: 2px solid var(--sand, #e9daca);
  outline-offset: 3px;
}
/* o icone e desenho vetorial, nao imagem: em 64px cada traco precisa ser
   grande o bastante para se ler de relance */
.chat__bolha-icone {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
}

/* --------------------------------------------------- onda que se propaga
   Dois aneis saindo da bolha, como pedra na agua. Ficam ATRAS do icone e
   nao recebem clique. Param quando a conversa esta aberta — ai a bolha ja
   cumpriu o papel de chamar. */
.chat__onda {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--sand, #e9daca);
  opacity: 0;
  pointer-events: none;
  animation: chat-onda 3.6s cubic-bezier(.22, .61, .36, 1) infinite;
}
.chat__onda--2 { animation-delay: 1.2s; }
.chat--aberto .chat__onda { animation: none; opacity: 0; }

@keyframes chat-onda {
  0%   { transform: scale(1);    opacity: .55; }
  70%  { opacity: .06; }
  100% { transform: scale(1.85); opacity: 0; }
}

/* ------------------------------------------------- botoes de acao no balao
   A Amana oferecia "posso te mostrar o masterplan" e nao havia como ir ate
   la — a conversa terminava num beco. Estes botoes levam de fato ao lugar
   citado, e sao montados so a partir do catalogo fechado de acoes. */
.chat__acoes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chat__acao {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--olive, #333609);
  border-radius: 999px;
  background: var(--olive, #333609);
  color: var(--cream, #f8eee4);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}
.chat__acao:hover { background: transparent; color: var(--olive, #333609); }
.chat__acao:focus-visible { outline: 2px solid var(--olive, #333609); outline-offset: 2px; }

/* ------------------------------------------------------- convite inicial */
.chat__convite {
  position: absolute;
  right: 0;
  bottom: 76px;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  /* o container do widget tem a largura da bolha (64px): sem `width` explicito
     o balao encolhe para caber nele e o texto quebra letra a letra */
  width: max-content;
  max-width: min(74vw, 250px);
  padding: 12px 10px 12px 16px;
  border-radius: 18px 18px 18px 4px;
  background: var(--cream, #f8eee4);
  color: var(--olive, #333609);
  box-shadow: 0 10px 28px rgba(51, 54, 9, .22);
  opacity: 0;
  transform: translateY(6px) scale(.96);
  transform-origin: 100% 100%;
  transition: opacity .45s ease, transform .45s cubic-bezier(.22, .61, .36, 1);
  pointer-events: none;
}
.chat__convite.is-visivel { opacity: 1; transform: none; pointer-events: auto; }
.chat__convite-texto {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 400;
  cursor: pointer;
}
.chat__convite-fechar {
  flex: none;
  width: 22px;
  height: 22px;
  margin: -2px -2px 0 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(51, 54, 9, .55);
  font: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.chat__convite-fechar:hover { color: var(--olive, #333609); background: rgba(51, 54, 9, .08); }
.chat__convite-fechar:focus-visible { outline: 2px solid var(--olive, #333609); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .chat__onda { animation: none; opacity: 0; }
  .chat__convite { transition: none; }
}
/* com o painel aberto a bolha vira "fechar" e recua visualmente */
.chat--aberto .chat__bolha { transform: scale(.92); opacity: .9; }
.chat--aberto .chat__bolha:hover { transform: scale(.96); opacity: 1; }

/* ------------------------------------------------------------------ painel */
.chat__painel {
  position: fixed;
  right: 12px;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 999;
  display: flex;
  flex-direction: column;
  width: calc(100% - 24px);
  max-width: 380px;
  max-height: calc(100vh - 108px - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 108px - env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  border-radius: 18px;
  background: var(--cream, #f8eee4);
  box-shadow: 0 14px 44px rgba(51, 54, 9, 0.28);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.chat__painel--aberto {
  opacity: 1;
  transform: translateY(0) scale(1);
}
/* `display: flex` acima vence o `[hidden] { display: none }` do user-agent:
   sem esta regra o painel fechado continua ocupando ~380x500px no canto
   inferior direito e ENGOLE os cliques do que estiver embaixo (os ícones
   sociais do rodapé e o botão "Ampliar mapa" ficaram inertes por isso). */
.chat__painel[hidden] { display: none; }
@media (min-width: 480px) {
  .chat__painel { right: 16px; width: 380px; }
}

/* ------------------------------------------------------------------ header */
.chat__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  background: var(--olive, #333609);
  color: #e9daca;
  flex: none;
}
.chat__header-avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--sand, #e9daca);
  padding: 4px;
  object-fit: contain;
}
.chat__header-info { min-width: 0; }
.chat__header-nome {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.chat__header-sub {
  margin: 0;
  font-size: 12px;
  opacity: 0.75;
}
.chat__header-acoes {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat__encerrar {
  padding: 5px 10px;
  border: 1px solid rgba(233, 218, 202, 0.5);
  border-radius: 999px;
  background: none;
  color: #e9daca;
  font-size: 11px;
  letter-spacing: 0.03em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease;
}
.chat__encerrar:hover { background: var(--sand, #e9daca); color: var(--olive, #333609); }
.chat__fechar {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #e9daca;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.chat__fechar:hover { opacity: 0.6; }
.chat__encerrar:focus-visible,
.chat__fechar:focus-visible {
  outline: 2px solid var(--sand, #e9daca);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------- LGPD */
.chat__lgpd {
  flex: none;
  padding: 12px 16px;
  background: var(--sage, #c1c6b1);
  color: var(--olive, #333609);
}
.chat__lgpd-texto {
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.5;
}
.chat__lgpd-link {
  text-decoration: underline;
  font-weight: 500;
}
.chat__lgpd-ok {
  padding: 7px 20px;
  border: 1px solid var(--olive, #333609);
  border-radius: 999px;
  background: var(--olive, #333609);
  color: var(--cream, #f8eee4);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.chat__lgpd-ok:hover { opacity: 0.85; }

/* --------------------------------------------------------------- mensagens */
.chat__mensagens {
  flex: 1 1 auto;
  /* `min-height: 180px` travava o encolhimento: em tela baixa (ou com o
     teclado aberto) o conteudo passava da altura do painel e, como ele tem
     `overflow: hidden`, o CAMPO DE DIGITAR ficava cortado para fora. Item de
     flex so encolhe abaixo do conteudo com min-height: 0. */
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overscroll-behavior: contain;
}
.chat__msg {
  margin: 0;
  max-width: 85%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 16px;
  overflow-wrap: break-word;
}
/* o texto vive num <p> interno: zera a margem padrão e preserva quebras */
.chat__msg-texto {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.chat__msg--amana {
  align-self: flex-start;
  background: #ffffff;
  color: var(--olive, #333609);
  border-bottom-left-radius: 4px;
}
.chat__msg--visitante {
  align-self: flex-end;
  background: var(--olive, #333609);
  color: #e9daca;
  border-bottom-right-radius: 4px;
}

/* ------------------------------------------------------ indicador digitando */
.chat__digitando {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 12px 14px;
  background: #ffffff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.chat__digitando-ponto {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage, #c1c6b1);
  animation: chat-pulso 1.1s ease-in-out infinite;
}
.chat__digitando-ponto:nth-child(2) { animation-delay: 0.18s; }
.chat__digitando-ponto:nth-child(3) { animation-delay: 0.36s; }
@keyframes chat-pulso {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-3px); }
}

/* ------------------------------------------------------------------- chips */
.chat__chips {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px 10px;
}
.chat__chips[hidden] { display: none; }
.chat__chip {
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--sage, #c1c6b1);
  color: var(--olive, #333609);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.chat__chip:hover:not(:disabled) { background: var(--olive, #333609); color: var(--cream, #f8eee4); }
.chat__chip:disabled { opacity: 0.5; cursor: default; }

/* ------------------------------------------------------------------- input */
.chat__form {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px) * 0.25);
  border-top: 1px solid rgba(51, 54, 9, 0.12);
  background: var(--cream, #f8eee4);
}
.chat__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 16px;
  border: 1px solid rgba(51, 54, 9, 0.25);
  border-radius: 999px;
  background: #ffffff;
  color: var(--olive, #333609);
  font-size: 14px;
}
.chat__input:focus {
  outline: none;
  border-color: var(--olive, #333609);
}
.chat__input:disabled { opacity: 0.55; }
.chat__input::placeholder { color: rgba(51, 54, 9, 0.45); }
/* o botao leva o texto "Enviar": pill, nao circulo — como circulo de 42px o
   rotulo vazava para fora do painel */
.chat__enviar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--olive, #333609);
  color: var(--sand, #e9daca);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.chat__enviar:hover:not(:disabled) { opacity: 0.85; }
.chat__enviar:disabled { opacity: 0.45; cursor: default; }
.chat__enviar:focus-visible,
.chat__chip:focus-visible,
.chat__lgpd-ok:focus-visible {
  outline: 2px solid var(--olive, #333609);
  outline-offset: 2px;
}

/* --------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  .chat__bolha,
  .chat__painel,
  .chat__encerrar,
  .chat__chip,
  .chat__fechar,
  .chat__enviar,
  .chat__lgpd-ok { transition: none; }
  .chat__bolha:hover { transform: none; }
  .chat__painel {
    opacity: 1;
    transform: none;
  }
  .chat__digitando-ponto { animation: none; opacity: 0.7; }
}
