/* =========================================================
   Chat ao vivo — botão flutuante + janela (landing)

   Folha própria: o widget é autocontido e não depende de mais nada da
   landing além das variáveis de cor. Assim dá para levá-lo para outra
   página depois sem arrastar o resto junto.
   ========================================================= */

.cw {
  --cw-verde: #22c55e;
  --cw-azul: #1B6FC4;
  --cw-azul-escuro: #155A9F;
  --cw-navy: #12325B;
  --cw-linha: #DCE8F1;
  --cw-cinza: #607086;
  --cw-fundo: #F7FBFF;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI",
               system-ui, -apple-system, "Nunito Sans", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Botão flutuante ---------- */
.cw-botao {
  position: fixed; z-index: 120;
  right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 10px;
  height: 58px; padding: 0 20px 0 16px;
  border: none; border-radius: 999px; cursor: pointer;
  background: var(--cw-azul); color: #fff;
  font-family: inherit; font-size: 15.5px; font-weight: 700; line-height: 1;
  box-shadow: 0 8px 22px rgba(18, 50, 91, .28);
  animation: cw-flutua 3.2s ease-in-out infinite;
  transition: background-color .16s ease, transform .12s ease;
}
.cw-botao:hover { background: var(--cw-azul-escuro); }
.cw-botao:active { transform: scale(.97); }
.cw-botao svg { width: 24px; height: 24px; flex: none; }
.cw-botao-texto { white-space: nowrap; }
/* No computador o invólucro do ícone não existe visualmente: os filhos
   dele viram filhos diretos do botão, e o desenho fica o de sempre. */
.cw-botao-circulo { display: contents; }
.cw-botao-curto { display: none; }

/* O "pra cima e pra baixo" pedido: bem leve, sem chamar atenção demais */
@keyframes cw-flutua {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}

/* Bolinha verde de "tem gente online" */
.cw-botao-online {
  position: absolute; top: 6px; right: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--cw-verde); border: 2px solid #fff;
}
/* Contador de mensagens não lidas */
.cw-badge {
  position: absolute; top: -4px; left: -4px;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: #E5484D; color: #fff;
  font-size: 12px; font-weight: 800; line-height: 22px; text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}
.cw-badge[hidden] { display: none; }

/* ---------- Janela ---------- */
.cw-painel {
  position: fixed; z-index: 121;
  right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: min(380px, calc(100vw - 40px));
  height: min(560px, calc(100vh - 40px));
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border-radius: 20px;
  box-shadow: 0 20px 60px rgba(18, 50, 91, .3);
  animation: cw-abre .18s ease;
}
.cw-painel[hidden] { display: none; }
@keyframes cw-abre {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.cw-topo {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; flex: none;
  background: linear-gradient(135deg, var(--cw-azul) 0%, var(--cw-navy) 100%);
  color: #fff;
}
.cw-avatar {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: rgba(255, 255, 255, .2); overflow: hidden;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 800; color: #fff;
  position: relative;
}
.cw-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cw-topo-info { flex: 1; min-width: 0; }
.cw-topo-nome { display: block; font-size: 15.5px; font-weight: 800; line-height: 1.2; }
.cw-topo-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; opacity: .9; margin-top: 2px;
}
.cw-ponto {
  width: 8px; height: 8px; border-radius: 50%; background: var(--cw-verde);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .3);
  animation: cw-pulsa 2s ease-in-out infinite;
}
@keyframes cw-pulsa {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, .3); }
  50%      { box-shadow: 0 0 0 6px rgba(34, 197, 94, .12); }
}
.cw-fechar {
  width: 36px; height: 36px; flex: none; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .16); color: #fff; border-radius: 10px;
  display: grid; place-items: center; font-size: 22px; line-height: 1;
}
.cw-fechar:hover { background: rgba(255, 255, 255, .26); }

/* ---------- Mensagens ---------- */
.cw-corpo {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px; background: var(--cw-fundo);
  display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
}
.cw-msg {
  max-width: 82%; padding: 10px 13px; border-radius: 15px;
  font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere;
  animation: cw-msg-entra .16s ease;
}
@keyframes cw-msg-entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cw-msg--eu {
  align-self: flex-end; background: var(--cw-azul); color: #fff;
  border-bottom-right-radius: 5px;
}
.cw-msg--ela {
  align-self: flex-start; background: #fff; color: #21334A;
  border: 1px solid var(--cw-linha); border-bottom-left-radius: 5px;
}
.cw-msg-hora { display: block; font-size: 10.5px; opacity: .65; margin-top: 4px; text-align: right; }

