/* ====================================================================
   ASPharma — chat-widget.css
   ────────────────────────────────────────────────────────────────────
   SCOPE: capa conversacional alternativa al formulario modal.
          Reutiliza tokens del design-system (--brand-*, --palette-*,
          --text-*, --radius-*, --shadow-*, --sp-*) — no redefine :root.

   Prefijo de clases: .cw-*
   Z-index: 1000 (burbuja) / 1010 (panel)
            por debajo del modal Luxury (1100+).
   ==================================================================== */

/* ── BURBUJA FLOTANTE ─────────────────────────────────────────────── */

/* Burbuja flotante — círculo estilo chat estándar (WhatsApp/Messenger/Intercom).
   Patrón conocido por el usuario LATAM: redondo, solo ícono, esquina inferior
   derecha. Tamaño 60×60 desktop / 56×56 mobile — sobre el mínimo recomendado
   de touch target (48px iOS, 44px Material). */
.cw-bubble {
  position: fixed;
  /* max() con safe-area-inset garantiza espacio en iPhones con notch y
     Android con gesture areas. En navegadores sin soporte, env() resuelve
     a 0 y max() devuelve el valor base. */
  bottom: max(1.5rem, calc(env(safe-area-inset-bottom) + 0.5rem));
  right: max(1.5rem, calc(env(safe-area-inset-right) + 0.5rem));
  z-index: 1000;
  width: 64px;
  height: 64px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-primary);
  color: var(--content-on-brand);
  border: none;
  border-radius: 50%;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow:
    0 12px 32px -6px rgba(var(--palette-azure-700-rgb), 0.4),
    0 4px 12px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 220ms ease, box-shadow 220ms ease;
  -webkit-tap-highlight-color: transparent;
  /* Pulso suave al cargar — attractor visual, se autodetiene a los ~9s
     (3 iteraciones × 2.4s + delay 1.5s) para no ser molesto. */
  animation: cwBubbleAttract 2.4s ease-out 1.5s 3;
}

/* Aro de pulso decorativo — el "halo" característico de los chat triggers */
.cw-bubble::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(var(--brand-accent-rgb), 0.6);
  opacity: 0;
  animation: cwHaloPulse 2.4s ease-out 1.5s 3;
  pointer-events: none;
}

/* Notification dot dorado — "hay algo nuevo para vos" */
.cw-bubble::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand-accent);
  border: 2px solid var(--brand-primary);
  box-shadow: 0 0 0 0 rgba(var(--brand-accent-rgb), 0.5);
  animation: cwDotPulse 1.8s ease-in-out infinite;
}

@keyframes cwBubbleAttract {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

@keyframes cwHaloPulse {
  0%   { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.35); }
}

@keyframes cwDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--brand-accent-rgb), 0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(var(--brand-accent-rgb), 0); }
}

.cw-bubble:hover {
  background: var(--brand-primary-hover);
  transform: scale(1.05);
  box-shadow:
    0 16px 40px -6px rgba(var(--palette-azure-700-rgb), 0.5),
    0 6px 16px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.cw-bubble:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 4px;
}

.cw-bubble:active {
  transform: scale(0.98);
}

.cw-bubble__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 36px;
  color: rgb(var(--palette-teal-400-rgb));
}

/* Label legacy — ya no se muestra (lo dejamos por compatibilidad con el HTML) */
.cw-bubble__label {
  display: none;
}

/* Una vez que el usuario interactuó con la burbuja, quitamos el pulso y el
   dot dorado: ya cumplieron su rol de attractor. La clase se agrega en JS
   al primer openPanel(). */
.cw-bubble.cw-bubble--seen,
.cw-bubble.cw-bubble--seen::before {
  animation: none;
}
.cw-bubble.cw-bubble--seen::after {
  display: none;
}

/* Icono presente pero "quieto": sin atractor mientras hay una sección con CTA
   primary visible en el viewport (no compite con la conversión on-page).
   Reversible — JS la agrega/quita según la visibilidad de CTA — a diferencia
   de --seen, que es permanente tras la primera interacción. Solo apaga
   animación/decoración: no altera posición, tamaño ni layout del icono. */
