/* ==========================================================================
   Chatealo · Popups de la sección Problemas (js/pain-dialog.js)
   Cada tarjeta abre un <dialog> con la solución: título, texto, botones,
   lista de beneficios y dos paneles ilustrados con la interfaz.
   Mismo comportamiento que los popups de stripe.com: velo claro, panel que
   sube con desaceleración, cierre con Esc, con la X o tocando afuera.
   ========================================================================== */

/* Bloquea el scroll de la página mientras hay un popup abierto (sin salto por la barra) */
html.has-dialog { overflow: hidden; scrollbar-gutter: stable; }

.pain-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 6rem var(--gutter);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  background: transparent;
  color: var(--ink-black);
}
.pain-dialog::backdrop {
  background: rgba(245, 245, 255, .92);
  opacity: 0;
  transition: opacity .25s ease;
}
.pain-dialog.is-open::backdrop { opacity: 1; }

.pain-dialog__panel {
  position: relative;
  display: grid;
  width: min(150rem, 100%);
  margin: 0 auto;
  padding: 9.6rem 9.6rem 11.2rem;
  border-radius: 3.2rem;
  background: #fff;
  box-shadow: 0 .2rem .6rem rgba(40, 36, 110, .04), 0 3rem 9rem -2rem rgba(40, 36, 110, .16);
  opacity: 0;
  transform: translateY(2.4rem);
  transition: opacity .3s ease, transform .8s cubic-bezier(.22, 1, .36, 1);
}
.pain-dialog__panel:focus { outline: none; }
.pain-dialog.is-open .pain-dialog__panel { opacity: 1; transform: none; }
.pain-dialog.is-closing .pain-dialog__panel {
  opacity: 0;
  transform: translateY(1.2rem) scale(.99);
  transition: opacity .2s ease, transform .25s ease;
}

