/* =========================================================
   ESTERO NATURAL — Widget de WhatsApp
   ========================================================= */
.wa-widget {
  --wa: #25D366;
  --wa-ink: #167A43;
  --wa-ink-2: #11633A;
  position: fixed; right: 28px; bottom: 28px; z-index: 950;
  display: flex; flex-direction: column; align-items: flex-end; gap: 16px;
  font-family: var(--font-sans);
  transition: opacity .3s var(--ease), visibility .3s;
}
body.menu-open .wa-widget, body.lb-open .wa-widget { opacity: 0; visibility: hidden; }

/* El botón de volver arriba sube para dejar sitio al de WhatsApp */
.scroll-to-top { bottom: 104px; }

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

/* ---------- Botón flotante ---------- */
.wa-fab {
  position: relative; width: 62px; height: 62px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: #fff;
  background: linear-gradient(145deg, #2BD46C, var(--wa-ink));
  box-shadow: 0 18px 36px -14px rgba(22, 122, 67, .75), 0 0 0 1px rgba(255, 255, 255, .25) inset;
  touch-action: manipulation;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.wa-fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 24px 44px -14px rgba(22, 122, 67, .85), 0 0 0 1px rgba(255, 255, 255, .3) inset; }
.wa-fab:active { transform: scale(.96); }
.wa-fab::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--wa); opacity: 0;
  animation: wa-ring 2.8s var(--ease) 1.5s 4;
}
.wa-widget.open .wa-fab::before { animation: none; }
.wa-fab svg { position: absolute; width: 30px; height: 30px; transition: transform .4s var(--ease), opacity .3s; }
.wa-fab .wa-icon-close { width: 26px; height: 26px; opacity: 0; transform: rotate(-90deg) scale(.6); }
.wa-widget.open .wa-fab .wa-icon-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.wa-widget.open .wa-fab .wa-icon-close { opacity: 1; transform: none; }
.wa-badge {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--ochre); border: 2px solid #fff;
  transition: transform .3s var(--ease);
}
.wa-widget.seen .wa-badge { transform: scale(0); }
@keyframes wa-ring {
  0% { opacity: .7; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(1.55); }
}

/* ---------- Aviso ---------- */
.wa-teaser {
  position: relative; max-width: 260px; padding: 14px 40px 14px 18px;
  border-radius: 18px 18px 4px 18px; background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  font-size: .92rem; line-height: 1.45;
  opacity: 0; visibility: hidden; transform: translateY(10px) scale(.96); transform-origin: bottom right;
  transition: opacity .4s var(--ease), transform .4s var(--ease), visibility .4s;
}
.wa-teaser.show { opacity: 1; visibility: visible; transform: none; }
.wa-teaser strong { display: block; font-family: var(--font-display); font-size: 1.2rem; color: var(--estuary); line-height: 1.2; margin-bottom: 2px; }
.wa-teaser-open { all: unset; cursor: pointer; display: block; }
.wa-teaser-open:focus-visible { outline: 2px solid var(--ochre); outline-offset: 4px; border-radius: 8px; }
.wa-teaser-close {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; background: transparent; color: var(--muted);
  transition: background .25s, color .25s;
}
.wa-teaser-close:hover { background: var(--salt-2); color: var(--ink); }
.wa-teaser-close svg { width: 16px; height: 16px; }