.cw-bubble.cw-bubble--quiet,
.cw-bubble.cw-bubble--quiet::before {
  animation: none;
}
.cw-bubble.cw-bubble--quiet::after {
  display: none;
}

.cw-bubble[hidden],
.cw-panel[hidden] {
  display: none !important;
}

/* En móvil: burbuja ligeramente más chica (56×56) para no comerse el área
   de la pantalla. Breakpoint a 600px para capturar también phablets y
   phones en landscape, donde el "floating" no se ve bien. */
@media (max-width: 600px) {
  .cw-bubble {
    width: 60px;
    height: 60px;
    bottom: max(1rem, env(safe-area-inset-bottom));
    right: max(1rem, env(safe-area-inset-right));
  }
}

/* ── TEASER PILL (attractor pre-click) ─────────────────────────────
   Aparece a los ~6s junto a la burbuja (solo desktop). Cormorant italic,
   fondo claro con borde dorado y cola apuntando a la burbuja. */
.cw-teaser {
  position: fixed;
  bottom: calc(max(1.5rem, calc(env(safe-area-inset-bottom) + 0.5rem)) + 16px);
  right: calc(max(1.5rem, calc(env(safe-area-inset-right) + 0.5rem)) + 78px);
  z-index: 999;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  padding-right: 0.5rem;
  background: var(--surface-page);
  border: 1px solid rgba(var(--brand-accent-rgb), 0.35);
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-style: italic;
  font-weight: 400;
  color: var(--brand-primary);
  letter-spacing: 0.005em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow:
    0 8px 20px -6px rgba(var(--palette-azure-700-rgb), 0.25),
    0 2px 6px rgba(0, 0, 0, 0.06);
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 320ms ease, transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}
.cw-teaser[hidden] { display: none !important; }
.cw-teaser.cw-teaser--visible { opacity: 1; transform: translateX(0); }
.cw-teaser::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--surface-page);
  border-right: 1px solid rgba(var(--brand-accent-rgb), 0.35);
  border-top: 1px solid rgba(var(--brand-accent-rgb), 0.35);
}
.cw-teaser:hover {
  border-color: var(--brand-accent-hover);
  transform: translateX(-2px);
}
.cw-teaser:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 3px; }
.cw-teaser__label { display: inline-block; }
.cw-teaser__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(var(--palette-azure-500-rgb), 0.06);
  color: var(--content-muted);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.cw-teaser__close:hover {
  background: rgba(var(--palette-azure-500-rgb), 0.12);
  color: var(--brand-primary);
}

/* Modo "Continuar consulta": variante del teaser cuando hay una conversación
   guardada en curso. Acento dorado + prefijo ↻ para diferenciarlo del teaser
   de captación. */
.cw-teaser--resume {
  background: linear-gradient(135deg,
    rgba(var(--brand-accent-rgb), 0.18) 0%,
    var(--surface-page) 100%);
  border-color: rgba(var(--brand-accent-rgb), 0.5);
}
.cw-teaser--resume .cw-teaser__label {
  color: var(--brand-primary);
  font-weight: 500;
}
.cw-teaser--resume .cw-teaser__label::before {
  content: '↻ ';
  margin-right: 2px;
  color: var(--brand-accent-hover);
  font-weight: 500;
}

@media (max-width: 600px) {
  .cw-teaser { display: none !important; }
}

/* ── PANEL DEL CHAT ───────────────────────────────────────────────── */

/* Desktop (≥1024px): SIDEBAR full-height 420px anclado a la derecha. El sitio
   sigue navegable (en desktop NO bloqueamos el scroll del body). Animación solo
   por opacity: un transform residual sobre position:fixed deja un containing
   block que desplaza el panel tras animar. */
