/* [4.104 · «veo a Brainmore trabajando»] Actividad del Agente viva, estados del Hero, siguiente acción, acciones. Clase en <html>
   (desde el primer cuadro: sin saltos). Movimiento: sólo transform/opacity; pausa fuera de pantalla, pestaña oculta y reduced-motion. */

/* ── Hero: la píldora de estado cambia de indicador según el hecho (sin rediseñar el banner) ── */
.agente-vivo .hero-estado { transition: background .2s ease, border-color .2s ease; width: 236px; justify-content: flex-start; } /* ancho fijo: cambiar de estado no mueve nada */
.agente-vivo .hero-estado > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.bt-onda { display: none; align-items: center; gap: 2px; height: 12px; }
.bt-onda i { display: block; width: 2.5px; height: 12px; border-radius: 2px; background: #67e8f9; transform: scaleY(.2); transform-origin: 50% 50%;
             transition: transform 80ms linear; will-change: transform; }
#agente[data-bt="escuchando"] .bt-onda { display: inline-flex; }
#agente[data-bt="escuchando"] .hero-estado .vivo { display: none; }
#agente[data-bt="escuchando"] .hero-estado { border-color: rgba(103,232,249,.55); background: rgba(34,184,217,.16); }
#agente[data-bt="investigando"] .hero-estado, #agente[data-bt="consultando"] .hero-estado { border-color: rgba(125,211,252,.45); background: rgba(37,99,235,.22); }
#agente[data-bt="investigando"] .hero-estado .vivo, #agente[data-bt="consultando"] .hero-estado .vivo { background: #7dd3fc; }
#agente[data-bt="investigando"] .hero-estado .vivo::after, #agente[data-bt="consultando"] .hero-estado .vivo::after { border-color: rgba(125,211,252,.6); animation-duration: 1.1s; }
#agente[data-bt="fuentes"] .hero-estado .vivo { background: #7dd3fc; }
#agente[data-bt="accion"] .hero-estado { border-color: rgba(253,224,71,.45); background: rgba(250,204,21,.12); color: #fef3c7; }
#agente[data-bt="accion"] .hero-estado .vivo { background: #facc15; }
#agente[data-bt="hablando"] .hero-estado .vivo { background: #a5b4fc; }
/* investigando: una línea de exploración recorre el borde inferior del input (transform, sólo mientras hay pregunta en curso) */
.agente-vivo .ai-hero .preguntar { position: relative; overflow: hidden; }
.agente-vivo .ai-hero .preguntar::after { content: ""; position: absolute; left: 0; bottom: 0; width: 30%; height: 2px; opacity: 0;
  background: linear-gradient(90deg, transparent, #67e8f9, transparent); transform: translateX(-100%); pointer-events: none; }
#agente[data-bt="investigando"] .preguntar::after, #agente[data-bt="consultando"] .preguntar::after { opacity: 1; animation: bt-explora 1.2s ease-in-out infinite; will-change: transform; }
@keyframes bt-explora { to { transform: translateX(340%); } }

/* ── Actividad del Agente viva (panel derecho; el pulso decorativo queda de fondo) ── */
.agente-vivo .hero-pulso { height: 124px; opacity: .28; pointer-events: none; }   /* reserva el lugar de la actividad desde el primer cuadro */
.agente-vivo .hero-act { display: none; }
.bt-act { position: absolute; z-index: 1; left: 14px; right: 14px; top: 12px; height: 124px; display: flex; flex-direction: column; gap: 4px; }
.bt-act-t { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: #7dd3fc; }
.bt-act-l { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; min-height: 0; overflow: hidden; max-height: 96px; }
.bt-paso { display: flex; align-items: baseline; gap: 7px; font-size: 11.5px; line-height: 15px; color: #dbe7fb;
           transition: opacity .28s ease, transform .28s ease; }
.bt-paso.bt-entra { opacity: 0; transform: translateY(4px); }
.bt-tx { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-ic { flex: none; width: 12px; text-align: center; font-size: 10px; color: #4ade80; }
.bt-paso.ok .bt-ic::before { content: "✓"; }
.bt-paso.aviso .bt-ic::before { content: "●"; color: #fbbf24; font-size: 8px; }
.bt-paso.nd .bt-ic::before { content: "—"; color: #93a9c9; }
.bt-paso.nd .bt-tx { color: #93a9c9; }
.bt-paso.curso .bt-ic::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #7dd3fc;
                                animation: bt-latido 1s ease-in-out infinite; }
@keyframes bt-latido { 50% { opacity: .25; transform: scale(.7); } }
.bt-act-pie { font-size: 11px; color: #93a9c9; margin-top: auto; }

/* ── Siguiente acción sugerida (bajo la respuesta) ── */
.bt-sig { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 4px; padding: 9px 12px; border-radius: 10px;
          background: var(--superficie-2, #f6f8fb); border: 1px solid var(--linea, #e3e8ef); font-size: 13.5px; color: var(--tinta, #0f172a); }
.bt-sig-ic { width: 8px; height: 8px; border-radius: 50%; background: var(--primary, #7a1f2b); flex: none; }
.bt-sig-t { flex: 1 1 260px; min-width: 0; }
.bt-sig-acc { display: flex; gap: 6px; flex-wrap: wrap; }
.bt-sig .btn-pri, .bt-sig .btn-sec { padding: 6px 12px; font-size: 12.5px; }

/* ── Brainmore ejecutando una acción ── */
.bt-ejec { margin: 10px 0 6px; border: 1px solid color-mix(in srgb, var(--primary, #7a1f2b) 30%, var(--linea, #e3e8ef)); border-radius: 12px;
           padding: 10px 12px; background: color-mix(in srgb, var(--primary, #7a1f2b) 4%, var(--superficie, #fff)); }
.bt-ejec-cab { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.bt-ejec-ic { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; flex: none; }
.bt-ejec-cab .link { margin-left: auto; font-size: 12.5px; }
.bt-ejec-pasos { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 8px; padding: 0; font-size: 12px; color: var(--suave, #64748b); }
.bt-ejec-pasos li { transition: opacity .25s ease, transform .25s ease; }
.bt-ejec-pasos li::before { content: "✓ "; color: #16a34a; }
.bt-ejec-pasos li.bt-entra { opacity: 0; transform: translateX(-4px); }
.bt-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.bt-u { width: 100%; display: flex; gap: 10px; align-items: baseline; text-align: left; font: inherit; font-size: 13px; padding: 6px 9px; border-radius: 8px;
        background: var(--superficie, #fff); border: 1px solid var(--linea, #e3e8ef); cursor: pointer; color: var(--tinta-2, #334155); }
.bt-u:hover { border-color: var(--primary, #7a1f2b); }
.bt-u b { color: var(--tinta, #0f172a); letter-spacing: .02em; flex: none; }
.bt-u span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-mas { font-size: 12px; color: var(--suave, #64748b); padding: 2px 9px; }

/* chip de filtro «Sucursal: Coquimbo ×» */
.bt-chip { display: inline-flex; align-items: center; gap: 6px; font: 600 12px Inter, sans-serif; padding: 3px 6px 3px 10px; border-radius: 999px;
           border: 1px solid color-mix(in srgb, var(--primary, #7a1f2b) 45%, transparent); background: color-mix(in srgb, var(--primary, #7a1f2b) 8%, #fff);
           color: var(--primary, #7a1f2b); cursor: pointer; }
.bt-chip b { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: color-mix(in srgb, var(--primary, #7a1f2b) 14%, transparent); font-size: 12px; }
.ejg-cab .bt-chip { margin-left: auto; margin-right: 10px; }

/* gráficos: barra resaltada y el resto atenuado (transición de opacidad) */
.agente-vivo .vz-fila, .agente-vivo .vz-met { transition: opacity .25s ease; }
.vz .bt-aten { opacity: .32; }
.vz .bt-sel .vz-et { font-weight: 700; color: var(--tinta, #0f172a); }
.vz .bt-sel .vz-pista { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary, #7a1f2b) 35%, transparent); border-radius: 6px; }

/* ── «74 → 75»: sólo cuando una cifra cambia entre dos lecturas ── */
.agente-vivo .kpi-ej { position: relative; }
.bt-delta { position: absolute; top: 9px; right: 10px; font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 999px;
            background: var(--superficie-2, #f6f8fb); color: var(--tinta-2, #334155); transition: opacity .5s ease, transform .5s ease;
            animation: bt-aparece .35s ease-out; }
.bt-delta.fuera { opacity: 0; transform: translateY(-3px); }
@keyframes bt-aparece { from { opacity: 0; transform: translateY(3px); } }

/* ── Brainmore recomienda (motivo + acciones) ── */
.agente-vivo #ej-recomiendo { visibility: hidden; height: 138px; }          /* reserva hasta que llegan las recomendaciones */
.agente-vivo #ej-recomiendo.bt-oculto { display: none; }
.bt-rec { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--linea, #e3e8ef); display: grid; gap: 5px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.bt-rec-t { font-size: 12px; font-weight: 650; color: var(--tinta-2, #334155); }
.bt-rec-f { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; padding: 3px 0; }
.bt-rec-q { flex: 1 1 240px; min-width: 0; display: flex; gap: 8px; align-items: baseline; }
.bt-rec-q b { letter-spacing: .02em; }
.bt-rec-q span { min-width: 0; color: var(--tinta-2, #334155); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-rec-f.alta .bt-rec-q b { color: var(--critico, #c62828); }
.bt-rec-acc { display: flex; gap: 6px; }
.bt-rec-acc .chico { padding: 3px 10px; font-size: 12px; }

/* ── Voz: subtítulos y lo que se explica ── */
.bt-sub { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 12px;
          max-width: min(760px, calc(100vw - 32px)); padding: 10px 12px 10px 16px; border-radius: 14px; background: rgba(7,26,54,.92); color: #fff;
          font-size: 15px; line-height: 1.4; box-shadow: 0 10px 30px -12px rgba(0,0,0,.5); animation: bt-aparece .25s ease-out; }
.bt-sub-t { min-width: 0; }
.bt-sub-x { flex: none; border: 1px solid rgba(255,255,255,.25); background: none; color: #fff; border-radius: 8px; padding: 4px 10px; font: 600 12px Inter, sans-serif; cursor: pointer; }
.bt-onda-hab { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #a5b4fc; flex: none; animation: bt-latido 1.2s ease-in-out infinite; }
.bt-habla { background: color-mix(in srgb, #2563eb 9%, transparent); border-radius: 8px; transition: background .2s ease; }
.resp.bt-explica { outline: 2px solid color-mix(in srgb, #2563eb 45%, transparent); outline-offset: 3px; border-radius: 12px; }

/* ── Móvil: estado → Agente → acción recomendada → KPI → respuesta → visual → detalle ── */
@media (max-width: 720px) {
  .agente-vivo body.ejecutiva-on .saludo-cab { order: 1; }
  .agente-vivo body.ejecutiva-on #agente { order: 2; }
  .agente-vivo body.ejecutiva-on #ej-detecto { order: 3; }
  .agente-vivo body.ejecutiva-on #kpis-ej { order: 4; }
  .agente-vivo body.ejecutiva-on #respuesta-inicio { order: 5; }
  .agente-vivo body.ejecutiva-on #ej-acciones { order: 6; }
  .agente-vivo body.ejecutiva-on #ej-graficos { order: 7; }
  .agente-vivo body.ejecutiva-on .filtros-op { order: 8; }
  .agente-vivo body.ejecutiva-on #operativa { order: 9; }
  .agente-vivo body.ejecutiva-on .abajo { order: 10; }
  .agente-vivo .ai-hero .hero-pulso { display: block; height: 34px; }      /* reserva 1 línea de actividad + hora, sin ilustración */
  .agente-vivo .ai-hero .hp-caja { display: none; }
  .bt-act { top: 8px; left: 12px; right: 12px; height: 34px; gap: 2px; }
  .bt-act-l { max-height: 16px; }                 /* móvil: 1 línea de actividad (lo último que hizo) */
  .bt-act-l .bt-paso:not(:last-child) { display: none; }
  .bt-act-t { display: none; }
  .agente-vivo .hero-estado { max-width: 100%; }
  /* Detecté en móvil: la acción recomendada primero (es lo que se hace en 3 s) */
  .agente-vivo #ej-detecto { display: flex !important; flex-direction: column; }
  .agente-vivo #ej-detecto .det-cab { order: 1; } .agente-vivo #ej-detecto .bt-rec { order: 2; margin-top: 2px; border-top: 0; padding-top: 0; }
  .agente-vivo #ej-detecto #ej-recomiendo { order: 2; margin-top: 2px; border-top: 0; padding-top: 0; }   /* la reserva, donde irá la recomendación */
  .agente-vivo #ej-detecto .det-lista { order: 3; min-height: 0; margin-top: 6px; display: none; }   /* qué ocurre: con «Ver evidencia» */
  .agente-vivo #ej-detecto.con-porque .det-lista { display: block; }
  .bt-rec-f:nth-child(n+3) { display: none; }
  .agente-vivo .bt-rec-t { display: none; }        /* «Detecté» ya encabeza; la fila es la acción sugerida */
  /* una sola línea: el caso (recortado con «…») y su acción principal; el resto de acciones está en la ficha */
  .bt-rec-f { flex-wrap: nowrap; gap: 8px; padding: 0; }
  .bt-rec-q { flex: 1 1 auto; }
  .bt-rec-acc button:not(:first-child) { display: none; }
  .agente-vivo #ej-recomiendo { height: 24px; }        /* = alto real de una fila de recomendación en móvil */
}

/* ── Pausas: Hero fuera de pantalla / pestaña oculta (clase existente) y movimiento reducido ── */
body.hero-quieto .bt-act *, body.hero-quieto #agente .preguntar::after { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  .bt-paso, .bt-ejec-pasos li, .bt-delta, .bt-onda i, .vz-fila, .vz-met { transition: none !important; }
  #agente[data-bt] .preguntar::after, .bt-paso.curso .bt-ic::before, .bt-onda-hab, .bt-sub, .bt-delta { animation: none !important; }
}
