/* ================================================
   whatsapp.css — Chat de WhatsApp dentro de la web
   Panel de pre-chat: el visitante escribe aqui mismo
   y al enviar se abre WhatsApp con el mensaje listo.
   Sustituye al antiguo boton flotante `.wa`.
   ================================================ */

.wsp {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 160;           /* sobre el carrito flotante (150), bajo drawers (200+) */
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

/* En /catalogo el carrito ya ocupa la esquina (bottom:28 right:28), asi que
   el chat se apila encima en vez de taparlo. La clase la pone whatsapp.js
   solo si encuentra #cart-btn-wrap en la pagina. */
.wsp.wsp--stacked { right: 28px; bottom: 96px; }

/* ══════════════════════════════════════════════
   BOTON LANZADOR
══════════════════════════════════════════════ */
.wsp-btn {
  position: relative;
  width: 58px; height: 58px;
  border: none; border-radius: 50%;
  background: linear-gradient(145deg, #25D366 0%, #1DA851 100%);
  box-shadow: 0 10px 30px rgba(29,168,81,.45), 0 2px 8px rgba(15,23,42,.14);
  display: grid; place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform .25s cubic-bezier(.22,1,.36,1), box-shadow .25s ease;
}
.wsp-btn:hover  { transform: scale(1.07); box-shadow: 0 14px 38px rgba(29,168,81,.55); }
.wsp-btn:active { transform: scale(.96); }
.wsp-btn:focus-visible { outline: 3px solid #0EA5E9; outline-offset: 3px; }

/* Anillo de pulso — llama la atencion sin ser intrusivo */
.wsp-btn::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(37,211,102,.55);
  animation: wspPulse 2.8s ease-out infinite;
  pointer-events: none;
}
@keyframes wspPulse {
  0%   { transform: scale(1);    opacity: .7; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}
.wsp.is-open .wsp-btn::after { animation: none; }

/* Los dos iconos (WhatsApp / cerrar) se cruzan al abrir */
.wsp-ico {
  grid-area: 1 / 1;
  display: block;
  transition: transform .3s cubic-bezier(.22,1,.36,1), opacity .2s ease;
}
.wsp-ico--close    { transform: rotate(-90deg) scale(.5); opacity: 0; }
.wsp.is-open .wsp-ico--wa    { transform: rotate(90deg) scale(.5); opacity: 0; }
.wsp.is-open .wsp-ico--close { transform: rotate(0) scale(1);      opacity: 1; }

/* ══════════════════════════════════════════════
   GLOBO DE INVITACION (una vez por sesion)
══════════════════════════════════════════════ */
.wsp-teaser {
  position: absolute;
  right: 72px; bottom: 8px;
  width: max-content; max-width: 214px;
  background: #FFFFFF;
  color: #0F172A;
  font-size: 13.5px; line-height: 1.45; font-weight: 600;
  padding: 11px 30px 11px 14px;
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 12px 32px rgba(15,23,42,.16);
  border: 1px solid rgba(15,23,42,.07);
  animation: wspTeaserIn .45s cubic-bezier(.22,1,.36,1) both;
  cursor: pointer;
}
.wsp-teaser small { display: block; font-weight: 500; color: #64748B; font-size: 12px; margin-top: 2px; }
.wsp-teaser-x {
  position: absolute; top: 5px; right: 5px;
  width: 20px; height: 20px;
  border: none; background: transparent;
  color: #94A3B8; font-size: 15px; line-height: 1;
  cursor: pointer; border-radius: 50%;
}
.wsp-teaser-x:hover { background: #F1F5F9; color: #0F172A; }
@keyframes wspTeaserIn {
  from { opacity: 0; transform: translateX(10px) scale(.94); }
  to   { opacity: 1; transform: none; }
}

/* ══════════════════════════════════════════════
   PANEL DE CHAT
══════════════════════════════════════════════ */
.wsp-panel {
  position: absolute;
  right: 0; bottom: calc(100% + 14px);
  width: min(358px, calc(100vw - 40px));
  max-height: min(556px, calc(100vh - 150px));
  display: flex; flex-direction: column;
  background: #FFFFFF;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 28px 70px rgba(15,23,42,.26), 0 4px 16px rgba(15,23,42,.10);
  border: 1px solid rgba(15,23,42,.08);
  transform-origin: bottom right;
  animation: wspPanelIn .32s cubic-bezier(.22,1,.36,1) both;
}
.wsp-panel[hidden] { display: none; }
@keyframes wspPanelIn {
  from { opacity: 0; transform: translateY(14px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
.wsp-panel.is-closing { animation: wspPanelOut .2s ease forwards; }
@keyframes wspPanelOut {
  to { opacity: 0; transform: translateY(10px) scale(.96); }
}

/* ── Cabecera ── */
.wsp-head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 14px 14px 16px;
  background: linear-gradient(135deg, #075985 0%, #0369A1 55%, #0EA5E9 100%);
  color: #FFFFFF;
  position: relative;
}
.wsp-head::after {   /* brillo diagonal suave */
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(115deg, rgba(255,255,255,.16) 0%, transparent 45%);
  pointer-events: none;
}
.wsp-avatar {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 50%;
  background: #FFFFFF;
  object-fit: contain;
  padding: 3px;
  box-shadow: 0 2px 10px rgba(2,6,23,.22);
}
.wsp-head-txt { flex: 1; min-width: 0; position: relative; }
.wsp-name {
  font-size: 14.5px; font-weight: 800; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wsp-status {
  font-size: 11.5px; font-weight: 500;
  color: rgba(255,255,255,.86);
  display: flex; align-items: center; gap: 5px;
  margin-top: 1px;
}
.wsp-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ADE80; flex: 0 0 7px;
  box-shadow: 0 0 0 0 rgba(74,222,128,.6);
  animation: wspDot 2.2s ease-out infinite;
}
.wsp-dot.is-off { background: #FBBF24; animation: none; }
@keyframes wspDot {
  0%   { box-shadow: 0 0 0 0 rgba(74,222,128,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}
.wsp-close {
  position: relative;
  width: 30px; height: 30px; flex: 0 0 30px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #FFFFFF;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .2s ease;
}
.wsp-close:hover { background: rgba(255,255,255,.28); }

/* ── Hilo de mensajes ── */
.wsp-body {
  flex: 1;
  padding: 18px 14px 14px;
  overflow-y: auto;
  background-color: #F1F5F9;
  background-image: radial-gradient(rgba(15,23,42,.055) 1px, transparent 1px);
  background-size: 17px 17px;
  display: flex; flex-direction: column; gap: 9px;
  scrollbar-width: thin;
}
.wsp-body::-webkit-scrollbar { width: 6px; }
.wsp-body::-webkit-scrollbar-thumb { background: rgba(15,23,42,.18); border-radius: 3px; }

.wsp-msg {
  max-width: 86%;
  font-size: 13.8px; line-height: 1.5;
  padding: 10px 13px;
  border-radius: 4px 15px 15px 15px;
  background: #FFFFFF;
  color: #0F172A;
  box-shadow: 0 2px 8px rgba(15,23,42,.09);
  animation: wspMsgIn .34s cubic-bezier(.22,1,.36,1) both;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.wsp-msg--out {
  align-self: flex-end;
  background: #DCF8C6;
  border-radius: 15px 4px 15px 15px;
  white-space: pre-wrap;
}
.wsp-msg--sys {
  align-self: center;
  max-width: 100%;
  background: rgba(15,23,42,.06);
  box-shadow: none;
  color: #475569;
  font-size: 12px; font-weight: 600;
  text-align: center;
  border-radius: 10px;
  padding: 7px 12px;
}
.wsp-msg--sys a { color: #0369A1; font-weight: 700; }
.wsp-time { display: block; font-size: 10.5px; color: #94A3B8; margin-top: 3px; text-align: right; }
@keyframes wspMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Indicador "escribiendo…" */
.wsp-typing {
  align-self: flex-start;
  display: flex; gap: 4px; align-items: center;
  background: #FFFFFF;
  padding: 12px 14px;
  border-radius: 4px 15px 15px 15px;
  box-shadow: 0 2px 8px rgba(15,23,42,.09);
}
.wsp-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #94A3B8;
  animation: wspTyping 1.3s ease-in-out infinite;
}
.wsp-typing i:nth-child(2) { animation-delay: .18s; }
.wsp-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes wspTyping {
  0%, 60%, 100% { transform: translateY(0);    opacity: .45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ── Respuestas rapidas ── */
.wsp-quick { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 3px; }
.wsp-chip {
  border: 1px solid rgba(3,105,161,.28);
  background: #FFFFFF;
  color: #0369A1;
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .18s ease;
  animation: wspMsgIn .34s cubic-bezier(.22,1,.36,1) both;
}
.wsp-chip:hover { background: #0369A1; color: #FFFFFF; transform: translateY(-1px); }

/* ── Composer ── */
.wsp-form {
  display: flex; align-items: flex-end; gap: 9px;
  padding: 11px 12px;
  background: #FFFFFF;
  border-top: 1px solid rgba(15,23,42,.08);
}
.wsp-input {
  flex: 1;
  resize: none;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 18px;
  padding: 10px 14px;
  font-family: inherit; font-size: 13.8px; line-height: 1.45;
  color: #0F172A;
  background: #F8FAFC;
  max-height: 96px; min-height: 40px;
  transition: border-color .2s ease, background .2s ease;
}
.wsp-input::placeholder { color: #94A3B8; }
.wsp-input:focus {
  outline: none;
  border-color: rgba(3,105,161,.45);
  background: #FFFFFF;
}
.wsp-input.is-empty { animation: wspShake .4s ease; }
@keyframes wspShake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-5px); }
  75%     { transform: translateX(5px); }
}
.wsp-send {
  width: 40px; height: 40px; flex: 0 0 40px;
  border: none; border-radius: 50%;
  background: linear-gradient(145deg, #25D366 0%, #1DA851 100%);
  color: #FFFFFF;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(29,168,81,.38);
  transition: transform .2s ease, box-shadow .2s ease;
}
.wsp-send:hover  { transform: scale(1.08); box-shadow: 0 6px 20px rgba(29,168,81,.5); }
.wsp-send:active { transform: scale(.94); }

.wsp-note {
  padding: 0 14px 11px;
  background: #FFFFFF;
  font-size: 10.8px; line-height: 1.4; color: #94A3B8;
  text-align: center;
}

/* ══════════════════════════════════════════════
   MOVIL — el panel se comporta como hoja inferior
══════════════════════════════════════════════ */
@media (max-width: 480px) {
  .wsp { right: 16px; bottom: 16px; }
  .wsp.wsp--stacked { right: 16px; bottom: 84px; }
  .wsp-panel {
    position: fixed;
    right: 12px; left: 12px; bottom: 88px;
    width: auto;
    max-height: min(72vh, calc(100vh - 130px));
  }
  .wsp.wsp--stacked .wsp-panel { bottom: 152px; max-height: calc(100vh - 200px); }
  .wsp-teaser { max-width: min(210px, calc(100vw - 110px)); }
}

/* ══════════════════════════════════════════════
   ACCESIBILIDAD
══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .wsp-btn::after,
  .wsp-dot,
  .wsp-typing i { animation: none; }
  .wsp-panel,
  .wsp-panel.is-closing,
  .wsp-msg,
  .wsp-chip,
  .wsp-teaser { animation-duration: .01ms; }
  .wsp-btn, .wsp-send, .wsp-chip { transition: none; }
}

/* Impresion: el widget no aporta nada en papel */
@media print { .wsp { display: none !important; } }
