/*
  Asistente de la web (apps/website/templates/website/theme/_assistant.html · static/website/assistant.js): el dibujo
  de la empresa abajo a la derecha con su bocadillo («¿Te ayudo?») y el chat como un bocadillo grande que le sale a
  él, con el trazo de tinta del tema. Mensajes del asistente en el color de la marca muy suave y los del cliente en
  tinta; botones de respuesta rápida como pastillas, enlaces como botones y tarjetas de producto o actividad con foto.
  En el móvil el bocadillo ocupa casi toda la pantalla y el dibujo se queda pequeño abajo. Con «reducir movimiento»,
  quieto (site.css). Usa los colores del tema (site.css: --c-ink, --c-brand…).
*/
.wchat { --wchat-mascot: 104px; --wchat-gap: 16px; position: fixed; right: var(--wchat-gap); bottom: var(--wchat-gap); z-index: 80; font-family: var(--f-body); }

/* El dibujo y su bocadillo ------------------------------------------------- */
.wchat-launcher {
  position: relative; display: block; width: var(--wchat-mascot); height: var(--wchat-mascot); padding: 0; border: 0;
  background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.wchat-launcher[hidden] { display: none; }
.wchat-mascot {
  display: block; width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%;
  filter: drop-shadow(0 8px 14px rgba(29, 29, 27, 0.18)); transform-origin: 50% 100%;
  animation: site-float 5s ease-in-out infinite; transition: transform 300ms var(--ease-bounce);
}
.wchat-launcher:hover .wchat-mascot { animation-play-state: paused; transform: translateY(-4px) rotate(-4deg) scale(1.04); }
.wchat-launcher:focus-visible { outline: 3px solid var(--c-ink); outline-offset: 4px; border-radius: 50%; }
.wchat-mascot-icon {
  display: grid; place-items: center; width: 68px; height: 68px; margin: auto 0 0 auto; border: 2px solid var(--c-ink);
  border-radius: 50%; background: var(--c-brand); color: var(--c-ink);
}
.wchat-bubble {
  position: absolute; right: calc(var(--wchat-mascot) - 14px); bottom: calc(var(--wchat-mascot) - 18px);
  padding: 8px 14px; border: 2px solid var(--c-ink); border-radius: 18px 18px 4px 18px; background: var(--c-white);
  color: var(--c-ink); font: 700 15px/1.2 var(--f-display); letter-spacing: -0.01em; white-space: nowrap;
  box-shadow: 3px 3px 0 var(--c-ink); transform-origin: 100% 100%;
  animation: wchat-pop 450ms var(--ease-bounce) 1.2s both;
}
.wchat.is-open .wchat-bubble { opacity: 0; transform: scale(0.6); pointer-events: none; transition: opacity 150ms ease, transform 150ms ease; animation: none; }
@keyframes wchat-pop { from { opacity: 0; transform: scale(0.4) translate(10px, 10px); } to { opacity: 1; transform: none; } }

/* El chat: un bocadillo que le sale al dibujo ------------------------------- */
.wchat-panel {
  position: fixed; right: var(--wchat-gap); bottom: calc(var(--wchat-gap) + var(--wchat-mascot) + 18px);
  display: flex; flex-direction: column; width: min(392px, calc(100vw - 2 * var(--wchat-gap)));
  height: min(620px, calc(100vh - var(--wchat-mascot) - 64px)); height: min(620px, calc(100dvh - var(--wchat-mascot) - 64px));
  border: 2px solid var(--c-ink); border-radius: var(--r-md); background: var(--c-white); color: var(--c-ink);
  box-shadow: 5px 5px 0 var(--c-ink), 0 24px 48px rgba(29, 29, 27, 0.16);
  transform-origin: calc(100% - 46px) 100%; animation: wchat-open 320ms var(--ease-bounce);
}
.wchat-panel[hidden] { display: none; }
/* el pico del bocadillo, hacia la cabeza del dibujo */
.wchat-panel::after {
  content: ""; position: absolute; right: calc(var(--wchat-mascot) / 2 - 11px); bottom: -12px; width: 22px; height: 22px;
  border: solid var(--c-ink); border-width: 0 2px 2px 0; border-bottom-right-radius: 4px; background: var(--c-white);
  transform: rotate(45deg);
}
@keyframes wchat-open { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: none; } }

