/* ==========================================================================
   CHALLU AI — bot de preguntas frecuentes (encima del botón de WhatsApp)
   El HTML lo crea assets/js/challu.js; aquí solo va su aspecto.
   ========================================================================== */
.challu {
  --challu-right: clamp(16px, 4.6vw, 66px);
  --challu-bottom: calc(clamp(16px, 2.6vw, 34px) + 70px);
  --challu-w: clamp(84px, 8.4vw, 118px);
  position: fixed; right: var(--challu-right); bottom: var(--challu-bottom); z-index: 46;
  font-family: var(--f-body);
}

/* ---------- Botón flotante: robot + globo ---------- */
.challu__launcher {
  position: relative; display: block; width: var(--challu-w); margin-left: auto;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .28));
  animation: challu-float 3.6s var(--ease-in-out) infinite;
  transition: transform .4s var(--ease-out);
}
.challu__launcher img { width: 100%; }
.challu__launcher:hover { transform: scale(1.06) rotate(-3deg); }
@keyframes challu-float { 50% { translate: 0 -8px; } }

.challu__bubble {
  position: absolute; right: -6px; bottom: calc(100% - 4px);
  padding: 6px 14px 7px; min-width: 96px;
  background: #fff8ea; color: #000; border-radius: 16px;
  font-size: 13px; line-height: 1.05; text-align: center; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
  transform-origin: 30% 100%;
  animation: challu-pop .6s var(--ease-out) 1.2s both;
  pointer-events: none;
}
.challu__bubble::after { content: ""; position: absolute; left: 14px; top: calc(100% - 2px); border: 8px solid transparent; border-top-color: #fff8ea; border-left-width: 2px; }
@keyframes challu-pop { from { opacity: 0; transform: scale(.4) translateY(10px); } }
.challu.is-open .challu__bubble, .challu.is-quiet .challu__bubble { opacity: 0; transform: scale(.6); animation: none; transition: opacity .25s, transform .25s; }

/* ---------- Panel del chat ----------
   En laptop se abre al costado del robot, apoyado abajo, sin pasar el alto
   de la pantalla. En celular es un panel inferior a lo ancho. */
.challu__panel {
  position: fixed;
  right: calc(var(--challu-right) + var(--challu-w) + 14px);
  bottom: clamp(16px, 2.6vw, 34px);
  width: 340px;
  max-height: min(580px, calc(100vh - 130px));
  max-height: min(580px, calc(100dvh - 130px));
  display: flex; flex-direction: column;
  background: #fff; color: #000;
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  overflow: hidden;
  transform-origin: 100% 100%;
  opacity: 0; transform: translateY(16px) scale(.94); visibility: hidden;
  transition: opacity .3s, transform .45s var(--ease-out), visibility 0s .45s;
}
.challu.is-open .challu__panel { opacity: 1; transform: none; visibility: visible; transition: opacity .3s, transform .45s var(--ease-out); }

.challu__head { position: relative; flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 18px 46px 8px; }
.challu__head img { width: 30px; height: auto; }
.challu__name { font-family: var(--f-display); font-size: 22px; line-height: 1; text-transform: uppercase; }
.challu__close {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: var(--c-beige); color: #000;
  transition: background .3s, transform .3s;
}
.challu__close:hover { background: var(--c-red); color: #fff; transform: rotate(90deg); }
.challu__close svg { width: 11px; }

.challu__log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 12px;
  padding: 8px 18px 12px; scroll-behavior: smooth;
}
.challu__avatar { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--c-yellow); overflow: hidden; }
.challu__avatar img { width: 90%; margin-top: 12%; }
.challu__intro { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 6px 0 4px; }
.challu__intro[hidden] { display: none; }
.challu__avatar--big { width: 88px; height: 88px; }
.challu__intro p { max-width: 220px; font-family: var(--f-display); text-transform: uppercase; font-size: 13px; line-height: 1.15; }