/* "digitando…" que aparece logo depois que a pessoa manda algo */
.cw-digitando {
  align-self: flex-start; display: flex; gap: 4px;
  padding: 12px 14px; background: #fff;
  border: 1px solid var(--cw-linha); border-radius: 15px; border-bottom-left-radius: 5px;
}
.cw-digitando[hidden] { display: none; }
.cw-digitando span {
  width: 7px; height: 7px; border-radius: 50%; background: #9fb3c8;
  animation: cw-pula 1.3s ease-in-out infinite;
}
.cw-digitando span:nth-child(2) { animation-delay: .18s; }
.cw-digitando span:nth-child(3) { animation-delay: .36s; }
@keyframes cw-pula {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Campo de escrever ---------- */
.cw-rodape {
  flex: none; display: flex; gap: 8px; align-items: flex-end;
  padding: 12px; background: #fff; border-top: 1px solid var(--cw-linha);
}
.cw-campo {
  flex: 1; min-width: 0; resize: none;
  max-height: 110px; padding: 11px 13px;
  border: 1px solid var(--cw-linha); border-radius: 14px;
  font-family: inherit; line-height: 1.4; color: #21334A;
  /* 16px evita o zoom automático do Safari do iPhone ao focar */
  font-size: 16px;
}
.cw-campo:focus { outline: none; border-color: var(--cw-azul); box-shadow: 0 0 0 3px rgba(37, 136, 232, .16); }
.cw-enviar {
  width: 44px; height: 44px; flex: none; border: none; cursor: pointer;
  border-radius: 50%; background: var(--cw-azul); color: #fff;
  display: grid; place-items: center;
}
.cw-enviar:hover { background: var(--cw-azul-escuro); }
.cw-enviar:disabled { opacity: .5; cursor: default; }
.cw-enviar svg { width: 20px; height: 20px; }

.cw-aviso {
  padding: 0 12px 10px; font-size: 12px; color: var(--cw-cinza); text-align: center;
  background: #fff;
}
.cw-aviso[hidden] { display: none; }

/* ---------- Celular: janela ocupa a tela ---------- */
@media (max-width: 560px) {
  .cw-painel {
    right: 0; bottom: 0; left: 0;
    width: 100%; height: 100dvh; max-height: 100dvh;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .cw-topo { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .cw-msg { max-width: 88%; }

  /* ---- Botão no celular: só o símbolo ----
     Uma pílula com "Fale com a gente" ocupa metade da largura da tela e
     briga com a barra fixa de "Criar minha conta". Aqui o botão vira um
     círculo com o ícone e um rótulo miúdo embaixo. */
  .cw-botao {
    right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    flex-direction: column; align-items: center; gap: 5px;
    width: auto; height: auto; padding: 0;
    background: none; border-radius: 0; box-shadow: none;
  }
  .cw-botao:hover { background: none; }

  .cw-botao-circulo {
    /* deixa de ser "contents": agora é o círculo de verdade, e é ele
       que ancora a bolinha verde e o contador */
    display: grid; place-items: center; position: relative;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--cw-azul); color: #fff;
    box-shadow: 0 8px 22px rgba(18, 50, 91, .28);
    transition: background-color .16s ease;
  }
  .cw-botao:hover .cw-botao-circulo { background: var(--cw-azul-escuro); }

  .cw-botao-texto { display: none; }
  .cw-botao-curto {
    display: block; max-width: 92px;
    font-size: 10.5px; font-weight: 700; line-height: 1.2;
    color: var(--cw-navy); text-align: center;
    background: rgba(255, 255, 255, .92);
    padding: 3px 9px; border-radius: 999px;
    box-shadow: 0 2px 8px rgba(18, 50, 91, .16);
  }
}

/* A landing tem uma barra fixa embaixo no celular; quando ela está
   visível, o botão sobe para não cobrir o "Criar minha conta". */
body.lp--sticky-on .cw-botao { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

@media (prefers-reduced-motion: reduce) {
  .cw-botao, .cw-ponto, .cw-digitando span { animation: none; }
  .cw-painel, .cw-msg { animation: none; }
}
