/* =========================================================
   Asistente virtual · Marisela
   ========================================================= */

/* ---------- Botón para abrir ---------- */
.va-launch {
  position: fixed; right: 20px; bottom: 96px; z-index: 61;
  width: 72px; height: 72px; padding: 0; border: 0; border-radius: 50%;
  background: #fff; box-shadow: 0 12px 30px rgba(61, 26, 102, .35), 0 0 0 4px #fff, 0 0 0 7px var(--purple-500);
  transition: transform .25s;
}
.va-launch:hover { transform: scale(1.06); }
.va-launch__clip img { transform: none; }
@keyframes vaBreath { 0%, 100% { transform: scale(1.12) translateY(0) rotate(0); } 50% { transform: scale(1.135) translateY(-1px) rotate(-.6deg); } }
.va-launch img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; transform: scale(1.12); }
.va-launch__clip { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.va-launch__dot { position: absolute; right: 2px; bottom: 4px; width: 16px; height: 16px; border-radius: 50%; background: #22c55e; border: 3px solid #fff; }
.va-launch__bubble {
  position: absolute; right: 88px; top: 50%; transform: translate(10px, -50%); white-space: nowrap;
  background: #fff; color: var(--ink); font-weight: 700; font-size: .9rem; padding: 10px 16px; border-radius: 16px 16px 4px 16px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .35s cubic-bezier(.2, .8, .2, 1);
}
.va-launch__bubble small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }
.va-launch.peek .va-launch__bubble, .va-launch:hover .va-launch__bubble { opacity: 1; transform: translate(0, -50%); }
.va-open .va-launch, .va-open .wa-float { opacity: 0; pointer-events: none; transform: scale(.6); }
.wa-float { transition: transform .25s, opacity .25s; }

/* ---------- Panel ---------- */
.va {
  position: fixed; right: 20px; bottom: 20px; z-index: 70;
  width: 390px; height: min(680px, calc(100vh - 40px)); height: min(680px, calc(100dvh - 40px));
  display: flex; flex-direction: column; background: #fff; border-radius: 26px; overflow: hidden;
  box-shadow: 0 30px 90px rgba(42, 17, 69, .35), 0 0 0 1px rgba(91, 42, 145, .08);
  transform-origin: bottom right; transform: translateY(20px) scale(.92); opacity: 0; visibility: hidden;
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .25s, visibility .35s;
  font-family: var(--f-body);
}
.va.open { transform: none; opacity: 1; visibility: visible; }

/* Encabezado con avatar circular */
.va__stage {
  --h: 262px;
  position: relative; height: var(--h); flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 14px 16px 16px;
  background: radial-gradient(circle at 50% 30%, #8e4fd1, transparent 65%), linear-gradient(160deg, var(--purple-700), var(--purple-900));
  color: #fff;
}
.va__avatar {
  --lvl: 0;
  position: relative; width: 168px; height: 168px; flex: none; border-radius: 50%;
  box-shadow: 0 0 0 4px #fff, 0 14px 34px rgba(0, 0, 0, .35);
}
.va__avatar::before {           /* aro que "late" con tu voz */
  content: ""; position: absolute; inset: -7px; border-radius: 50%;
  border: 4px solid var(--yellow); opacity: 0; transform: scale(calc(1 + var(--lvl) * .07));
  transition: opacity .25s, transform 90ms linear;
}
.va.speaking .va__avatar::before { opacity: .95; }
.va.listening .va__avatar::before { opacity: .9; border-color: #ff8fb3; animation: vaListen 1.2s ease-in-out infinite; }
@keyframes vaListen { 50% { transform: scale(1.06); } }
.va__face { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; background: #d9c9ef; }
.va__head { position: absolute; inset: 0; }
.va__face img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 110ms ease;
}
.va__face img.on { opacity: 1; }
.va__vid {                      /* video de la respuesta (cuando existe) */
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 35%;
  opacity: 0; transition: opacity .25s ease; pointer-events: none; background: transparent;
}
.va__face.has-video .va__vid { opacity: 1; }
.va__who { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.va__who b { font-family: var(--f-display); font-size: 1.2rem; line-height: 1.1; }
.va__status { display: flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 600; color: rgba(255, 255, 255, .85); }
.va__live { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .25); flex: none; }
.va.listening .va__live { background: #ff8fb3; box-shadow: 0 0 0 3px rgba(255, 143, 179, .3); }
.va__btns { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.va__icon {
  width: 34px; height: 34px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .14); color: #fff; transition: background .2s, transform .2s;
}
.va__icon:hover { background: rgba(255, 255, 255, .26); transform: scale(1.06); }
.va__icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.va__icon .off { display: none; }
.va.muted .va__icon .on-ico { display: none; }
.va.muted .va__icon .off { display: block; }

/* Ondas de "hablando" */
.va__wave { display: inline-flex; gap: 3px; align-items: center; height: 16px; margin-left: 2px; opacity: 0; transition: opacity .2s; }
.va.speaking .va__wave { opacity: 1; }
.va__wave i { width: 3px; height: 4px; border-radius: 3px; background: var(--yellow); transition: height 80ms; }
.va-tap { display: inline-block; margin-top: 8px; border: 0; padding: 7px 12px; border-radius: 99px; background: var(--yellow); color: var(--purple-900); font-weight: 800; font-size: .82rem; }

/* Conversación */
.va__log { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 10px; background: linear-gradient(#faf7ff, #fff 120px); overscroll-behavior: contain; }
.va-msg { max-width: 86%; padding: 10px 14px; border-radius: 18px; font-size: .93rem; line-height: 1.45; animation: vaIn .3s cubic-bezier(.2, .8, .2, 1); }
.va-msg--bot { align-self: flex-start; background: #fff; color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: 0 2px 8px rgba(61, 26, 102, .05); }
.va-msg--user { align-self: flex-end; background: var(--purple-700); color: #fff; border-bottom-right-radius: 6px; }
.va-msg--typing { display: flex; gap: 4px; padding: 14px 16px; }
.va-msg--typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--purple-500); animation: vaDot 1s infinite; }
.va-msg--typing i:nth-child(2) { animation-delay: .15s; } .va-msg--typing i:nth-child(3) { animation-delay: .3s; }
@keyframes vaDot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes vaIn { from { opacity: 0; transform: translateY(8px); } }
.va-msg .va-wa {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 8px 14px; border-radius: 99px;
  background: var(--wa); color: #0b3d1f; font-weight: 800; font-size: .85rem; text-decoration: none;
}
.va-msg .va-wa svg { width: 16px; height: 16px; fill: currentColor; }
.va-replay { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; border: 0; background: none; padding: 0; color: var(--purple-600); font-size: .78rem; font-weight: 700; }
.va-replay svg { width: 13px; height: 13px; fill: currentColor; }

/* Sugerencias */
.va__suggest { padding: 4px 16px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.va-chip {
  border: 0; background: var(--purple-50); color: var(--purple-800); font-weight: 700; font-size: .82rem; text-align: left;
  padding: 7px 12px; border-radius: 99px; box-shadow: inset 0 0 0 1.5px var(--purple-100); transition: .2s;
}
.va-chip:hover { background: var(--purple-100); box-shadow: inset 0 0 0 1.5px var(--purple-500); }
.va-chip--all { background: #fff; color: var(--teal-700); box-shadow: inset 0 0 0 1.5px var(--teal-100); }

/* Todas las preguntas */
.va__all { position: absolute; inset: 262px 0 0 0; background: #fff; z-index: 3; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
.va__all.open { transform: none; }
.va__all-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); font-family: var(--f-display); font-weight: 800; color: var(--purple-900); }
.va__all-head button { border: 0; background: var(--purple-50); color: var(--purple-700); border-radius: 99px; padding: 6px 12px; font-weight: 700; font-size: .82rem; }
.va__all-list { overflow-y: auto; padding: 8px 16px 20px; overscroll-behavior: contain; }
.va__all-list h5 { margin: 14px 0 8px; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.va__all-list .va-chip { display: block; width: 100%; margin-bottom: 6px; border-radius: 12px; padding: 10px 12px; }

/* Escribir */
.va__form { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: #fff; flex: none; }
.va__form input {
  flex: 1; min-width: 0; font: inherit; font-size: .95rem; padding: 11px 14px; border-radius: 99px; border: 1.5px solid var(--line); background: #fdfbff;
}
.va__form input:focus { outline: none; border-color: var(--purple-500); box-shadow: 0 0 0 4px var(--purple-100); }
.va__form button { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--purple-700); color: #fff; display: grid; place-items: center; }
.va__form button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.va__form .va__mic { background: var(--purple-50); color: var(--purple-700); box-shadow: inset 0 0 0 1.5px var(--purple-100); position: relative; }
.va__form .va__mic[hidden] { display: none; }
.va__form .va__mic.on { background: #e5527f; color: #fff; box-shadow: none; }
.va__form .va__mic.on::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid #e5527f; animation: vaMic 1.2s infinite; }
@keyframes vaMic { from { transform: scale(1); opacity: .8; } to { transform: scale(1.4); opacity: 0; } }

@media (max-width: 640px) {
  .va { right: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; }
  .va__stage { --h: 236px; padding-top: calc(14px + env(safe-area-inset-top)); }
  .va__avatar { width: 150px; height: 150px; }
  .va__all { top: 236px; }
  .va-launch { width: 62px; height: 62px; right: 20px; bottom: 92px; }
  .va-launch__bubble { right: 76px; }
}
@media (max-height: 700px) and (min-width: 641px) {
  .va__stage { --h: 210px; }
  .va__avatar { width: 130px; height: 130px; }
  .va__all { top: 210px; }
}
@media (prefers-reduced-motion: reduce) {
  .va, .va__all, .va-launch { transition: none; }
}