.cw-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  height: 100vh;
  height: 100dvh;
  z-index: 1010;
  width: 420px;
  max-width: 100vw;
  background: var(--surface-page);
  border: none;
  border-left: 1px solid rgba(var(--palette-azure-500-rgb), 0.08);
  border-radius: 16px 0 0 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    -28px 0 70px -10px rgba(var(--palette-azure-700-rgb), 0.40),
    -10px 0 28px rgba(0, 0, 0, 0.12),
    -1px 0 0 rgba(var(--palette-azure-700-rgb), 0.10);
  font-family: var(--font-body);
  color: var(--content-body);
  animation: cwSlideIn 280ms ease-out;
}

@keyframes cwSlideIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Tablet (768–1023px): panel flotante 380×620 — más cómodo que el sidebar
   full-height, que cubriría demasiado en estos viewports. */
@media (max-width: 1023px) {
  .cw-panel {
    top: auto;
    left: auto;
    bottom: max(1.5rem, calc(env(safe-area-inset-bottom) + 0.5rem));
    right: max(1.5rem, calc(env(safe-area-inset-right) + 0.5rem));
    width: min(380px, calc(100vw - 2rem - env(safe-area-inset-right) - env(safe-area-inset-left)));
    height: min(620px, calc(100vh - 3rem));
    border: 1px solid rgba(var(--palette-azure-500-rgb), 0.08);
    border-radius: 16px;
    box-shadow:
      0 24px 60px -12px rgba(var(--palette-azure-700-rgb), 0.35),
      0 8px 24px rgba(0, 0, 0, 0.08);
    animation: cwSlideUp 240ms cubic-bezier(0.16, 1, 0.3, 1);
  }
}

@keyframes cwSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Bloqueo de scroll del body SOLO en mobile/fullscreen: evita el "rubber band"
   y el scroll fantasma detrás del panel. En desktop/tablet NO se bloquea — el
   panel es complementario y el sitio sigue navegable. */
@media (max-width: 600px), (orientation: landscape) and (max-height: 480px) {
  body.cw-panel-open {
    overflow: hidden;
  }
}

/* Fullscreen en mobile (≤600px) y phones en landscape (height ≤480).
   Antes era 480px pero dejaba afuera phablets y devices con notch
   donde el "floating" se ve mal o queda cortado en el borde derecho. */
@media (max-width: 600px), (orientation: landscape) and (max-height: 480px) {
  .cw-panel {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: none;
    /* Padding interno para que el contenido no entre en la safe area
       (notch laterales en landscape iOS) */
    padding-right: env(safe-area-inset-right);
    padding-left: env(safe-area-inset-left);
  }
}

/* ── HEADER ────────────────────────────────────────────────────────── */

.cw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--brand-primary);
  color: var(--content-on-brand);
  border-bottom: 1px solid rgba(var(--brand-accent-rgb), 0.18);
}

.cw-header__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.cw-header__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(var(--brand-accent-rgb), 0.18);
  color: rgb(var(--palette-teal-400-rgb));
  flex-shrink: 0;
}

.cw-header__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cw-header__title {
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.25;
}

.cw-header__subtitle {
  font-size: 0.75rem;
  opacity: 0.78;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 1px;
}

.cw-header__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5ED27A;
  box-shadow: 0 0 0 3px rgba(94, 210, 122, 0.18);
  animation: cwPulse 2s ease-in-out infinite;
}

@keyframes cwPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

.cw-header__actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.cw-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--content-on-brand);
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 160ms ease, background 160ms ease;
}

.cw-icon-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.cw-icon-btn:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 1px;
}

/* ── STREAM DE MENSAJES ───────────────────────────────────────────── */

.cw-stream {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.875rem;
  background:
    linear-gradient(180deg,
      rgba(var(--brand-accent-rgb), 0.025) 0%,
      var(--surface-page) 80px);
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--palette-azure-500-rgb), 0.2) transparent;
}

.cw-stream::-webkit-scrollbar {
  width: 6px;
}

.cw-stream::-webkit-scrollbar-thumb {
  background: rgba(var(--palette-azure-500-rgb), 0.2);
  border-radius: 3px;
}

