/* =====================================================================
   Botón WhatsApp + captación previa — estilos self-contained
   Depende solo de las variables CSS declaradas aquí (paleta MEP).
   Todo el componente vive bajo el prefijo .wac- para evitar colisiones.
   ===================================================================== */

/* --- Tokens MEP (copiados aquí para que el componente sea portable) -- */
.wac-launcher,
.wac-modal {
  --wac-sand-50: #fbf8f3;
  --wac-sand-100: #f5efe6;
  --wac-sand-200: #ebe2d4;
  --wac-sand-300: #d9ccb8;
  --wac-ink-900: #1d221f;
  --wac-ink-700: #333a35;
  --wac-ink-500: #66706a;
  --wac-ink-400: #8a938c;
  --wac-primary: #486355;         /* verde sage (--green-600) */
  --wac-primary-strong: #3a5044;  /* verde bosque (--green-700) */
  --wac-primary-subtle: #dfe8e2;
  --wac-accent: #be6e4e;          /* terracota (--clay-500) */
  --wac-accent-soft: #fbf3ee;     /* --clay-50 */
  --wac-accent-subtle: #f5e1d5;   /* --clay-100 */
  --wac-danger: #b4503f;
  --wac-border: #ebe2d4;
  --wac-border-strong: #cdd2ce;
  --wac-wa-green: #25d366;        /* WhatsApp brand green */
  --wac-wa-green-strong: #128c7e; /* WhatsApp brand teal */

  --wac-radius-sm: 10px;
  --wac-radius-md: 14px;
  --wac-radius-lg: 18px;
  --wac-radius-xl: 24px;
  --wac-radius-pill: 999px;

  --wac-shadow-launcher: 0 12px 28px rgba(37, 211, 102, .22), 0 4px 10px rgba(29, 34, 31, .10);
  --wac-shadow-md: 0 12px 28px rgba(29, 34, 31, .14);
  --wac-shadow-lg: 0 30px 60px rgba(29, 34, 31, .22);

  --wac-font-display: 'Cormorant Garamond', 'DM Serif Display', Georgia, serif;
  --wac-font-sans: 'Mulish', 'Inter', system-ui, sans-serif;
  --wac-font-hand: 'Caveat', 'Kalam', cursive;
}

/* =====================================================================
   1 · BOTÓN FLOTANTE (launcher)
   ===================================================================== */
.wac-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;

  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px 8px 8px;
  border: none;
  cursor: pointer;

  background: var(--wac-sand-50);
  color: var(--wac-ink-900);
  border-radius: var(--wac-radius-pill);
  box-shadow: var(--wac-shadow-launcher);

  font-family: var(--wac-font-sans);
  font-weight: 700;
  font-size: .95rem;
  text-align: left;
  line-height: 1.15;

  transition: transform .18s cubic-bezier(.22,1,.36,1),
              box-shadow .18s cubic-bezier(.22,1,.36,1);
}
.wac-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(37, 211, 102, .28), 0 6px 14px rgba(29, 34, 31, .12);
}
.wac-launcher:active {
  transform: translateY(0);
}
.wac-launcher:focus-visible {
  outline: 3px solid var(--wac-wa-green);
  outline-offset: 3px;
}