.wchat-head { display: flex; align-items: center; gap: 4px; padding: 14px 10px 12px 20px; border-bottom: 2px solid var(--c-ink); }
.wchat-head-text { flex: 1; min-width: 0; }
.wchat-title { margin: 0; font: 800 18px/1.1 var(--f-display); letter-spacing: -0.02em; }
.wchat-sub { margin: 2px 0 0; font-size: 13px; color: var(--c-graphite); }
.wchat-icon-button {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--c-ink); cursor: pointer;
}
.wchat-icon-button:hover { background: color-mix(in srgb, var(--c-ink) 8%, transparent); }

.wchat-log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px;
  padding: 16px 14px 18px; scroll-behavior: smooth;
}
.wchat-msg { display: flex; flex-direction: column; gap: 8px; max-width: 92%; }
.wchat-msg.is-new { animation: site-drop 220ms ease both; }
.wchat-msg-bot { align-self: flex-start; }
.wchat-msg-user { align-self: flex-end; align-items: flex-end; }
.wchat-text {
  margin: 0; padding: 10px 14px; border-radius: 18px 18px 18px 6px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere;
  background: color-mix(in srgb, var(--c-brand) 12%, var(--c-white));
}
.wchat-text strong { font-weight: 700; }
.wchat-msg-user .wchat-text { border-radius: 18px 18px 6px 18px; background: var(--c-ink); color: var(--c-white); }

/* Respuestas rápidas, enlaces y tarjetas */
.wchat-buttons, .wchat-links { display: flex; flex-wrap: wrap; gap: 6px; }
.wchat-choice {
  min-height: 36px; padding: 6px 14px; border: 1.5px solid var(--c-ink); border-radius: var(--r-pill); background: var(--c-white);
  color: var(--c-ink); font: 600 14px/1.25 var(--f-body); text-align: left; cursor: pointer;
  transition: background 150ms ease, transform 200ms var(--ease-bounce);
}
.wchat-choice:hover:not(:disabled) { background: color-mix(in srgb, var(--c-accent) 55%, var(--c-white)); transform: translateY(-1px); }
.wchat-choice:disabled { border-color: var(--c-line); color: var(--c-graphite); cursor: default; }
.wchat-choice.is-chosen { border-color: var(--c-ink); background: var(--c-ink); color: var(--c-white); }
.wchat-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border-radius: var(--r-pill);
  background: var(--c-ink); color: var(--c-white); font-size: 14px; font-weight: 600; text-decoration: none;
}
.wchat-link:hover { background: var(--c-brand-ink); }
.wchat-link-whatsapp { background: #1f8f4e; }
.wchat-link-whatsapp:hover { background: #17733e; }
.wchat-cards { display: grid; gap: 6px; width: 100%; }
.wchat-card {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 12px; padding: 8px 12px 8px 8px;
  border: 1px solid var(--c-line); border-radius: 16px; background: var(--c-white); color: var(--c-ink); text-decoration: none;
  transition: border-color 150ms ease, transform 200ms var(--ease-bounce);
}
a.wchat-card:hover { border-color: var(--c-ink); transform: translateY(-1px); }
.wchat-thumb {
  display: grid; place-items: center; width: 56px; height: 56px; overflow: hidden; border-radius: 12px;
  background: color-mix(in srgb, var(--c-accent) 35%, var(--c-white)); font: 800 20px var(--f-display);
}
.wchat-thumb img { width: 100%; height: 100%; object-fit: cover; }
.wchat-card-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.wchat-card-title { font-size: 14px; font-weight: 700; line-height: 1.3; }
.wchat-card-meta { font-size: 13px; line-height: 1.35; color: var(--c-graphite); }
.wchat-card-price { font-size: 14px; font-weight: 700; }
.wchat-card-badge { justify-self: start; width: fit-content; padding: 1px 8px; border-radius: var(--r-pill); background: var(--c-sun); font-size: 12px; font-weight: 700; }

/* Formulario dentro del chat (número y email) */
.wchat-form { display: grid; gap: 8px; width: min(100%, 300px); padding: 12px; border: 1.5px solid var(--c-ink); border-radius: 18px; background: var(--c-white); }
.wchat-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.wchat-form input {
  height: 40px; padding: 0 12px; border: 1.5px solid var(--c-line); border-radius: 12px; background: var(--c-white);
  font: 500 15px var(--f-body); color: var(--c-ink);
}
.wchat-form input:focus { border-color: var(--c-ink); outline: none; }
.wchat-form button { justify-self: start; min-height: 38px; padding: 0 18px; border: 0; border-radius: var(--r-pill); background: var(--c-ink); color: var(--c-white); font: 600 14px var(--f-body); cursor: pointer; }
.wchat-form button:disabled { opacity: 0.5; cursor: default; }

/* Escribiendo… */
.wchat-typing { display: inline-flex; gap: 4px; padding: 14px 16px; border-radius: 18px 18px 18px 6px; background: color-mix(in srgb, var(--c-brand) 12%, var(--c-white)); }
.wchat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--c-ink); opacity: 0.35; animation: wchat-dot 1s ease-in-out infinite; }
.wchat-typing span:nth-child(2) { animation-delay: 0.15s; }
.wchat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes wchat-dot { 0%, 100% { opacity: 0.35; transform: none; } 50% { opacity: 1; transform: translateY(-3px); } }