/* ── MENSAJES (burbujas) ──────────────────────────────────────────── */

.cw-msg {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.625rem;
  max-width: 100%;
  animation: cwMsgIn 220ms ease;
}

@keyframes cwMsgIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cw-msg--bot {
  align-items: flex-start;
}

.cw-msg--user {
  align-items: flex-end;
}

.cw-msg__bubble {
  display: inline-block;
  max-width: 88%;
  padding: 0.625rem 0.875rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.cw-msg--bot .cw-msg__bubble {
  background: rgba(var(--palette-azure-500-rgb), 0.05);
  color: var(--content-body);
  border-bottom-left-radius: 4px;
}

.cw-msg--user .cw-msg__bubble {
  background: var(--brand-primary);
  color: var(--content-on-brand);
  border-bottom-right-radius: 4px;
}

.cw-msg__sub {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--content-muted);
  line-height: 1.4;
}

.cw-msg--user .cw-msg__sub {
  text-align: right;
}

/* Indicador de "escribiendo..." */
.cw-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 0.875rem;
  background: rgba(var(--palette-azure-500-rgb), 0.05);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.cw-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--content-muted);
  opacity: 0.5;
  animation: cwBlink 1.2s ease-in-out infinite;
}

.cw-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.cw-typing__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes cwBlink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40%           { opacity: 1;   transform: scale(1); }
}

/* ── COMPOSER (área de input dinámica) ────────────────────────────── */

.cw-composer {
  border-top: 1px solid rgba(var(--palette-azure-500-rgb), 0.08);
  padding: 0.75rem 0.875rem 0.875rem;
  background: var(--surface-page);
}

.cw-composer:empty {
  display: none;
}

/* Composer bloqueado mientras el restart-chip está activo (confirmación). */
.cw-composer.cw-composer--locked {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.3);
}

/* ── RESTART INLINE CHIP (reemplaza el confirm() nativo) ───────────────
   Pill flotante sticky en el TOP del stream, cerca del botón ↻ del header.
   Layout vertical: pregunta arriba + dos botones de texto explícitos. */
.cw-restart-chip {
  align-self: center;
  position: sticky;
  top: 0.5rem;
  z-index: 5;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  margin: 0.5rem auto 0.75rem;
  padding: 0.75rem 1.5rem 0.625rem;
  background: var(--surface-page);
  border: 1px solid rgba(var(--brand-accent-rgb), 0.3);
  border-radius: 18px;
  color: var(--content-strong);
  box-shadow: 0 6px 16px -4px rgba(var(--palette-azure-700-rgb), 0.18);
  animation: cwRestartChipIn 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cwRestartChipIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cw-restart-chip__question {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--brand-primary);
  letter-spacing: 0.005em;
  text-align: center;
}
.cw-restart-chip__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.cw-restart-chip__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.875rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.cw-restart-chip__btn:hover { transform: scale(1.02); }
.cw-restart-chip__btn:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
/* "Sí, reiniciar" — acción destructiva (pierde la conversación): rojo suave. */
.cw-restart-chip__btn--yes {
  color: #DC2626;
  border-color: rgba(220, 38, 38, 0.25);
}
.cw-restart-chip__btn--yes:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.4);
}
/* "No, continuar" — acción segura (mantiene el estado): navy (default). */
.cw-restart-chip__btn--no {
  color: var(--brand-primary);
  border-color: rgba(var(--palette-azure-500-rgb), 0.2);
}
.cw-restart-chip__btn--no:hover {
  background: rgba(var(--palette-azure-500-rgb), 0.06);
  border-color: var(--brand-accent-hover);
}

/* Composer en modo cards: altura limitada + sticky question + scroll interno.
   Evita que sets grandes de opciones (ej. 8 tipos de proyecto) aplasten el
   stream y dejen la pregunta del bot fuera del viewport en mobile. */