/* Círculo verde con el icono de WhatsApp */
.wac-launcher__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--wac-radius-pill);
  background: var(--wac-wa-green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  position: relative;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .08);
}
.wac-launcher__icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* Pulso sutil alrededor del círculo verde */
.wac-launcher__icon::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: var(--wac-radius-pill);
  border: 2px solid var(--wac-wa-green);
  opacity: 0;
  animation: wac-pulse 2.6s cubic-bezier(.22,1,.36,1) infinite;
}
@keyframes wac-pulse {
  0%   { transform: scale(.85); opacity: .55; }
  70%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Bloque de texto (título + subtítulo) */
.wac-launcher__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wac-launcher__title {
  font-family: var(--wac-font-sans);
  font-weight: 700;
  font-size: .95rem;
  color: var(--wac-ink-900);
  letter-spacing: -0.005em;
}
.wac-launcher__sub {
  font-family: var(--wac-font-sans);
  font-weight: 500;
  font-size: .74rem;
  color: var(--wac-ink-500);
  letter-spacing: 0;
}

/* — Móvil: el botón colapsa a círculo verde puro — */
@media (max-width: 640px) {
  .wac-launcher {
    right: 14px;
    bottom: 14px;
    padding: 0;
    background: transparent;
    box-shadow: none;
  }
  .wac-launcher__text { display: none; }
  .wac-launcher__icon {
    width: 56px;
    height: 56px;
    box-shadow: var(--wac-shadow-launcher);
  }
  .wac-launcher__icon svg { width: 28px; height: 28px; }
}

/* — Respetar preferencia de movimiento reducido — */
@media (prefers-reduced-motion: reduce) {
  .wac-launcher,
  .wac-launcher__icon::before {
    animation: none !important;
    transition: none !important;
  }
}

/* =====================================================================
   2 · MODAL (velo + tarjeta centrada)
   ===================================================================== */
.wac-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  font-family: var(--wac-font-sans);
  color: var(--wac-ink-900);
}
.wac-modal[data-open="true"] {
  pointer-events: auto;
}

.wac-modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(29, 34, 31, .42);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .28s cubic-bezier(.22,1,.36,1);
}
.wac-modal[data-open="true"] .wac-modal__scrim { opacity: 1; }

.wac-modal__wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.wac-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--wac-sand-50);
  border-radius: var(--wac-radius-xl);
  box-shadow: var(--wac-shadow-lg);
  overflow: hidden;
  transform: translateY(18px) scale(.98);
  opacity: 0;
  transition: transform .32s cubic-bezier(.22,1,.36,1),
              opacity .28s cubic-bezier(.22,1,.36,1);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.wac-modal[data-open="true"] .wac-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* — Cerrar (esquina superior derecha) — */
.wac-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: var(--wac-radius-pill);
  border: none;
  background: rgba(255, 255, 255, .7);
  color: var(--wac-ink-700);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background .15s ease;
}
.wac-close:hover { background: #fff; }
.wac-close:focus-visible {
  outline: 2px solid var(--wac-primary);
  outline-offset: 2px;
}

/* — Cabecera cálida con foto + saludo — */
.wac-header {
  padding: 30px 24px 20px;
  background: linear-gradient(155deg, var(--wac-accent-soft) 0%, var(--wac-sand-50) 68%);
  border-bottom: 1px solid var(--wac-border);
}
.wac-header__row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 40px; /* deja aire al botón X */
}
.wac-avatar {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: var(--wac-radius-pill);
  overflow: hidden;
  border: 2.5px solid #fff;
  box-shadow: 0 4px 12px rgba(29, 34, 31, .12);
  flex: none;
}
.wac-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.wac-avatar__dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 18px;
  height: 18px;
  border-radius: var(--wac-radius-pill);
  background: var(--wac-wa-green);
  border: 2.5px solid var(--wac-sand-50);
}

.wac-header__eyebrow {
  font-family: var(--wac-font-sans);
  font-weight: 700;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--wac-accent);
  margin: 0 0 4px;
}
.wac-header__title {
  font-family: var(--wac-font-display);
  font-weight: 600;
  font-size: 1.65rem;
  color: var(--wac-ink-900);
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}

.wac-header__hand {
  font-family: var(--wac-font-hand);
  font-weight: 500;
  font-size: 1.35rem;
  color: var(--wac-accent);
  margin: 14px 0 0;
  line-height: 1.3;
}

.wac-header__lede {
  margin: 12px 0 0;
  font-family: var(--wac-font-sans);
  font-size: .93rem;
  color: var(--wac-ink-700);
  line-height: 1.55;
  text-wrap: pretty;
}