/* Escribir y el pie */
.wchat-composer { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 14px; border-top: 2px solid var(--c-ink); }
.wchat-composer input {
  flex: 1; min-width: 0; height: 44px; padding: 0 16px; border: 1.5px solid var(--c-line); border-radius: var(--r-pill);
  background: var(--c-canvas); font: 500 16px var(--f-body); color: var(--c-ink);
}
.wchat-composer input:focus { border-color: var(--c-ink); outline: none; }
.wchat-send {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: var(--c-brand); color: var(--c-ink); cursor: pointer; transition: transform 200ms var(--ease-bounce);
}
.wchat-send:hover { transform: scale(1.06); }
.wchat-foot { margin: 0; padding: 0 16px 12px; font-size: 12px; line-height: 1.4; color: var(--c-graphite); }
.wchat-foot a { color: inherit; font-weight: 600; }

/* Móvil: el bocadillo ocupa casi toda la pantalla y el dibujo se queda pequeño abajo a la derecha */
@media (max-width: 560px) {
  .wchat { --wchat-mascot: 76px; --wchat-gap: 10px; }
  .wchat-bubble { font-size: 14px; padding: 7px 12px; }
  .wchat-panel {
    left: var(--wchat-gap); top: var(--wchat-gap); width: auto; height: auto;
    bottom: calc(var(--wchat-gap) + var(--wchat-mascot) + 14px);
  }
}

/* Móvil o pantalla baja: las sugerencias en una sola fila de pastillas pequeñas que se desliza de lado (no tapan la
   conversación) y, de las ya contestadas, solo la elegida */
@media (max-width: 560px), (max-height: 720px) {
  .wchat-msg:has(.wchat-buttons) { max-width: 100%; }
  .wchat-buttons {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    margin-right: -14px; padding: 2px 28px 2px 0;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .wchat-buttons::-webkit-scrollbar { display: none; }
  .wchat-choice { flex: none; min-height: 32px; padding: 4px 12px; font-size: 13px; white-space: nowrap; }
  .wchat-choice:disabled:not(.is-chosen) { display: none; }
  .wchat-buttons:not(:has(.wchat-choice:not(:disabled), .is-chosen)) { display: none; }
}
