/* =========================================================================
   WIDGET DE CAPTURA — Lopes Pereira Imóveis
   Compartilhado pelas três LPs. Herda os tokens de cada uma.

   Namespace próprio (--lpw-*) de propósito: `--green` significa coisas
   diferentes nas duas paletas (verde-WhatsApp na Vivenda/Camburi,
   verde-marca no Viverde). Usar var(--green) direto sairia errado numa delas.
   ========================================================================= */

.lpw {
  --lpw-brand:   var(--navy, #2E401B);
  --lpw-brand-2: var(--navy-2, #3A4E24);
  --lpw-accent:  var(--gold, #C6A961);
  --lpw-surface: var(--bege-4, var(--sand-4, #fff));
  --lpw-surface-2: var(--bege-2, var(--sand-2, #F4ECDA));
  --lpw-ink:     var(--ink, #1F1B12);
  --lpw-muted:   var(--muted, #5F5748);
  --lpw-line:    var(--line, #DFD2B4);
  --lpw-radius:  var(--radius, 14px);
  --lpw-font:    var(--f, system-ui, -apple-system, sans-serif);
  --lpw-shadow:  var(--sh-lg, 0 12px 40px rgba(0,0,0,.18));

  position: fixed;
  inset: 0;
  z-index: 2147483000;   /* acima de qualquer sticky da página */
  display: none;
  font-family: var(--lpw-font);
  color: var(--lpw-ink);
}

.lpw[data-aberto="1"] { display: block; }

/* ---------- fundo ---------- */
.lpw__fundo {
  position: absolute;
  inset: 0;
  background: rgba(12, 10, 6, .55);
  opacity: 0;
  transition: opacity .22s ease;
}
.lpw[data-aberto="1"] .lpw__fundo { opacity: 1; }

/* ---------- janela ---------- */
.lpw__janela {
  position: absolute;
  background: var(--lpw-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--lpw-shadow);
}

/* Desktop: card ancorado no canto */
@media (min-width: 641px) {
  .lpw__janela {
    right: 24px;
    bottom: 24px;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 48px);
    border-radius: var(--lpw-radius);
    transform: translateY(16px) scale(.98);
    opacity: 0;
    transition: transform .24s cubic-bezier(.2,.8,.3,1), opacity .18s ease;
  }
  .lpw[data-aberto="1"] .lpw__janela { transform: none; opacity: 1; }
}

/* Mobile: bottom-sheet */
@media (max-width: 640px) {
  .lpw__janela {
    left: 0;
    right: 0;
    bottom: 0;
    height: 85vh;
    height: 85dvh;              /* evita o pulo da barra do Safari iOS */
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.2,.8,.3,1);
  }
  .lpw[data-aberto="1"] .lpw__janela { transform: none; }
  .lpw.is-arrastando .lpw__janela { transition: none; }
}

/* ---------- handle (só mobile) ---------- */
.lpw__handle {
  display: none;
  padding: 10px 0 4px;
  cursor: grab;
  touch-action: none;
  flex: 0 0 auto;
}
.lpw__handle::before {
  content: '';
  display: block;
  width: 42px;
  height: 4px;
  margin: 0 auto;
  border-radius: 99px;
  background: var(--lpw-line);
}
@media (max-width: 640px) { .lpw__handle { display: block; } }

/* ---------- cabeçalho ---------- */
.lpw__topo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  background: var(--lpw-brand);
  color: #fff;
  flex: 0 0 auto;
}
.lpw__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  padding: 4px;
  flex: 0 0 auto;
}
.lpw__quem { flex: 1 1 auto; min-width: 0; }
.lpw__nome {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lpw__status {
  font-size: 11.5px;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}
.lpw__status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  flex: 0 0 auto;
}
.lpw__fechar {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.lpw__fechar:hover { background: rgba(255,255,255,.24); }
.lpw__fechar:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- corpo ---------- */
.lpw__corpo {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 8px;
  background: var(--lpw-surface-2);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.lpw__balao {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 15px;
  font-size: 14.5px;
  line-height: 1.45;
  animation: lpw-entra .22s ease both;
  overflow-wrap: anywhere;
}
.lpw__balao--deles {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--lpw-line);
  border-bottom-left-radius: 5px;
}
.lpw__balao--meu {
  align-self: flex-end;
  background: var(--lpw-brand);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.lpw__balao strong { font-weight: 600; }

@keyframes lpw-entra {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- digitando ---------- */
.lpw__digitando {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 13px 15px;
  background: #fff;
  border: 1px solid var(--lpw-line);
  border-radius: 15px;
  border-bottom-left-radius: 5px;
}
.lpw__digitando i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lpw-muted);
  animation: lpw-pula 1.2s infinite;
}
.lpw__digitando i:nth-child(2) { animation-delay: .18s; }
.lpw__digitando i:nth-child(3) { animation-delay: .36s; }

@keyframes lpw-pula {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1;  transform: translateY(-4px); }
}

/* ---------- chips ---------- */
.lpw__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 0 2px;
  align-self: flex-start;
  max-width: 100%;
}
.lpw__chip {
  font: inherit;
  font-size: 13.5px;
  padding: 9px 14px;
  border: 1.5px solid var(--lpw-accent);
  border-radius: 99px;
  background: transparent;
  color: var(--lpw-ink);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.lpw__chip:hover,
.lpw__chip:focus-visible {
  background: var(--lpw-accent);
  color: var(--lpw-brand);
  outline: none;
}

/* ---------- rodapé ---------- */
.lpw__rodape {
  flex: 0 0 auto;
  padding: 11px 12px;
  background: var(--lpw-surface);
  border-top: 1px solid var(--lpw-line);
}
.lpw__linha { display: flex; gap: 8px; }
.lpw__input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 16px;              /* 16px evita o zoom automático no iOS */
  padding: 12px 14px;
  border: 1.5px solid var(--lpw-line);
  border-radius: 11px;
  background: #fff;
  color: var(--lpw-ink);
}
.lpw__input:focus {
  outline: 0;
  border-color: var(--lpw-accent);
  box-shadow: 0 0 0 3px rgba(198,169,97,.22);
}
.lpw__enviar {
  flex: 0 0 auto;
  width: 46px;
  border: 0;
  border-radius: 11px;
  background: var(--lpw-brand);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
}
.lpw__enviar:disabled { opacity: .45; cursor: default; }

/* ---------- botão final ---------- */
.lpw__cta {
  display: block;
  width: 100%;
  padding: 15px 16px;
  border: 0;
  border-radius: 12px;
  background: #12A150;          /* verde do WhatsApp só no botão de ação */
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.lpw__cta:hover { background: #0E7C3A; }

.lpw__alt {
  display: block;
  margin-top: 9px;
  font-size: 12.5px;
  text-align: center;
  color: var(--lpw-muted);
}
.lpw__alt a { color: var(--lpw-muted); }

/* ---------- LGPD ---------- */
.lpw__lgpd {
  margin: 9px 2px 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--lpw-muted);
  text-align: center;
}
.lpw__lgpd a { color: var(--lpw-muted); }

/* ---------- acessibilidade ---------- */
.lpw__sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .lpw__fundo,
  .lpw__janela,
  .lpw__balao { transition: none !important; animation: none !important; }
  .lpw__digitando i { animation: none !important; opacity: .55 !important; }
}

/* 320px: nada pode estourar */
@media (max-width: 360px) {
  .lpw__balao { max-width: 88%; font-size: 14px; }
  .lpw__chip  { font-size: 13px; padding: 8px 12px; }
  .lpw__topo  { padding: 11px 12px; gap: 9px; }
  .lpw__avatar { width: 36px; height: 36px; }
}