.cw-composer.cw-composer--cards {
  display: flex;
  flex-direction: column;
  /* min(porcentaje, píxeles): en pantallas chicas limita por % (~mitad del
     panel); en grandes limita por px (no crece sin control). El stream
     siempre conserva al menos ~180px visibles. */
  max-height: min(50%, 340px);
  padding: 0;
}

/* En sidebar full-height (≥1024px): el composer cards reserva espacio para que
   header + stream + footer SIEMPRE entren (sin cortar el footer). 360px ≈
   header (~64) + stream mínimo (~200) + footer (~36) + margen. El stream
   mantiene min-height para mostrar saludo + pregunta. */
@media (min-width: 1024px) {
  /* Paso de cards en el sidebar full-height: el stream se ajusta a su contenido
     (los mensajes quedan pegados al header, sin hueco arriba) y el composer
     crece para ocupar el resto. Así la pregunta del bot queda justo encima de
     las cards: el sobrante de altura queda DENTRO del área de cards, no como
     espacio muerto entre la pregunta y las opciones. */
  .cw-panel--cards .cw-stream {
    flex: 0 1 auto;
    min-height: 0;
  }
  .cw-panel--cards .cw-composer.cw-composer--cards {
    flex: 1 1 auto;
    max-height: none;
  }
}

/* ── VARIANTE 7 — contraste extremo en el paso de cards ────────────────
   El composer en modo cards se vuelve un "marco" navy: la sticky-question
   queda sobre navy con texto blanco y el área de las cards es BLANCO PURO.
   Las cards quedan luminosas dentro del marco. Solo aplica con cards. */
.cw-composer.cw-composer--cards {
  background: var(--brand-primary);
  border-top: 1px solid rgba(var(--brand-accent-rgb), 0.2);
}
.cw-composer--cards .cw-sticky-question {
  background: var(--brand-primary);
  color: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: none;
}
.cw-composer--cards .cw-sticky-question::before {
  background: var(--brand-accent);
}
.cw-composer--cards .cw-cards-scroll {
  background: var(--surface-page);
}
.cw-composer--cards .cw-card {
  background: var(--surface-page);
  border: 1px solid rgba(var(--brand-accent-rgb), 0.22);
}
.cw-composer--cards .cw-card:hover {
  border-color: var(--brand-accent);
  background: rgba(var(--brand-accent-rgb), 0.04);
  box-shadow: 0 4px 12px -2px rgba(var(--palette-azure-700-rgb), 0.1);
}
.cw-composer--cards .cw-card__label { color: var(--brand-primary); }
.cw-composer--cards .cw-card__hint  { color: var(--content-muted); }

.cw-sticky-question {
  flex-shrink: 0;
  padding: 0.7rem 0.875rem 0.6rem;
  background: linear-gradient(180deg,
    rgba(var(--brand-accent-rgb), 0.08) 0%,
    rgba(var(--brand-accent-rgb), 0.03) 100%);
  border-bottom: 1px solid rgba(var(--palette-azure-500-rgb), 0.1);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--brand-primary);
  letter-spacing: 0.005em;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  /* Sombra hacia abajo para "elevar" la sticky cuando se hace scroll */
  box-shadow: 0 2px 4px -2px rgba(var(--palette-azure-500-rgb), 0.08);
}

.cw-sticky-question::before {
  content: '';
  flex-shrink: 0;
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--brand-accent);
}

.cw-cards-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.625rem 0.875rem 0.875rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--palette-azure-500-rgb), 0.2) transparent;
  /* Gradiente "fade out" sutil en el borde inferior — señal visual de
     scroll, sin tapar contenido. Funciona como affordance: el usuario ve
     que hay algo más abajo. */
  background:
    linear-gradient(to bottom, transparent calc(100% - 24px),
      rgba(var(--brand-accent-rgb), 0.06) 100%);
}

.cw-cards-scroll::-webkit-scrollbar {
  width: 6px;
}

.cw-cards-scroll::-webkit-scrollbar-thumb {
  background: rgba(var(--palette-azure-500-rgb), 0.2);
  border-radius: 3px;
}

