/* =========================================================
   WhatsApp en tiempo real — vista previa del mensaje mientras se completa
   un formulario de contacto. Recurso compartido de Arbolia (nació en
   L&L Servicios, 2026-09-28). Colores de marca vía variables:
     --wa-accent        color del chip elegido y del pulso del botón
     --wa-accent-rgb    el mismo color en "r, g, b" (para el pulso)
     --wa-chip-bg / --wa-chip-border / --wa-muted
   ========================================================= */

/* Chips de opción (radio) con tilde que aparece con un saltito. */
.wa-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.wa-chip { position: relative; cursor: pointer; }
.wa-chip input { position: absolute; opacity: 0; pointer-events: none; }
.wa-chip span {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--wa-chip-border, rgba(0, 0, 0, 0.12));
  background: var(--wa-chip-bg, #faf7f2);
  font-size: 0.86rem;
  font-weight: 500;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.wa-chip:hover span { border-color: var(--wa-accent, #C1602A); }
.wa-chip input:checked + span { background: var(--wa-accent, #C1602A); border-color: var(--wa-accent, #C1602A); color: #fff; }
.wa-chip input:focus-visible + span { outline: 2px solid var(--wa-accent, #C1602A); outline-offset: 2px; }
.wa-chip span::before {
  content: '✓';
  display: inline-block;
  width: 0;
  opacity: 0;
  font-size: 0.8em;
  transform: scale(0);
  transition: width 0.2s ease, opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), margin 0.2s ease;
}
.wa-chip input:checked + span::before { width: 0.9em; margin-right: 6px; opacity: 1; transform: scale(1); }

/* Fondo del chat + burbuja verde del lado del que envía. */
.wa-preview {
  padding: 14px;
  border-radius: 14px;
  background:
    radial-gradient(circle, rgba(33, 28, 23, 0.05) 1px, transparent 1px) 0 0 / 14px 14px,
    #EFE7DC;
}
.wa-preview__label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--wa-muted, #6B6259);
}
.wa-preview__label::before { content: '● '; color: #25D366; }
.wa-bubble {
  position: relative;
  margin-left: auto;
  width: fit-content;
  max-width: 88%;
  min-width: 90px;
  padding: 8px 10px 6px 12px;
  border-radius: 12px 12px 4px 12px;
  background: #D9FDD3;
  color: #111B21;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
  animation: wa-bubble-in 0.3s ease both;
}
/* OJO: pre-line SOLO en el texto. Si va en la burbuja, los espacios del
   HTML entre spans se vuelven renglones vacíos arriba del mensaje. */
.wa-bubble__text { display: block; white-space: pre-line; }
.wa-bubble__meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-size: 0.68rem;
  color: #667781;
}
.wa-bubble__ticks { transition: color 0.3s ease; letter-spacing: -0.3em; padding-right: 0.3em; }
.wa-bubble.is-ready .wa-bubble__ticks { color: #53BDEB; }
.wa-bubble__typing { display: none; gap: 4px; padding: 6px 4px 2px; }
.wa-bubble.is-empty .wa-bubble__typing { display: inline-flex; }
.wa-bubble.is-empty .wa-bubble__text { display: none; }
.wa-bubble__typing i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #8696A0;
  animation: wa-typing 1.2s ease-in-out infinite;
}
.wa-bubble__typing i:nth-child(2) { animation-delay: 0.15s; }
.wa-bubble__typing i:nth-child(3) { animation-delay: 0.3s; }

/* El botón de enviar late suave cuando lo obligatorio está completo. */
[data-wa-form].is-ready [data-wa-submit] { animation: wa-ready 2.2s ease-in-out infinite; }

@keyframes wa-bubble-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes wa-typing { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes wa-ready {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--wa-accent-rgb, 193, 96, 42), 0.45); }
  50% { box-shadow: 0 0 0 10px rgba(var(--wa-accent-rgb, 193, 96, 42), 0); }
}

@media (prefers-reduced-motion: reduce) {
  .wa-bubble, .wa-bubble__typing i, [data-wa-form].is-ready [data-wa-submit] { animation: none; }
}