/* — Formulario — */
.wac-form {
  padding: 22px 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wac-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wac-field__label {
  font-family: var(--wac-font-sans);
  font-weight: 600;
  font-size: .84rem;
  color: var(--wac-ink-700);
}
.wac-field__input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--wac-font-sans);
  font-size: .98rem;
  color: var(--wac-ink-900);
  background: #fff;
  border: 1.5px solid var(--wac-border-strong);
  border-radius: var(--wac-radius-md);
  padding: 13px 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.wac-field__input::placeholder { color: var(--wac-ink-400); }
.wac-field__input:focus {
  border-color: var(--wac-primary);
  box-shadow: 0 0 0 3px rgba(90, 122, 104, .18);
}
.wac-field--error .wac-field__input {
  border-color: var(--wac-danger);
}
.wac-field--error .wac-field__input:focus {
  box-shadow: 0 0 0 3px rgba(180, 80, 63, .18);
}
.wac-field__error {
  font-size: .78rem;
  color: var(--wac-danger);
  min-height: 0;
  display: none;
}
.wac-field--error .wac-field__error { display: block; }

/* — Casilla de consentimiento — */
.wac-consent {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px 14px;
  background: var(--wac-accent-soft);
  border: 1px solid var(--wac-accent-subtle);
  border-radius: var(--wac-radius-md);
  cursor: pointer;
  margin-top: 2px;
  transition: border-color .15s ease, background .15s ease;
}
.wac-consent:hover { border-color: var(--wac-accent); }
.wac-consent input[type="checkbox"] {
  margin: 2px 0 0;
  accent-color: var(--wac-accent);
  width: 17px;
  height: 17px;
  flex: none;
  cursor: pointer;
}
.wac-consent__text {
  font-family: var(--wac-font-sans);
  font-size: .84rem;
  color: var(--wac-ink-700);
  line-height: 1.5;
  text-wrap: pretty;
}
.wac-consent__text a {
  color: var(--wac-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* — Botón envío — */
.wac-submit {
  margin-top: 6px;
  width: 100%;
  border: none;
  cursor: pointer;
  background: var(--wac-wa-green);
  color: #fff;
  padding: 15px 20px;
  border-radius: var(--wac-radius-pill);
  font-family: var(--wac-font-sans);
  font-weight: 700;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .15s ease, transform .12s ease, box-shadow .18s ease;
  box-shadow: 0 8px 20px rgba(37, 211, 102, .28);
}
.wac-submit:hover { background: var(--wac-wa-green-strong); }
.wac-submit:active { transform: translateY(1px); }
.wac-submit:disabled {
  background: var(--wac-sand-200);
  color: var(--wac-ink-400);
  cursor: not-allowed;
  box-shadow: none;
}
.wac-submit svg { width: 18px; height: 18px; }

/* Loader mientras se registra el lead */
.wac-submit[data-loading="true"] { pointer-events: none; }
.wac-submit__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: var(--wac-radius-pill);
  animation: wac-spin .7s linear infinite;
}
.wac-submit[data-loading="true"] .wac-submit__spinner { display: inline-block; }
.wac-submit[data-loading="true"] .wac-submit__icon { display: none; }
@keyframes wac-spin { to { transform: rotate(360deg); } }

.wac-fineprint {
  margin: 4px 0 0;
  font-family: var(--wac-font-sans);
  font-size: .76rem;
  color: var(--wac-ink-400);
  text-align: center;
  line-height: 1.5;
  text-wrap: pretty;
}

/* — Móvil: la tarjeta encaja abajo como bottom sheet — */
@media (max-width: 520px) {
  .wac-modal__wrap { padding: 14px 14px 0; align-items: flex-end; }
  .wac-card {
    max-width: 100%;
    border-radius: 22px 22px 0 0;
    max-height: 92vh;
  }
  .wac-header { padding: 24px 20px 16px; }
  .wac-form { padding: 18px 20px 22px; }
  .wac-header__title { font-size: 1.5rem; }
}

/* — Respetar preferencia de movimiento reducido — */
@media (prefers-reduced-motion: reduce) {
  .wac-modal__scrim,
  .wac-card { transition: none !important; }
}