/* Input row (text/email) */
.cw-input-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.cw-input {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 0.75rem;
  background: var(--surface-page);
  border: 1px solid rgba(var(--palette-azure-500-rgb), 0.18);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--content-body);
  transition: border-color 160ms ease, box-shadow 160ms ease;
  -webkit-appearance: none;
  appearance: none;
}

.cw-input:focus {
  outline: none;
  border-color: var(--brand-accent-hover);
  box-shadow: 0 0 0 3px rgba(var(--brand-accent-rgb), 0.15);
}

.cw-input::placeholder {
  color: var(--content-muted);
  opacity: 0.6;
}

.cw-textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  padding: 0.625rem 0.75rem;
  background: var(--surface-page);
  border: 1px solid rgba(var(--palette-azure-500-rgb), 0.18);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--content-body);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.cw-textarea:focus {
  outline: none;
  border-color: var(--brand-accent-hover);
  box-shadow: 0 0 0 3px rgba(var(--brand-accent-rgb), 0.15);
}

.cw-send-btn,
.cw-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem 1rem;
  background: var(--brand-primary);
  color: var(--content-on-brand);
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.cw-send-btn:hover:not(:disabled),
.cw-primary-btn:hover:not(:disabled) {
  background: var(--brand-primary-hover);
}

.cw-send-btn:active:not(:disabled),
.cw-primary-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.cw-send-btn:disabled,
.cw-primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cw-send-btn:focus-visible,
.cw-primary-btn:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

/* Meta / counter / errores */
.cw-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.375rem;
  font-size: 0.6875rem;
  color: var(--content-muted);
  min-height: 14px;
}

.cw-meta__count {
  font-variant-numeric: tabular-nums;
}

.cw-error {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: var(--palette-red-500);
}

.cw-error[hidden] {
  display: none;
}

/* ── CARDS (opciones tipo cards / quick replies) ──────────────────── */

.cw-cards {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.cw-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--surface-page);
  border: 1px solid rgba(var(--palette-azure-500-rgb), 0.18);
  border-radius: 10px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.cw-card:hover {
  border-color: var(--brand-accent-hover);
  background: rgba(var(--brand-accent-rgb), 0.04);
}

.cw-card:active {
  transform: scale(0.99);
}

.cw-card:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

.cw-card__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--content-strong);
  line-height: 1.3;
}

.cw-card__hint {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--content-muted);
  line-height: 1.35;
}

/* ── REVIEW (resumen final + consent) ─────────────────────────────── */

.cw-review {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.cw-review__rows {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(var(--palette-azure-500-rgb), 0.08);
  border-radius: 10px;
  overflow: hidden;
}

.cw-review__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  background: var(--surface-page);
  border: none;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 160ms ease;
}

.cw-review__row:hover {
  background: rgba(var(--brand-accent-rgb), 0.04);
}

.cw-review__label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--content-muted);
  flex-shrink: 0;
}

.cw-review__value {
  font-size: 0.8125rem;
  color: var(--content-strong);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.cw-consent {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.625rem;
  background: rgba(var(--brand-accent-rgb), 0.05);
  border-radius: 8px;
  border: 1px solid rgba(var(--brand-accent-rgb), 0.15);
}

.cw-consent__check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--brand-primary);
}

.cw-consent__label {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--content-body);
  cursor: pointer;
}