/* X: queda fija arriba a la derecha aunque se scrollee el popup */
.pain-dialog__close {
  position: sticky;
  top: 2.4rem;
  z-index: 3;
  justify-self: end;
  display: grid;
  place-items: center;
  width: 5.4rem;
  height: 5.4rem;
  margin: -7.2rem -7.2rem -5.4rem 0;
  border-radius: 1.2rem;
  background: #eef0ff;
  box-shadow: 0 .4rem 1.4rem rgba(40, 36, 110, .12);
  color: #6366f1;
  transition: background-color .2s ease, color .2s ease;
}
.pain-dialog__close:hover { background: #6366f1; color: #fff; }
.pain-dialog__close svg { width: 2.2rem; height: 2.2rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ---------- Encabezado: texto + botones a la izquierda, beneficios a la derecha ---------- */
.pain-dialog__head {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 4rem 9.6rem;
  align-items: start;
}
.pain-dialog__eyebrow {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 2.4rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #6366f1;
}
.pain-dialog__title {
  margin-top: 1.6rem;
  font-size: 4.4rem;
  font-weight: 500;
  line-height: 5.4rem;
  letter-spacing: -.02em;
  color: var(--ink-black);
}
.pain-dialog__lead {
  margin-top: 2.4rem;
  font-size: 2.2rem;
  line-height: 3.5rem;
  color: var(--ink-600);
}
.pain-dialog__actions { display: flex; flex-wrap: wrap; gap: 1.6rem; margin-top: 4rem; }
.pain-dialog__btn { height: 6.4rem; padding: 0 3.6rem; font-size: 1.9rem; }
.pain-dialog__btn svg { width: 1.8rem; height: 1.8rem; margin-left: 1rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pain-dialog__btn--ghost {
  border: .15rem solid #6366f1;
  color: #6366f1;
  background: #fff;
  transition: background-color .2s ease, color .2s ease;
}
.pain-dialog__btn--ghost:hover { filter: none; background: #6366f1; color: #fff; }

.pain-dialog__list { display: grid; gap: 1.8rem; padding-top: 4rem; }
.pain-dialog__list li {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  gap: 1.4rem;
  font-size: 2rem;
  line-height: 2.8rem;
  color: var(--ink-strong);
}
.pain-dialog__list svg { width: 2.6rem; height: 2.6rem; margin-top: .1rem; }
.pain-dialog__list circle { fill: #e9fbf2; }
.pain-dialog__list path { fill: none; stroke: #13b86c; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Paneles ilustrados ---------- */
.pain-dialog__visuals {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 2.2rem;
  margin-top: 8rem;
}
.pv {
  position: relative;
  display: grid;
  place-items: center;
  height: 58rem;
  margin: 0;
  padding: 4.8rem;
  overflow: hidden;
  border-radius: 2.4rem;
}
.pv--indigo { background: radial-gradient(90% 80% at 0% 100%, rgba(168, 85, 247, .55), rgba(168, 85, 247, 0) 70%), linear-gradient(160deg, #f5f5ff 10%, #dfe0ff 55%, #8e91f5 100%); }
.pv--green { background: radial-gradient(90% 80% at 100% 100%, rgba(37, 224, 137, .6), rgba(37, 224, 137, 0) 70%), linear-gradient(200deg, #fff 10%, #effcf6 50%, #9ff0c9 100%); }

.pv-card {
  width: 100%;
  max-width: 56rem;
  padding: 3rem 3.2rem;
  border-radius: 2rem;
  background: #fff;
  box-shadow: 0 .2rem .6rem rgba(40, 36, 110, .05), 0 2.4rem 5rem -1.6rem rgba(40, 36, 110, .25);
  font-size: 1.6rem;
  line-height: 2.2rem;
  color: var(--ink-strong);
}
.pv-card + .pv-card { margin-top: 2rem; }
.pv-stack { width: 100%; max-width: 44rem; }
.pv-card__head { display: flex; align-items: center; justify-content: space-between; gap: 1.6rem; }
.pv-card__title { font-size: 1.9rem; font-weight: 600; line-height: 2.6rem; color: var(--ink-black); }
.pv-card__sub { font-size: 1.4rem; line-height: 2rem; color: var(--ink-400); }
.pv-chip {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  height: 2.8rem;
  padding: 0 1.2rem;
  border-radius: 99px;
  background: #eef0ff;
  font-size: 1.3rem;
  font-weight: 600;
  color: #6366f1;
  white-space: nowrap;
}
.pv-chip--green { background: #e3faef; color: #0f9d5c; }
.pv-chip--purple { background: #f4ebff; color: #9333ea; }
.pv-dot { width: .9rem; height: .9rem; border-radius: 50%; background: currentColor; }

.pv-chip--red { background: #fdecec; color: #d92d2d; }
.pv-corner { position: absolute; top: 2.4rem; left: 2.4rem; z-index: 2; }
.pv--auto { height: auto; min-height: 58rem; }
.pv-img { width: 100%; height: 100%; object-fit: contain; }

/* Barras horizontales */
.pv-bars { display: grid; gap: 1.8rem; margin-top: 2.6rem; }
.pv-bar__label { display: flex; justify-content: space-between; font-size: 1.4rem; line-height: 2rem; color: var(--ink-600); }
.pv-bar__label b { font-weight: 600; color: var(--ink-black); }
.pv-bar__track { height: 1rem; margin-top: .8rem; overflow: hidden; border-radius: 99px; background: #f0f0f7; }
.pv-bar__fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6366f1, #a855f7); transform-origin: left; }
.pv-bar__fill--green { background: linear-gradient(90deg, #25e089, #13b86c); }
.pv-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-top: 2.4rem; }
.pv-kpi { padding: 1.6rem 1.8rem; border-radius: 1.4rem; background: #f7f7fc; }
.pv-kpi__value { font-size: 3rem; font-weight: 600; line-height: 3.8rem; color: var(--ink-black); }
.pv-kpi__label { font-size: 1.3rem; line-height: 1.8rem; color: var(--ink-400); }

/* Conversación (burbujas de landing 3) */
.pv-thread { display: grid; gap: 1.4rem; width: 100%; max-width: 44rem; }
.pv-bubble { display: block; width: 88%; height: auto; filter: drop-shadow(0 1.6rem 2.4rem rgba(40, 36, 110, .12)); }
.pv-bubble--out { justify-self: end; }

/* Antes / después */
.pv-compare { display: grid; gap: 3.2rem; width: 100%; max-width: 40rem; }
.pv-compare img { display: block; width: 100%; height: auto; margin-top: 1.2rem; filter: drop-shadow(0 1.6rem 2.4rem rgba(20, 60, 40, .12)); }
.pv-compare .pv-compare__square { width: 84%; margin-inline: auto; }

/* Chats desordenados (landing 2) */
.pv-chaos { position: relative; width: 100%; max-width: 54rem; height: 46rem; margin-top: 4rem; }
.pv-lead {
  position: absolute;
  left: calc(var(--x) * .1rem);
  top: calc(var(--y) * .14rem);
  display: flex;
  align-items: center;
  gap: 1.2rem;
  width: 86%;
  padding: 1.3rem 1.8rem;
  border-radius: 1.4rem;
  background: #fff;
  box-shadow: 0 .4rem 1.6rem rgba(0, 0, 0, .14);
  rotate: var(--r);
}
.pv-lead__icon { flex: none; width: 2.2rem; height: 2.2rem; }
.pv-lead__avatar { flex: none; width: 4.4rem; height: 4.4rem; border-radius: 50%; object-fit: cover; }
.pv-lead__body { flex: 1; min-width: 0; }
.pv-lead__name { overflow: hidden; font-size: 1.5rem; font-weight: 600; line-height: 2rem; color: var(--ink); white-space: nowrap; text-overflow: ellipsis; }
.pv-lead__msg { overflow: hidden; font-size: 1.3rem; line-height: 1.8rem; color: #96989a; white-space: nowrap; text-overflow: ellipsis; }
.pv-lead__meta { display: grid; justify-items: end; gap: .2rem; flex: none; font-size: 1.2rem; line-height: 1.6rem; }
.pv-lead__badge { display: grid; place-items: center; min-width: 2.2rem; height: 2.2rem; padding: 0 .6rem; border-radius: 99px; background: #2563eb; font-weight: 700; color: #fff; }
.pv-lead__time { color: #96989a; }
.pv-lead__status { font-weight: 700; white-space: nowrap; }

.pv-shot { width: 100%; max-width: 40rem; margin-top: 3.2rem; }
.pv-shot img { display: block; width: 100%; height: auto; filter: drop-shadow(0 2rem 3rem rgba(20, 60, 40, .16)); }

/* ---------- Bloques con contenido de las landings ---------- */
.pd-block { margin-top: 10.4rem; }
.pd-block__head { max-width: 86rem; }
.pd-block__title { font-size: 3.4rem; font-weight: 500; line-height: 4.4rem; letter-spacing: -.02em; color: var(--ink-black); }
.pd-block__lead { margin-top: 1.4rem; font-size: 2rem; line-height: 3.2rem; color: var(--ink-600); }

/* Tres tarjetas */
.pd-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2.2rem; margin-top: 4rem; }
.pd-card { overflow: hidden; border-radius: 2.4rem; background: #f7f7fc; }
.pd-card__media {
  display: grid;
  place-items: center;
  height: 28rem;
  padding: 1.6rem;
  background: radial-gradient(70% 70% at 50% 45%, rgba(168, 85, 247, .14), rgba(168, 85, 247, 0) 70%), #f0f0fa;
}
.pd-card__media img { width: 100%; height: 100%; object-fit: contain; }
.pd-card__body { padding: 2.8rem 3.2rem 3.6rem; }
.pd-card--text { padding: 3.6rem 3.2rem 4rem; }
.pd-card__icon { display: block; width: 6.4rem; height: 6.4rem; margin-bottom: 2.4rem; fill: #6366f1; }
.pd-card:nth-child(2) .pd-card__icon { fill: #a855f7; }
.pd-card:nth-child(3) .pd-card__icon { fill: #13b86c; }
.pd-card__title { font-size: 2.2rem; font-weight: 600; line-height: 3rem; color: var(--ink-black); }
.pd-card__text { margin-top: 1rem; font-size: 1.7rem; line-height: 2.7rem; color: var(--ink-600); }

/* Tira de tarjetas-imagen */
.pd-strip {
  display: flex;
  gap: 2.2rem;
  align-items: center;
  margin-top: 3.2rem;
  padding: 4rem;
  border-radius: 2.4rem;
  background: radial-gradient(60% 120% at 0% 100%, rgba(99, 102, 241, .16), rgba(99, 102, 241, 0) 70%), radial-gradient(60% 120% at 100% 0%, rgba(37, 224, 137, .16), rgba(37, 224, 137, 0) 70%), #f7f7fc;
}
.pd-strip img { display: block; flex: var(--w) 1 0; min-width: 0; height: auto; }

/* Capturas de métricas */
.pd-shots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.2rem; margin-top: 4rem; }
.pd-shot {
  display: grid;
  align-content: center;
  gap: 2.4rem;
  margin: 0;
  padding: 4rem;
  border-radius: 2.4rem;
  background: radial-gradient(70% 90% at 50% 100%, rgba(237, 50, 55, .08), rgba(237, 50, 55, 0) 70%), #fbf7f7;
}
.pd-shot--wide { grid-column: 1 / -1; }
.pd-shot img { display: block; width: 100%; max-width: 42rem; height: auto; margin-inline: auto; }
.pd-shot--wide img { max-width: 78rem; }

/* Logos de integraciones */
.pd-logos { display: flex; flex-wrap: wrap; gap: 1.6rem; margin-top: 3.2rem; }
.pd-logos li {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 1.4rem 2.6rem 1.4rem 1.8rem;
  border-radius: 99px;
  background: #f7f7fc;
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--ink-strong);
}
.pd-logos img { width: 4.2rem; height: 3rem; object-fit: contain; }

/* Cierre */
.pd-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 4.8rem;
  margin-top: 10.4rem;
  padding: 6.4rem;
  overflow: hidden;
  border-radius: 3.2rem;
  background: radial-gradient(60% 90% at 100% 100%, rgba(168, 85, 247, .35), rgba(168, 85, 247, 0) 70%), var(--dark-grad);
  color: #fff;
}
.pd-banner__title { font-size: 4.4rem; font-weight: 500; line-height: 5.4rem; letter-spacing: -.02em; }
.pd-banner__title span { color: var(--green); }
.pd-banner__lead { margin-top: 2rem; font-size: 2rem; line-height: 3.2rem; color: rgba(255, 255, 255, .8); }
.pd-banner__list { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2.8rem; }
.pd-banner__list li { padding: .8rem 1.8rem; border: .1rem solid rgba(255, 255, 255, .22); border-radius: 99px; font-size: 1.6rem; line-height: 2.4rem; }
.pd-banner .pain-dialog__btn { margin-top: 3.6rem; }
.pd-banner__media { display: grid; place-items: center; }
.pd-banner__media img { display: block; width: 100%; max-width: var(--max, 60rem); height: auto; border-radius: 1.6rem; filter: drop-shadow(0 2.4rem 4rem rgba(0, 0, 0, .35)); }

/* Entrada de los elementos de los paneles cuando se abre el popup */
@media (prefers-reduced-motion: no-preference) {
  .pain-dialog [data-pv-in] {
    opacity: 0;
    transform: translateY(1.6rem);
    transition: opacity .5s ease calc(.25s + var(--d, 0s)), transform .9s cubic-bezier(.22, 1, .36, 1) calc(.25s + var(--d, 0s));
  }
  .pain-dialog .pv-bar__fill { transform: scaleX(0); transition: transform 1.1s cubic-bezier(.22, 1, .36, 1) calc(.45s + var(--d, 0s)); }
  .pain-dialog.is-open [data-pv-in] { opacity: 1; transform: none; }
  .pain-dialog.is-open .pv-bar__fill { transform: none; }
}

/* ---------- Tablet ---------- */
@media (max-width: 1099px) {
  .pain-dialog__panel { padding: 8rem 5.6rem 7.2rem; }
  .pain-dialog__close { margin: -5.6rem -3.2rem -5.4rem 0; }
  .pain-dialog__head { grid-template-columns: 1fr; gap: 0; }
  .pain-dialog__list { padding-top: 4.8rem; }
  .pain-dialog__visuals { grid-template-columns: 1fr; margin-top: 5.6rem; }
  .pv { height: auto; min-height: 52rem; }
  .pd-block, .pd-banner { margin-top: 7.2rem; }
  .pd-trio { grid-template-columns: 1fr; }
  .pd-strip { flex-direction: column; align-items: stretch; }
  .pd-strip img { flex: none; width: calc(var(--w) / 738 * 100%); max-width: 100%; }
  .pd-banner { grid-template-columns: 1fr; padding: 5.6rem 4.8rem; }
}

/* ---------- Mobile: hoja que sube desde abajo ---------- */
@media (max-width: 699px) {
  .pain-dialog { padding: 6rem 0 0; }
  .pain-dialog__panel {
    min-height: 100%;
    padding: 7.2rem 2.6rem 6rem;
    border-radius: 3.2rem 3.2rem 0 0;
    transform: translateY(12rem);
  }
  .pain-dialog__close { width: 5.2rem; height: 5.2rem; margin: -5.2rem -.6rem -5.2rem 0; }
  .pain-dialog__eyebrow { font-size: 1.8rem; }
  .pain-dialog__title { padding-right: 4rem; font-size: 3.6rem; line-height: 4.4rem; }
  .pain-dialog__lead { font-size: 2.2rem; line-height: 3.3rem; }
  .pain-dialog__actions { flex-direction: column; }
  .pain-dialog__btn { width: 100%; height: 7rem; font-size: 2.2rem; }
  .pain-dialog__list li { font-size: 2.1rem; line-height: 3rem; }
  .pv { min-height: 0; padding: 3.2rem 2rem; border-radius: 2rem; }
  .pv-card { padding: 2.4rem 2rem; }
  .pv-corner { top: 1.6rem; left: 1.6rem; }
  .pv-chaos { height: 50rem; margin-top: 4.8rem; }
  .pv-lead { left: calc(var(--x) * .05rem); width: 94%; padding: 1.1rem 1.4rem; }
  .pv-lead__avatar { width: 3.8rem; height: 3.8rem; }
  .pd-block__title { font-size: 2.8rem; line-height: 3.6rem; }
  .pd-block__lead { font-size: 2rem; line-height: 3rem; }
  .pd-card__media { height: 24rem; }
  .pd-card__text { font-size: 1.9rem; line-height: 2.9rem; }
  .pd-strip, .pd-shot { padding: 2.4rem; }
  .pd-shots { grid-template-columns: 1fr; }
  .pd-logos li { font-size: 1.9rem; }
  .pd-banner { padding: 4.4rem 2.6rem; border-radius: 2.4rem; }
  .pd-banner__title { font-size: 3.2rem; line-height: 4rem; }
}
