/* =========================================================
   WHATSAPP — Botón flotante + panel de conversación
   Integrado con la estética piedra, vela y oro
   ========================================================= */

.wa-widget {
  --wa-green: #25d366;
  --wa-green-deep: #128c7e;
  --wa-status: #25d366;
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.9rem;
  font-family: var(--font-sans, 'Inter', sans-serif);
  transition: opacity 0.4s var(--ease, ease), transform 0.5s var(--ease, ease);
}
.wa-widget[data-status="closed"] { --wa-status: #f59e0b; }
.wa-widget.is-hidden { opacity: 0; pointer-events: none; transform: translateY(16px); }

/* ── Botón principal ── */
.wa-fab {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  background: radial-gradient(circle at 30% 25%, #5ee68f, var(--wa-green) 45%, var(--wa-green-deep) 100%);
  box-shadow:
    0 0 0 4px rgba(12, 10, 8, 0.85),
    0 0 0 5px rgba(201, 168, 76, 0.55),
    0 18px 40px -10px rgba(37, 211, 102, 0.55),
    0 10px 24px -8px rgba(0, 0, 0, 0.8);
  transition: transform 0.5s var(--ease, ease), box-shadow 0.5s var(--ease, ease);
}
.wa-fab:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    0 0 0 4px rgba(12, 10, 8, 0.85),
    0 0 0 5px rgba(232, 213, 163, 0.85),
    0 22px 50px -10px rgba(37, 211, 102, 0.7),
    0 12px 28px -8px rgba(0, 0, 0, 0.8);
}
.wa-fab:active { transform: scale(0.96); }
.wa-fab:focus-visible { outline: 2px solid var(--candle, #f3b65b); outline-offset: 8px; border-radius: 50%; }
.wa-fab svg {
  grid-area: 1 / 1;
  width: 30px;
  height: 30px;
  transition: transform 0.5s var(--ease, ease), opacity 0.3s;
}
.wa-fab .wa-icon-close { width: 24px; height: 24px; opacity: 0; transform: rotate(-90deg) scale(0.6); }
.wa-widget.is-open .wa-fab .wa-icon-wa { opacity: 0; transform: rotate(90deg) scale(0.6); }
.wa-widget.is-open .wa-fab .wa-icon-close { opacity: 1; transform: none; }

.wa-fab-ring {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid rgba(37, 211, 102, 0.65);
  pointer-events: none;
  animation: waPulse 2.8s var(--ease, ease) infinite;
}
.wa-fab-ring:nth-child(2) { animation-delay: 1.4s; }
.wa-widget.is-open .wa-fab-ring { animation: none; opacity: 0; }
@keyframes waPulse {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1.6); opacity: 0; }
}

.wa-fab-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font: 700 0.72rem/22px var(--font-sans, sans-serif);
  color: #1b1408;
  background: linear-gradient(135deg, #e6c983, #c9a84c 55%, #9a782b);
  box-shadow: 0 0 0 3px var(--stone-950, #0c0a08);
  transition: transform 0.4s var(--ease, ease), opacity 0.3s;
}
.wa-fab-badge.is-gone { transform: scale(0); opacity: 0; }

/* ── Mensaje de invitación ── */
.wa-teaser {
  position: relative;
  max-width: 270px;
  border-radius: 16px 16px 4px 16px;
  background: linear-gradient(180deg, #2d261f, #1a1612);
  border: 1px solid rgba(201, 168, 76, 0.32);
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.95), 0 0 40px -20px rgba(243, 182, 91, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.45s var(--ease, ease), transform 0.55s var(--ease, ease), visibility 0.45s;
}
.wa-teaser.is-visible { opacity: 1; visibility: visible; transform: none; }
.wa-teaser-btn {
  display: block;
  width: 100%;
  padding: 0.9rem 2.6rem 0.9rem 1.1rem;
  text-align: left;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text-2, #bcb097);
  background: none;
  border: none;
  border-radius: inherit;
  cursor: pointer;
}
.wa-teaser-btn strong {
  display: block;
  margin-bottom: 0.15rem;
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gold-light, #e8d5a3);
}
.wa-teaser-btn:hover strong { color: #fff; }
.wa-teaser-close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-3, #908471);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.3s, background 0.3s;
}
.wa-teaser-close:hover { color: var(--bone, #efe6d2); background: rgba(255, 240, 200, 0.08); }

/* ── Panel ── */
.wa-panel {
  width: min(370px, calc(100vw - 2.5rem));
  overflow: hidden;
  border-radius: 24px;
  background: linear-gradient(180deg, #211c17, #13100d);
  border: 1px solid rgba(201, 168, 76, 0.28);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.95), 0 0 60px -25px rgba(243, 182, 91, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.4s var(--ease, ease), transform 0.55s var(--ease, ease), visibility 0.4s;
}
.wa-widget.is-open .wa-panel { opacity: 1; visibility: visible; transform: none; }

.wa-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.1rem 1rem 1.1rem 1.25rem;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(37, 211, 102, 0.2), transparent 60%),
    linear-gradient(135deg, #10261c, #13100d 80%);
  border-bottom: 1px solid rgba(201, 168, 76, 0.18);
}
.wa-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--gold, #c9a84c);
  background: radial-gradient(circle at 50% 35%, rgba(243, 182, 91, 0.25), rgba(12, 10, 8, 0.9));
  border: 1px solid rgba(201, 168, 76, 0.45);
}
.wa-avatar svg { width: 22px; height: 22px; filter: drop-shadow(0 0 8px rgba(243, 182, 91, 0.6)); }
.wa-avatar::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--wa-status);
  border: 2px solid #13100d;
  box-shadow: 0 0 8px var(--wa-status);
}
.wa-head-text { min-width: 0; }
.wa-title {
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--bone, #efe6d2);
}
.wa-status { margin-top: 0.15rem; font-size: 0.8rem; line-height: 1.4; color: var(--text-2, #bcb097); }
.wa-close {
  margin-left: auto;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-2, #bcb097);
  background: transparent;
  border: 1px solid rgba(201, 168, 76, 0.2);
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.wa-close:hover { color: var(--gold-light, #e8d5a3); border-color: var(--gold, #c9a84c); background: rgba(201, 168, 76, 0.08); }

.wa-body {
  max-height: min(52vh, 400px);
  overflow-y: auto;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 85% 10%, rgba(243, 182, 91, 0.06), transparent 50%),
    var(--stone-950, #0c0a08);
}

.wa-typing {
  display: inline-flex;
  gap: 5px;
  padding: 0.85rem 1rem;
  border-radius: 4px 16px 16px 16px;
  background: rgba(255, 240, 200, 0.05);
  border: 1px solid rgba(201, 168, 76, 0.16);
}
.wa-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold, #c9a84c);
  animation: waDot 1.1s infinite ease-in-out;
}
.wa-typing span:nth-child(2) { animation-delay: 0.15s; }
.wa-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes waDot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.wa-bubble {
  max-width: 90%;
  padding: 0.85rem 1rem 0.55rem;
  border-radius: 4px 16px 16px 16px;
  background: rgba(255, 240, 200, 0.05);
  border: 1px solid rgba(201, 168, 76, 0.16);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--bone, #efe6d2);
}
.wa-bubble time {
  display: block;
  margin-top: 0.2rem;
  text-align: right;
  font-size: 0.7rem;
  color: var(--text-3, #908471);
}

.wa-topics-label {
  margin: 1.25rem 0 0.65rem;
  font-family: var(--font-inscription, Georgia, serif);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold, #c9a84c);
}
.wa-topics { display: flex; flex-direction: column; gap: 0.5rem; }
.wa-topic {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 46px;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-size: 0.93rem;
  color: var(--bone, #efe6d2);
  background: rgba(33, 28, 23, 0.7);
  border: 1px solid rgba(201, 168, 76, 0.2);
  transition: transform 0.45s var(--ease, ease), border-color 0.3s, background 0.3s;
}
.wa-topic svg { flex-shrink: 0; color: var(--gold, #c9a84c); transition: transform 0.4s var(--ease, ease), color 0.3s; }
.wa-topic:hover, .wa-topic:focus-visible {
  transform: translateX(4px);
  border-color: rgba(37, 211, 102, 0.6);
  background: rgba(37, 211, 102, 0.08);
}
.wa-topic:hover svg { transform: translateX(3px); color: var(--wa-green); }

/* Aparición escalonada del contenido */
.wa-reveal { opacity: 0; transform: translateY(8px); transition: opacity 0.5s var(--ease, ease), transform 0.5s var(--ease, ease); }
.wa-ready .wa-reveal { opacity: 1; transform: none; }
.wa-ready .wa-reveal:nth-child(2) { transition-delay: 0.06s; }
.wa-ready .wa-reveal:nth-child(3) { transition-delay: 0.12s; }
.wa-ready .wa-reveal:nth-child(4) { transition-delay: 0.18s; }
.wa-ready .wa-reveal:nth-child(5) { transition-delay: 0.24s; }

.wa-foot {
  padding: 1rem 1.25rem 1.2rem;
  border-top: 1px solid rgba(201, 168, 76, 0.14);
  background: #13100d;
}
.wa-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 50px;
  padding: 0.9rem 1rem;
  border-radius: 999px;
  font-family: var(--font-inscription, Georgia, serif);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #04130d;
  background: linear-gradient(135deg, #5ee68f, var(--wa-green) 50%, #1aa57a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 14px 30px -14px rgba(37, 211, 102, 0.8);
  transition: transform 0.45s var(--ease, ease), box-shadow 0.45s;
}
.wa-cta svg { width: 20px; height: 20px; }
.wa-cta:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 18px 36px -12px rgba(37, 211, 102, 0.9); }
.wa-call { margin-top: 0.75rem; text-align: center; font-size: 0.82rem; color: var(--text-3, #908471); }
.wa-call a { color: var(--gold, #c9a84c); text-decoration: underline; text-underline-offset: 3px; }
.wa-call a:hover { color: var(--gold-light, #e8d5a3); }

/* ── WhatsApp en la lista de contacto ── */
.contact-method-wa .contact-icon {
  color: #25d366;
  border-color: rgba(37, 211, 102, 0.45);
  background: radial-gradient(circle at 50% 35%, rgba(37, 211, 102, 0.22), rgba(37, 211, 102, 0.03));
}
a.contact-method-wa:hover { border-color: rgba(37, 211, 102, 0.55); background: rgba(37, 211, 102, 0.06); }

/* ── Responsive ── */
@media (max-width: 480px) {
  .wa-widget { right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); }
  .wa-fab { width: 58px; height: 58px; }
  .wa-fab svg { width: 27px; height: 27px; }
  .wa-panel { width: calc(100vw - 2rem); }
  .wa-teaser { max-width: 230px; }
}

@media (prefers-reduced-motion: reduce) {
  .wa-fab-ring { animation: none; display: none; }
  .wa-reveal { opacity: 1; transform: none; }
}

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