/* ==========================================================================
   Janela de conversa do assistente — canal «Site» do chatbot ACMM
   Desenhada como as conversas do WhatsApp e do Messenger, com a paleta do
   site. Todas as classes começam por `acw-` para não tocar no resto da página.
   ========================================================================== */

.acw {
  --acw-verde: var(--green, #2e7d18);
  --acw-verde-escuro: #225f11;
  --acw-verde-claro: #f1f8ec;
  --acw-eu: #dcf3cf;
  --acw-tinta: var(--ink, #14221a);
  --acw-suave: var(--muted, #66706a);
  --acw-linha: var(--line, #e8e2d6);
  --acw-fundo: #efe9dd;
  --acw-sombra: 0 1px .5px rgba(11, 20, 26, .13);
  --acw-ease: var(--ease, cubic-bezier(.2, .7, .2, 1));
  font-family: var(--font-body, system-ui, sans-serif);
  color: var(--acw-tinta);
}
.acw *, .acw *::before, .acw *::after { box-sizing: border-box; }

/* O «voltar ao topo» sobe para dar lugar ao botão da conversa. */
body.acw-on .to-top { bottom: 92px; }

/* ------------------------------------------------------------------ botão */
.acw-lancador {
  position: fixed; right: 20px; bottom: 20px; z-index: 55;
  width: 60px; height: 60px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--acw-verde); color: #fff;
  box-shadow: 0 12px 30px -8px rgba(20, 34, 26, .55);
  transition: transform .2s var(--acw-ease), background-color .2s;
}
.acw-lancador:hover { transform: translateY(-2px) scale(1.03); background: var(--acw-verde-escuro); }
.acw-lancador:focus-visible { outline: 3px solid var(--yellow, #f6c90e); outline-offset: 3px; }
.acw-lancador i { grid-area: 1 / 1; font-size: 1.55rem; transition: transform .25s var(--acw-ease), opacity .2s; }
.acw-lancador .acw-ico-fechar { opacity: 0; transform: rotate(-90deg); }
.acw.is-aberta .acw-lancador .acw-ico-abrir { opacity: 0; transform: rotate(90deg); }
.acw.is-aberta .acw-lancador .acw-ico-fechar { opacity: 1; transform: none; }

.acw-cracha {
  position: absolute; top: -3px; right: -3px;
  min-width: 21px; height: 21px; padding: 0 6px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--red, #bd090c); color: #fff; border: 2px solid #fff;
  font-size: .72rem; font-weight: 800; line-height: 1;
}
.acw-cracha[hidden] { display: none; }

/* ----------------------------------------------------------------- convite */
.acw-convite {
  position: fixed; right: 20px; bottom: 92px; z-index: 55;
  width: min(300px, calc(100vw - 40px));
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px 36px 14px 14px; border-radius: 16px 16px 4px 16px;
  background: #fff; color: var(--acw-tinta); cursor: pointer;
  box-shadow: 0 18px 40px -14px rgba(15, 26, 19, .45), 0 0 0 1px rgba(20, 34, 26, .06);
  animation: acw-entrar .35s var(--acw-ease);
}
.acw-convite[hidden] { display: none; }
.acw-convite img { width: 34px; height: 34px; flex: none; object-fit: contain; border-radius: 50%; background: var(--acw-verde-claro); padding: 4px; }
.acw-convite p { margin: 0; font-size: .9rem; line-height: 1.4; font-weight: 600; }
.acw-convite__fechar {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px;
  border: 0; border-radius: 50%; background: transparent; color: var(--acw-suave); cursor: pointer;
}
.acw-convite__fechar:hover { background: var(--sand, #f3ede1); color: var(--acw-tinta); }

/* ------------------------------------------------------------------ painel */
.acw-painel {
  position: fixed; right: 20px; bottom: 92px; z-index: 56;
  width: 380px; height: min(640px, calc(100vh - 120px));
  display: flex; flex-direction: column;
  /* `clip` e não só `hidden`: um foco ou um scrollIntoView não podem deslocar
     o painel e esconder o cabeçalho. */
  overflow: hidden; overflow: clip;
  background: var(--acw-fundo); border-radius: 18px;
  box-shadow: 0 30px 70px -20px rgba(15, 26, 19, .5), 0 0 0 1px rgba(20, 34, 26, .07);
  transform-origin: bottom right;
  opacity: 0; transform: translateY(14px) scale(.97); visibility: hidden;
  transition: opacity .2s, transform .25s var(--acw-ease), visibility 0s linear .25s;
}
@supports (height: 100dvh) {
  .acw-painel { height: min(640px, calc(100dvh - 120px)); }
}
.acw.is-aberta .acw-painel { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }

/* Cabeçalho */
.acw-topo {
  position: relative; flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 8px 12px 14px;
  background-color: var(--acw-verde); color: #fff;
  background-image: var(--zigzag, none);
}
.acw-avatar {
  position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; background: #fff;
}
.acw-avatar img { width: 30px; height: 30px; object-fit: contain; }
.acw-avatar::after {
  content: ""; position: absolute; right: -1px; bottom: 0;
  width: 12px; height: 12px; border-radius: 50%;
  background: #4ade80; border: 2px solid var(--acw-verde);
}
.acw-id { flex: 1; min-width: 0; }
.acw-nome {
  margin: 0; font-size: 1rem; font-weight: 800; line-height: 1.25; color: #fff;
  font-family: var(--font-body, system-ui, sans-serif);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acw-estado { margin: 1px 0 0; font-size: .78rem; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.acw-accao {
  flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: #fff; font-size: 1.08rem; text-decoration: none;
}
.acw-accao:hover, .acw-accao:focus-visible { background: rgba(255, 255, 255, .16); color: #fff; }
.acw-accao:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.acw-accao--escura { color: var(--acw-tinta); }
.acw-accao--escura:hover, .acw-accao--escura:focus-visible { background: var(--sand, #f3ede1); color: var(--acw-tinta); }
.acw-accao--escura:focus-visible { outline-color: var(--acw-verde); }

.acw-menu {
  position: absolute; top: calc(100% - 6px); right: 10px; z-index: 5;
  min-width: 220px; padding: 6px; border-radius: 12px;
  background: #fff; box-shadow: 0 16px 40px -12px rgba(15, 26, 19, .4), 0 0 0 1px rgba(20, 34, 26, .06);
}
.acw-menu[hidden] { display: none; }
.acw-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 8px; background: none;
  font: inherit; font-size: .9rem; font-weight: 600; color: var(--acw-tinta); text-align: left; cursor: pointer;
}
.acw-menu button i { width: 18px; text-align: center; color: var(--acw-verde); }
.acw-menu button:hover, .acw-menu button:focus-visible { background: var(--sand, #f3ede1); outline: none; }

/* Fio da conversa */
.acw-fio {
  position: relative; /* referência do offsetTop das mensagens */
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column;
  padding: 14px 12px 8px;
  background-color: var(--acw-fundo);
  background-image: radial-gradient(rgba(20, 34, 26, .05) 1px, transparent 1px);
  background-size: 18px 18px;
}
.acw-fio:focus-visible { outline: 2px solid var(--acw-verde); outline-offset: -2px; }

.acw-dia, .acw-sis {
  align-self: center; max-width: 90%; margin: 6px 0 10px; padding: 5px 10px; border-radius: 8px;
  background: rgba(255, 255, 255, .9); box-shadow: var(--acw-sombra);
  font-size: .74rem; font-weight: 700; color: var(--acw-suave); text-align: center;
}
.acw-sis { font-weight: 600; line-height: 1.4; }
.acw-sis--erro { color: var(--red, #bd090c); }
.acw-sis button {
  margin-left: 6px; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 800; color: var(--acw-verde-escuro); text-decoration: underline;
}

.acw-msg { display: flex; flex-direction: column; max-width: 86%; margin-bottom: 6px; animation: acw-entrar .22s var(--acw-ease); }
.acw-msg--bot { align-self: flex-start; }
.acw-msg--eu { align-self: flex-end; align-items: flex-end; }
.acw-msg--accoes { width: min(86%, 310px); }
.acw-msg--seguida { margin-top: -2px; }

.acw-bolha {
  position: relative; padding: 7px 10px 6px; border-radius: 12px;
  background: #fff; color: var(--acw-tinta); box-shadow: var(--acw-sombra);
  font-size: .92rem; line-height: 1.45; overflow-wrap: anywhere;
}
.acw-msg--bot .acw-bolha { border-top-left-radius: 4px; }
.acw-msg--eu .acw-bolha { background: var(--acw-eu); border-top-right-radius: 4px; }
/* Só a primeira bolha de uma sequência tem o «bico», como no WhatsApp. */
.acw-msg--seguida .acw-bolha { border-top-left-radius: 12px; border-top-right-radius: 12px; }
.acw-msg--accoes .acw-bolha { width: 100%; }
.acw-bolha strong { font-weight: 800; }
.acw-bolha code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: rgba(20, 34, 26, .06); padding: 1px 4px; border-radius: 4px; }
.acw-bolha a { color: #0a64b8; text-decoration: underline; text-underline-offset: 2px; }
.acw-bolha a:hover { color: #084d8d; }
.acw-cab { display: block; margin-bottom: 3px; font-weight: 800; }
.acw-rodape { display: block; margin-top: 6px; font-size: .76rem; color: var(--acw-suave); }

.acw-hora {
  float: right; margin: 7px -2px -3px 10px;
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .68rem; line-height: 1; color: var(--acw-suave); white-space: nowrap;
}
.acw-hora .fa-check-double { color: #34b7f1; }
.acw-hora .fa-circle-exclamation { color: var(--red, #bd090c); }
.acw-msg--erro .acw-bolha { cursor: pointer; }
.acw-falhou { margin-top: 3px; font-size: .72rem; font-weight: 700; color: var(--red, #bd090c); }

.acw-img { display: block; margin: -3px -6px 6px; border-radius: 8px; overflow: hidden; background: var(--sand, #f3ede1); }
.acw-img img { display: block; width: 100%; max-height: 240px; object-fit: cover; }

/* Botões (até três), como as respostas rápidas do WhatsApp */
.acw-botoes { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; width: 100%; }
.acw-botao {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 10px; cursor: pointer;
  background: #fff; color: var(--acw-verde-escuro); box-shadow: var(--acw-sombra);
  font: inherit; font-size: .9rem; font-weight: 700; line-height: 1.3; text-align: center;
  transition: background-color .15s;
}
.acw-botao:hover { background: var(--acw-verde-claro); }
.acw-botao:focus-visible { outline: 2px solid var(--acw-verde); outline-offset: 1px; }
.acw-botao i { font-size: .82rem; opacity: .75; }

/* Lista: o botão «Ver opções» dentro da bolha abre a folha */
.acw-abrir-lista {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: calc(100% + 20px); margin: 8px -10px -6px; padding: 11px 10px;
  border: 0; border-top: 1px solid var(--acw-linha); border-radius: 0 0 12px 12px;
  background: none; color: var(--acw-verde-escuro); cursor: pointer;
  font: inherit; font-size: .9rem; font-weight: 800;
}
.acw-abrir-lista:hover { background: var(--acw-verde-claro); }
.acw-abrir-lista:focus-visible { outline: 2px solid var(--acw-verde); outline-offset: -2px; }

/* «A escrever…» */
.acw-escrever .acw-bolha { display: inline-flex; gap: 4px; padding: 13px 14px; }
.acw-escrever span { width: 7px; height: 7px; border-radius: 50%; background: #9aa59e; animation: acw-ponto 1.2s infinite ease-in-out; }
.acw-escrever span:nth-child(2) { animation-delay: .15s; }
.acw-escrever span:nth-child(3) { animation-delay: .3s; }

/* Sugestões por cima da caixa de texto */
.acw-sugestoes { flex: none; display: flex; gap: 8px; padding: 8px 12px 0; overflow-x: auto; background: var(--acw-fundo); }
.acw-sugestoes[hidden] { display: none; }
.acw-chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--acw-verde); background: #fff; color: var(--acw-verde-escuro);
  font: inherit; font-size: .86rem; font-weight: 700; white-space: nowrap;
}
.acw-chip:hover { background: var(--acw-verde-claro); }
.acw-chip:disabled { opacity: .6; cursor: progress; }

/* Composição */
.acw-compor { flex: none; display: flex; align-items: flex-end; gap: 8px; margin: 0; padding: 8px 10px 6px; background: var(--acw-fundo); }
.acw-caixa {
  flex: 1; min-width: 0; display: flex; align-items: flex-end;
  padding: 3px 4px 3px 14px; border-radius: 22px;
  background: #fff; box-shadow: var(--acw-sombra);
}
.acw-caixa:focus-within { box-shadow: var(--acw-sombra), 0 0 0 2px rgba(46, 125, 24, .35); }
.acw-texto {
  flex: 1; min-width: 0; max-height: 120px; margin: 0; padding: 9px 0;
  border: 0; outline: 0; resize: none; background: transparent;
  font: inherit; font-size: .95rem; line-height: 1.4; color: var(--acw-tinta);
}
.acw-texto::placeholder { color: #8b948e; }
.acw-geo {
  flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--acw-suave); font-size: 1.05rem;
}
.acw-geo:hover, .acw-geo:focus-visible { color: var(--acw-verde); background: var(--acw-verde-claro); outline: none; }
.acw-geo:disabled { cursor: progress; opacity: .6; }
.acw-enviar {
  flex: none; width: 46px; height: 46px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--acw-verde); color: #fff; font-size: 1.05rem;
  transition: background-color .15s, transform .15s;
}
.acw-enviar:hover:not(:disabled) { background: var(--acw-verde-escuro); }
.acw-enviar:active:not(:disabled) { transform: scale(.94); }
.acw-enviar:disabled { background: #a7b9a0; cursor: default; }
.acw-enviar:focus-visible { outline: 3px solid var(--yellow, #f6c90e); outline-offset: 2px; }
.acw-nota { flex: none; margin: 0; padding: 0 12px 8px; background: var(--acw-fundo); font-size: .68rem; color: var(--acw-suave); text-align: center; }
.acw-nota a { color: inherit; text-decoration: underline; }

/* Folha da lista (como a lista do WhatsApp, a subir do fundo) */
.acw-folha {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; justify-content: flex-end;
  visibility: hidden; transition: visibility 0s linear .28s;
}
.acw-folha.is-aberta { visibility: visible; transition-delay: 0s; }
.acw-folha__fundo { position: absolute; inset: 0; background: rgba(15, 26, 19, .4); opacity: 0; transition: opacity .25s; }
.acw-folha.is-aberta .acw-folha__fundo { opacity: 1; }
.acw-folha__painel {
  position: relative; max-height: 82%; display: flex; flex-direction: column;
  background: #fff; border-radius: 18px 18px 0 0;
  transform: translateY(100%); transition: transform .28s var(--acw-ease);
}
.acw-folha.is-aberta .acw-folha__painel { transform: none; }
.acw-folha__topo { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 8px 8px; border-bottom: 1px solid var(--acw-linha); }
.acw-folha__titulo { flex: 1; margin: 0; text-align: center; font-family: var(--font-body, system-ui, sans-serif); font-size: 1rem; font-weight: 800; color: var(--acw-tinta); }
.acw-folha__espaco { width: 38px; flex: none; }
.acw-folha__lista { overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 14px; }
.acw-folha__seccao { margin: 0; padding: 12px 18px 6px; font-size: .74rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--acw-verde-escuro); }
.acw-linha {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 12px 18px; border: 0; border-bottom: 1px solid #f2eee6; background: none;
  font: inherit; color: var(--acw-tinta); text-align: left; cursor: pointer;
}
.acw-linha:last-child { border-bottom: 0; }
.acw-linha:hover, .acw-linha:focus-visible { background: #f7f4ed; outline: none; }
.acw-linha__texto { flex: 1; min-width: 0; }
.acw-linha__titulo { display: block; font-size: .94rem; font-weight: 700; line-height: 1.3; }
.acw-linha__desc { display: block; margin-top: 2px; font-size: .8rem; line-height: 1.35; color: var(--acw-suave); }
.acw-linha__marca { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #b6c0b9; }
.acw-linha:hover .acw-linha__marca { border-color: var(--acw-verde); }

/* --------------------------------------------------------------- telemóvel */
@media (max-width: 560px) {
  .acw-painel {
    top: var(--acw-topo, 0); right: 0; bottom: auto; left: 0;
    width: 100%; height: var(--acw-altura, 100vh); border-radius: 0;
  }
  @supports (height: 100dvh) {
    .acw-painel { height: var(--acw-altura, 100dvh); }
  }
  .acw.is-aberta .acw-lancador, .acw.is-aberta .acw-convite { display: none; }
  .acw-convite { right: 16px; bottom: 90px; }
  .acw-lancador { right: 16px; bottom: 16px; }
  body.acw-on .to-top { bottom: 88px; right: 16px; }
  /* 16px impede o iOS de fazer zoom ao focar a caixa de texto. */
  .acw-texto { font-size: 16px; }
  html.acw-bloqueio, html.acw-bloqueio body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .acw *, .acw *::before, .acw *::after { animation: none !important; transition: none !important; }
}

@media print {
  .acw { display: none !important; }
}

@keyframes acw-entrar { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes acw-ponto { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-4px); opacity: 1; } }