.cw-consent__link {
  color: var(--brand-accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── SUCCESS ──────────────────────────────────────────────────────── */

.cw-success {
  text-align: center;
  padding: 0.5rem 0.25rem;
}

.cw-success__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 0.625rem;
  border-radius: 50%;
  background: rgba(94, 210, 122, 0.12);
  color: #2A8C45;
}

.cw-success__title {
  font-family: var(--font-heading);
  font-size: 1.0625rem;
  font-weight: 400;
  color: var(--content-heading);
  margin: 0 0 0.375rem;
}

.cw-success__body {
  font-size: 0.8125rem;
  color: var(--content-body);
  line-height: 1.5;
  margin: 0 0 0.875rem;
}

/* Variante "aviso": la solicitud se recibió pero la confirmación no salió.
   Matiz bronce sutil (heads-up, no error) — coherente con la paleta luxury. */
.cw-success__body--warn {
  text-align: left;
  padding: 0.625rem 0.75rem;
  background: rgba(var(--brand-accent-rgb), 0.10);
  border-left: 3px solid var(--brand-accent);
  border-radius: 8px;
}

.cw-success__ref {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.6875rem;
  background: rgba(var(--palette-azure-500-rgb), 0.06);
  border-radius: 6px;
  color: var(--content-strong);
  margin-bottom: 0.875rem;
}

.cw-success__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.cw-ghost-btn {
  padding: 0.5rem 0.875rem;
  background: transparent;
  border: 1px solid rgba(var(--palette-azure-500-rgb), 0.2);
  border-radius: 8px;
  color: var(--content-body);
  font-family: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.cw-ghost-btn:hover {
  border-color: var(--brand-accent-hover);
  background: rgba(var(--brand-accent-rgb), 0.05);
}

/* ── ESCUDO DE VERIFICACIÓN (Cloudflare Turnstile OK) ─────────────────
   Vive en el footer, en un slot fijo que comparte con el bullet point.
   Reutiliza la clase .cl-verify del modal (mismo diseño bronce + animación
   pop): por default está invisible (opacity 0) y al validar se enciende
   (.is-on, vía JS), reemplazando al bullet. Como el escudo NO está junto al
   botón Enviar, éste queda full-width y no se redimensiona al validar. */

/* Botón Enviar a ancho completo en el paso de review. */
.cw-primary-btn--block {
  width: 100%;
  margin-top: 4px;
}

/* Microcopy de tranquilidad bajo el botón de envío (C3). */
.cw-reassure {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.6875rem;
  color: var(--content-muted);
  letter-spacing: 0.01em;
  line-height: 1.4;
}

/* Slot fijo: bullet y escudo apilados en la misma celda (grid 1/1), centrados.
   Al reemplazarse no desplaza el texto "ASPharma". El tamaño fijo (16px)
   reserva el espacio del escudo aunque por default solo se vea el bullet. */
.cw-footer__verify {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.cw-footer__verify > .cw-footer__brand-dot,
.cw-footer__verify > .cw-footer__shield {
  grid-area: 1 / 1;
}

/* El escudo hereda color bronce + animación pop de .cl-verify. line-height:0
   evita el espacio fantasma del inline-svg dentro del slot. */
.cw-footer__shield {
  line-height: 0;
}

.cw-footer__shield[hidden] {
  display: none;
}

/* ── FOOTER ────────────────────────────────────────────────────────── */

.cw-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.875rem;
  background: rgba(var(--palette-azure-500-rgb), 0.025);
  border-top: 1px solid rgba(var(--palette-azure-500-rgb), 0.06);
  font-size: 0.6875rem;
  color: var(--content-muted);
}

.cw-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--content-muted);
}

.cw-footer__brand-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brand-accent);
}

.cw-footer__privacy {
  color: var(--content-muted);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.cw-footer__privacy:hover {
  color: var(--brand-accent-hover);
  border-bottom-color: currentColor;
}

/* ── HIDDEN UTILITIES ─────────────────────────────────────────────── */

.cw-form-hidden {
  display: none;
}

.cw-honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.cw-turnstile-wrap {
  margin-top: 0.5rem;
}

/* ── REDUCED MOTION ───────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .cw-panel,
  .cw-msg,
  .cw-bubble,
  /* Pseudo-elementos del atractor de la burbuja: halo (::before → cwHaloPulse)
     y notification dot (::after → cwDotPulse). Sin esto seguían animando pese
     a la preferencia de movimiento reducido (B5). */
  .cw-bubble::before,
  .cw-bubble::after,
  .cw-teaser,
  .cw-card,
  .cw-send-btn,
  .cw-primary-btn,
  .cw-header__dot,
  .cw-typing__dot {
    animation: none !important;
    transition: none !important;
  }
}