.challu__msg { animation: challu-msg .4s var(--ease-out) both; }
.challu__msg--user {
  position: relative; align-self: flex-end; max-width: 86%;
  padding: 9px 16px; border-radius: 18px;
  background: var(--c-yellow); color: #000;
  font-family: var(--f-display); text-transform: uppercase; font-size: 14px; line-height: 1.15;
}
.challu__msg--user::after { content: ""; position: absolute; right: -6px; bottom: 4px; border: 7px solid transparent; border-left-color: var(--c-yellow); border-bottom-color: var(--c-yellow); transform: skewY(-20deg); }
.challu__msg--bot { display: flex; align-items: flex-start; gap: 8px; max-width: 100%; }
.challu__text {
  position: relative; padding: 10px 14px; border-radius: 14px; background: var(--c-beige);
  font-size: 13.5px; line-height: 1.35;
}
.challu__text::before { content: ""; position: absolute; left: -6px; top: 14px; border: 6px solid transparent; border-right-color: var(--c-beige); border-left-width: 0; }
.challu__text a { color: var(--c-red-deep); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.challu__text a:hover { color: #000; }
.challu__text strong { font-weight: 700; }
@keyframes challu-msg { from { opacity: 0; transform: translateY(8px); } }

.challu__typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.challu__typing i { width: 7px; height: 7px; border-radius: 50%; background: #8f8a84; animation: challu-dot 1s infinite; }
.challu__typing i:nth-child(2) { animation-delay: .15s; }
.challu__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes challu-dot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Preguntas frecuentes: grises como en el diseño; más chicas cuando ya hay conversación */
.challu__faq { display: grid; gap: 7px; margin-top: 2px; }
.challu__chip {
  display: block; width: 100%; padding: 9px 14px; border-radius: 14px;
  background: #f3f1ee; color: #8d8984;
  font-family: var(--f-display); text-transform: uppercase; font-size: 13.5px; line-height: 1.1; text-align: left;
  transition: background .3s, color .3s, transform .3s var(--ease-out);
}
.challu__chip:hover, .challu__chip:focus-visible { background: var(--c-yellow); color: #000; transform: translateX(3px); }
.challu.is-chatting .challu__faq { padding: 0 6px 0 54px; gap: 5px; }
.challu.is-chatting .challu__chip { padding: 6px 12px; font-size: 11.5px; }

.challu__form { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 18px 18px; }
.challu__input {
  flex: 1; min-width: 0; height: 44px; padding: 0 16px;
  border: 0; border-radius: 12px; background: var(--c-beige);
  font-family: var(--f-display); font-size: 17px; text-transform: uppercase; color: #000;
}
.challu__input::placeholder { color: #a8a199; }
.challu__input:focus { outline: 2px solid var(--c-yellow); outline-offset: 0; }
.challu__send {
  flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c-yellow); color: #fff;
  transition: background .3s, transform .3s var(--ease-out);
}
.challu__send:hover { background: var(--c-red-flag); transform: rotate(-12deg); }
.challu__send svg { width: 20px; margin: 1px 2px 0 0; }

.challu__wa {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  padding: 6px 12px; border-radius: 999px; background: var(--c-mint); color: #000 !important;
  font-weight: 700; text-decoration: none !important;
}
.challu__wa:hover { background: #000; color: #fff !important; }

/* Laptops bajas: panel un poco más compacto */
@media (max-height: 760px) and (min-width: 641px) {
  .challu__avatar--big { width: 64px; height: 64px; }
  .challu__chip { padding: 7px 12px; font-size: 12.5px; }
}

/* Celular: panel inferior a lo ancho; el robot y WhatsApp se esconden mientras está abierto */
@media (max-width: 640px) {
  .challu { --challu-bottom: calc(clamp(16px, 2.6vw, 34px) + 62px); --challu-w: 74px; }
  .challu__panel {
    left: 10px; right: 10px; bottom: 10px; width: auto;
    max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px);
    border-radius: 24px; transform-origin: 50% 100%;
  }
  .challu-open .challu__launcher, .challu-open .wa-float { opacity: 0; pointer-events: none; }
  .challu__name { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { .challu__launcher { animation: none; } }

/* === REVISIÓN 2: robot y WhatsApp más chicos en celular (el globo se mantiene) === */
@media (max-width: 640px) {
  .challu { --challu-w: 58px; --challu-bottom: 78px; }
  .challu__bubble { font-size: 11px; padding: 5px 10px; min-width: 0; }
  .wa-float { width: 50px; height: 50px; }
  .wa-float svg { width: 28px; height: 28px; }
}
/* === FIN REVISIÓN 2 === */

/* === REVISIÓN 5 (chat): botones más grandes para tocar con el dedo === */
@media (max-width: 960px), (pointer: coarse) {
  .challu__close { width: 40px; height: 40px; top: 10px; right: 10px; }
  .challu__chip, .challu.is-chatting .challu__chip { min-height: 44px; display: flex; align-items: center; }
  .challu__send { width: 44px; height: 44px; }
}
/* === FIN REVISIÓN 5 (chat) === */