/* ---------- Panel de chat ---------- */
.wa-panel {
  position: absolute; right: 0; bottom: calc(100% + 16px);
  width: min(370px, calc(100vw - 36px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 24px; background: var(--paper);
  box-shadow: 0 40px 90px -30px rgba(9, 39, 43, .6), 0 0 0 1px var(--line);
  opacity: 0; visibility: hidden; transform: translateY(16px) scale(.96); transform-origin: bottom right;
  transition: opacity .35s var(--ease), transform .35s var(--ease), visibility .35s;
}
.wa-widget.open .wa-panel { opacity: 1; visibility: visible; transform: none; }

.wa-head {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 20px 20px 22px;
  background: radial-gradient(120% 140% at 100% 0%, var(--estuary-3), transparent 60%), var(--estuary);
  color: var(--on-dark);
}
.wa-head::after {
  content: ""; position: absolute; right: -40px; top: -60px; width: 180px; height: 180px; border-radius: 50%;
  background: repeating-radial-gradient(circle, rgba(232, 199, 126, .16) 0 1px, transparent 1px 12px);
  pointer-events: none;
}
.wa-avatar {
  position: relative; flex-shrink: 0; width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--salt); color: var(--estuary);
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; font-style: italic; letter-spacing: .02em;
  box-shadow: 0 0 0 3px rgba(232, 199, 126, .45);
}
.wa-status { position: absolute; right: 0; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--wa); border: 2px solid var(--estuary); }
.wa-head-text { flex: 1; min-width: 0; }
.wa-head h2 { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; line-height: 1.1; }
.wa-head p { font-size: .82rem; color: var(--on-dark-muted); }
.wa-close {
  position: relative; z-index: 1; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25);
  display: grid; place-items: center; cursor: pointer; background: rgba(255, 255, 255, .06); color: #fff;
  transition: background .25s, color .25s;
}
.wa-close:hover { background: #fff; color: var(--estuary); }
.wa-close svg { width: 18px; height: 18px; }

.wa-body {
  padding: 20px 18px 8px; max-height: min(52vh, 380px); overflow-y: auto; overscroll-behavior: contain;
  background-color: var(--salt-2);
  background-image: radial-gradient(rgba(14, 58, 64, .08) 1px, transparent 1.4px);
  background-size: 18px 18px;
}
.wa-msg {
  position: relative; max-width: 92%; padding: 12px 16px 8px; margin-bottom: 20px;
  border-radius: 4px 18px 18px 18px; background: #fff; color: var(--ink);
  box-shadow: var(--shadow-sm); font-size: .95rem; line-height: 1.5;
  animation: rise .5s var(--ease) both;
}
.wa-msg::before {
  content: ""; position: absolute; top: 0; left: -8px; width: 10px; height: 14px;
  background: #fff; clip-path: polygon(100% 0, 0 0, 100% 100%);
}
.wa-msg time { display: block; margin-top: 4px; text-align: right; font-size: .72rem; color: var(--muted); }
.wa-label { margin: 0 0 10px 4px; font-size: .7rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.wa-topics { display: grid; gap: 8px; padding-bottom: 12px; }
.wa-topic {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 10px 16px; border-radius: 14px;
  background: var(--paper); border: 1px solid var(--line); color: var(--estuary);
  font-size: .92rem; font-weight: 600; line-height: 1.3;
  transition: background .25s, color .25s, border-color .25s, transform .25s var(--ease);
}
.wa-topic svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--wa-ink); transition: transform .25s var(--ease), color .25s; }
.wa-topic:hover { background: var(--estuary); border-color: var(--estuary); color: #fff; transform: translateX(2px); }
.wa-topic:hover svg { color: var(--salt-gold); transform: translateX(3px); }

.wa-form { display: flex; align-items: flex-end; gap: 10px; padding: 14px 14px 10px; background: var(--paper); border-top: 1px solid var(--line); }
.wa-form textarea {
  flex: 1; min-height: 48px; max-height: 120px; padding: 13px 16px; resize: none;
  border: 1px solid var(--line); border-radius: 16px; background: #fff; color: var(--ink);
  font: inherit; font-size: 1rem; line-height: 1.4;
  transition: border-color .25s, box-shadow .25s;
}
.wa-form textarea::placeholder { color: #6B7573; }
.wa-form textarea:focus { outline: none; border-color: var(--wa-ink); box-shadow: 0 0 0 3px rgba(22, 122, 67, .18); }
.wa-form textarea.wa-error { border-color: var(--ochre); animation: wa-shake .4s var(--ease); }
.wa-send {
  flex-shrink: 0; width: 48px; height: 48px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: #fff; background: var(--wa-ink);
  transition: background .25s, transform .25s var(--ease);
}
.wa-send:hover { background: var(--wa-ink-2); transform: scale(1.06); }
.wa-send svg { width: 20px; height: 20px; }
.wa-foot { padding: 0 16px 14px; background: var(--paper); text-align: center; font-size: .78rem; color: var(--muted); }
.wa-foot a { color: var(--estuary); font-weight: 600; }
@keyframes wa-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  .wa-widget { right: 18px; bottom: 18px; }
  .wa-fab { width: 56px; height: 56px; }
  .wa-fab svg { width: 28px; height: 28px; }
  .scroll-to-top { bottom: 86px; }
  .wa-teaser { max-width: 220px; }
}

@media (forced-colors: active) {
  .wa-fab, .wa-send, .wa-close, .wa-topic { border: 1px solid ButtonText; }
}

@media print {
  .wa-widget { display: none !important; }
}
