/* ============================================================
   CreceWeb · asistente de la página (solo staging por ahora)
   Paleta y tipografías heredadas de estilo.css (propuesta 5 "Escaparate").
   Sin zoom en CSS: las animaciones largas de fotos van solo en canvas.
   ============================================================ */

/* El div del HTML trae solo el id (sin la clase .cw-chatbot). Se aplica la
   misma regla a ambos: así el botón flota y el panel queda por encima de las
   capas del hero (z-index 1-4) y del botón de WhatsApp (z-index 80). */
#cw-chatbot, .cw-chatbot {
  position: fixed;
  right: 88px;
  bottom: 22px;
  z-index: 90;
  font-family: var(--font-body);
}

.cw-chatbot__btn {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--orange);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(255,107,53,.5), 0 12px 30px rgba(16,42,67,.28);
  animation: cw-latido 2.6s infinite;
  transition: transform .2s ease, background .2s ease;
}
@keyframes cw-latido {
  0%   { box-shadow: 0 0 0 0 rgba(255,107,53,.5), 0 12px 30px rgba(16,42,67,.28); }
  70%  { box-shadow: 0 0 0 14px rgba(255,107,53,0), 0 12px 30px rgba(16,42,67,.28); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,53,0), 0 12px 30px rgba(16,42,67,.28); }
}
.cw-chatbot__btn:hover { transform: translateY(-3px); background: #ff7d4f; }
.cw-chatbot__btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
.cw-chatbot__btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.cw-chatbot__btn .cw-ia { fill: currentColor; stroke: none; animation: cw-brillo 4s ease-in-out infinite; }
@keyframes cw-brillo { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.cw-chatbot__btn[aria-expanded="true"] svg { display: none; }
.cw-chatbot__cerrar-icono { display: none; }
.cw-chatbot__btn[aria-expanded="true"] .cw-chatbot__cerrar-icono { display: block; }

.cw-chatbot__panel {
  position: fixed;
  right: 16px;
  bottom: 88px;
  width: min(370px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 150px));
  max-height: min(520px, calc(100dvh - 150px));
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(16, 42, 67, .22);
  overflow: hidden;
  transform-origin: bottom right;
  animation: cw-chat-in .2s ease-out;
}
.cw-chatbot__panel[hidden] { display: none; }
@keyframes cw-chat-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.cw-chatbot__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ink);
  color: #fff;
}
.cw-chatbot__logo {
  width: 36px; height: 36px; flex: 0 0 auto;
  border-radius: 10px; background: var(--orange);
  display: grid; place-items: center; color: var(--ink);
  font-family: var(--font-head); font-weight: 800; font-size: .8rem;
}
.cw-chatbot__titulos { flex: 1; min-width: 0; }
.cw-chatbot__titulo { margin: 0; font-family: var(--font-head); font-size: .98rem; font-weight: 800; }
.cw-chatbot__sub { margin: 0; font-size: .74rem; color: rgba(255,255,255,.72); }
.cw-chatbot__cerrar {
  border: 0; background: transparent; color: #fff; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%; font-size: 1.3rem; line-height: 1;
}
.cw-chatbot__cerrar:hover { background: rgba(255,255,255,.14); }
.cw-chatbot__cerrar:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.cw-chatbot__mensajes {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cream);
  overscroll-behavior: contain;
}
.cw-chatbot__burbuja {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: .88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cw-chatbot__burbuja--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  color: var(--ink);
}
.cw-chatbot__burbuja--persona {
  align-self: flex-end;
  background: var(--orange);
  color: var(--ink);
  border-bottom-right-radius: 4px;
  font-weight: 600;
}
.cw-chatbot__escribiendo {
  align-self: flex-start;
  display: flex; gap: 4px; padding: 12px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
}
.cw-chatbot__escribiendo i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--slate);
  animation: cw-punto 1s infinite ease-in-out;
}
.cw-chatbot__escribiendo i:nth-child(2) { animation-delay: .15s; }
.cw-chatbot__escribiendo i:nth-child(3) { animation-delay: .3s; }
@keyframes cw-punto { 0%, 70%, 100% { opacity: .3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Tarjeta de bienvenida (solo al abrir desde el menú) ---------- */
.cw-bienvenida {
  align-self: stretch;
  padding: 16px;
  border: 1px solid rgba(31, 181, 143, .45);
  border-left: 4px solid var(--mint);
  border-radius: 16px;
  background: linear-gradient(140deg, #fff, var(--cream));
  box-shadow: 0 10px 24px rgba(16, 42, 67, .08);
  animation: cw-bienvenida-in .35s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes cw-bienvenida-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.cw-bienvenida--salir { animation: cw-bienvenida-out .26s ease-in both; }
@keyframes cw-bienvenida-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(.98); } }
.cw-bienvenida__icono {
  width: 38px; height: 38px; margin-bottom: 10px;
  border-radius: 12px; background: var(--ink); color: var(--orange);
  display: grid; place-items: center;
}
.cw-bienvenida__icono svg { width: 23px; height: 23px; fill: currentColor; }
.cw-bienvenida__titulo { margin: 0 0 8px; font-family: var(--font-head); font-size: .98rem; font-weight: 800; color: var(--ink); }
.cw-bienvenida__lista { margin: 0 0 14px; display: grid; gap: 6px; }
.cw-bienvenida__lista li { position: relative; padding-left: 18px; font-size: .82rem; line-height: 1.45; color: var(--slate); }
.cw-bienvenida__lista li::before { content: ""; position: absolute; left: 2px; top: .6em; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); }
.cw-bienvenida__btn {
  border: 0; border-radius: 999px; padding: 9px 16px;
  background: var(--orange); color: var(--ink);
  font-family: var(--font-head); font-weight: 800; font-size: .8rem; cursor: pointer;
}
.cw-bienvenida__btn:hover { background: #ff7d4f; }
.cw-bienvenida__btn:focus-visible { outline: 3px solid var(--orange-deep); outline-offset: 2px; }
/* Mientras la tarjeta está visible no estorban los chips de preguntas. */
.cw-bienvenida-activa .cw-chatbot__sugerencias { display: none; }

.cw-chatbot__sugerencias { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; background: var(--cream); }
.cw-chatbot__chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 6px 11px; font-size: .76rem; cursor: pointer;
}
.cw-chatbot__chip:hover { border-color: var(--orange); background: var(--cream); }
.cw-chatbot__chip:focus-visible { outline: 2px solid var(--orange-deep); outline-offset: 2px; }

.cw-chatbot__form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.cw-chatbot__input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 14px; font-size: .86rem; background: var(--cream); color: var(--ink);
}
.cw-chatbot__input:focus-visible { outline: 2px solid var(--orange-deep); outline-offset: 1px; }
.cw-chatbot__enviar {
  border: 0; border-radius: 999px; padding: 0 16px; min-width: 48px;
  background: var(--ink); color: #fff; font-weight: 800; cursor: pointer;
}
.cw-chatbot__enviar:hover { background: #173650; }
.cw-chatbot__enviar:disabled { opacity: .5; cursor: wait; }
.cw-chatbot__wa {
  display: block; text-align: center; font-size: .76rem; font-weight: 700;
  color: var(--orange-deep); padding: 0 12px 12px; background: #fff;
  text-decoration: underline; text-underline-offset: 2px;
}

@media (max-width: 420px) {
  #cw-chatbot, .cw-chatbot { right: 76px; bottom: 18px; }
  .cw-chatbot__btn { width: 50px; height: 50px; }
  .cw-chatbot__panel {
    right: 12px; bottom: 78px; width: calc(100vw - 24px);
    max-height: min(620px, calc(100dvh - 120px));
  }
  /* Tarjeta compacta: caben las tres frases y el botón sin scrollear. */
  .cw-bienvenida { padding: 12px 14px; border-radius: 14px; }
  .cw-bienvenida__icono { width: 32px; height: 32px; margin-bottom: 8px; }
  .cw-bienvenida__icono svg { width: 20px; height: 20px; }
  .cw-bienvenida__titulo { font-size: .9rem; margin-bottom: 6px; }
  .cw-bienvenida__lista { gap: 5px; margin-bottom: 10px; }
  .cw-bienvenida__lista li { font-size: .78rem; padding-left: 15px; }
  .cw-bienvenida__btn { position: sticky; bottom: 0; padding: 8px 14px; font-size: .76rem; box-shadow: 0 4px 12px rgba(16,42,67,.16); }
}
@media (prefers-reduced-motion: reduce) {
  .cw-chatbot__btn, .cw-chatbot__panel, .cw-chatbot__btn .cw-ia { transition: none; animation: none; }
  .cw-chatbot__escribiendo i { animation: none; opacity: 1; }
  /* Sin movimiento: la tarjeta se muestra directo y se cierra al instante
     desde el botón (el JS omite el temporizador en este modo). */
  .cw-bienvenida, .cw-bienvenida--salir { animation: none; }
}
