.asistente {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 70;
    font-family: var(--font);
    color: var(--ink);
}

.asistente-lanzador {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: var(--teal);
    color: white;
    border-radius: 999px;
    padding: 12px 18px 12px 12px;
    box-shadow: 0 16px 40px rgba(26, 95, 191, .32);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.asistente-lanzador:hover { background: var(--teal-deep); }

.asistente-lanzador-ico {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .16);
    font-size: 1.05rem;
}

.asistente-punto {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 4px var(--teal);
}

.asistente-punto[hidden] { display: none; }

.asistente-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: min(400px, calc(100vw - 28px));
    height: min(640px, calc(100vh - 110px));
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: 0 28px 80px rgba(22, 50, 74, .2);
    overflow: hidden;
}

.asistente-panel[hidden] { display: none; }

.asistente-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: linear-gradient(180deg, var(--mint), var(--paper));
    border-bottom: 1px solid var(--line);
}

.asistente-top img {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    object-fit: cover;
    background: white;
}

.asistente-top div { min-width: 0; flex: 1; }

.asistente-top strong {
    display: block;
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 560;
    letter-spacing: -0.03em;
}

.asistente-top span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 700;
}

.asistente-vivo {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1f9d55;
    box-shadow: 0 0 0 0 rgba(31, 157, 85, .55);
    animation: asistente-pulso 1.8s infinite;
}

.asistente-top.is-espera .asistente-vivo { background: #d97706; }
.asistente-top.is-curso .asistente-vivo { background: var(--teal); }
.asistente-top.is-cerrada .asistente-vivo { background: var(--muted); animation: none; }

.asistente-x {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font-size: 1rem;
}

.asistente-x:hover { background: white; }

.asistente-hilo {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background:
        radial-gradient(1200px 180px at 0% -10%, rgba(43, 125, 233, .08), transparent 50%),
        var(--paper);
}

.asistente-burbuja {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 18px 18px 18px 6px;
    background: var(--mint);
}

.asistente-burbuja header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    font-size: .72rem;
    font-weight: 800;
    color: var(--muted);
}

.asistente-burbuja p {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.45;
    font-size: .94rem;
}

.asistente-burbuja.es-visitante {
    align-self: flex-end;
    background: var(--teal);
    color: white;
    border-radius: 18px 18px 6px 18px;
}

.asistente-burbuja.es-visitante header,
.asistente-burbuja.es-visitante time { color: rgba(255, 255, 255, .78); }

.asistente-burbuja.es-asesor {
    background: white;
    border: 1px solid var(--line);
}

.asistente-burbuja.es-sistema {
    align-self: center;
    max-width: 100%;
    background: transparent;
    color: var(--muted);
    text-align: center;
    padding: 2px 8px;
}

.asistente-burbuja.es-sistema header { display: none; }

.asistente-burbuja.es-sistema p { font-size: .82rem; font-weight: 700; }

.asistente-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--mint);
}

.asistente-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--teal);
    animation: asistente-punto 1s infinite;
}

.asistente-typing span:nth-child(2) { animation-delay: .15s; }
.asistente-typing span:nth-child(3) { animation-delay: .3s; }

.asistente-opciones {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px 10px;
}

.asistente-opciones:empty { display: none; }

.asistente-opciones button,
.asistente-fin button,
.asistente-datos button,
.asistente-terminar {
    border: 1px solid rgba(43, 125, 233, .28);
    background: white;
    color: var(--teal-deep);
    border-radius: 999px;
    padding: 8px 12px;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
}

.asistente-opciones button:hover,
.asistente-fin button:hover,
.asistente-datos button:hover { background: var(--mint); }

.asistente-datos {
    display: grid;
    gap: 8px;
    margin: 0 14px 10px;
    padding: 12px;
    border-radius: 18px;
    background: var(--paper-deep);
    border: 1px solid var(--line);
}

.asistente-datos[hidden] { display: none; }

.asistente-datos p {
    margin: 0;
    font-size: .82rem;
    font-weight: 700;
    color: var(--muted);
}

.asistente-datos input,
.asistente-composer textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: white;
}

.asistente-datos button {
    background: var(--teal);
    color: white;
    border-color: transparent;
}

.asistente-error {
    margin: 0 14px 8px;
    color: var(--danger);
    font-size: .8rem;
    font-weight: 700;
}

.asistente-error[hidden] { display: none; }

.asistente-composer label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.asistente-escribiendo {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 8px 16px 0;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}

.asistente-escribiendo[hidden] { display: none !important; }

.asistente-escribiendo-puntos {
    display: inline-flex;
    align-items: flex-end;
    gap: 3px;
    height: .7em;
}

.asistente-escribiendo-puntos i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: .35;
    animation: asistente-punto 1s infinite;
}

.asistente-escribiendo-puntos i:nth-child(2) { animation-delay: .15s; }
.asistente-escribiendo-puntos i:nth-child(3) { animation-delay: .3s; }

.asistente-composer {
    position: relative;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--line);
}

.asistente-composer[hidden] { display: none; }

.asistente-composer textarea {
    resize: none;
    min-height: 44px;
    max-height: 120px;
    border-radius: 16px;
}

.asistente-composer button {
    width: 44px;
    height: 44px;
    flex: none;
    border: 0;
    border-radius: 16px;
    background: var(--teal);
    color: white;
    cursor: pointer;
}

.asistente-composer button:hover { background: var(--teal-deep); }

.asistente-fin {
    padding: 12px;
    border-top: 1px solid var(--line);
}

.asistente-fin[hidden] { display: none; }

.asistente-fin button,
.asistente-terminar {
    width: 100%;
}

.asistente-terminar {
    margin: 0 14px 12px;
    width: calc(100% - 28px);
    background: transparent;
    color: var(--muted);
    border-color: var(--line);
}

.asistente-terminar[hidden] { display: none; }

@keyframes asistente-pulso {
    70% { box-shadow: 0 0 0 8px rgba(31, 157, 85, 0); }
    100% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0); }
}

@keyframes asistente-punto {
    0%, 80%, 100% { opacity: .25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 720px) {
    .asistente { right: 14px; bottom: 14px; }
    .asistente-lanzador-texto { display: none; }
    .asistente-lanzador { padding: 8px; }
    .asistente.is-abierto .asistente-lanzador { display: none; }
    .asistente.is-abierto .asistente-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .asistente-vivo,
    .asistente-typing span,
    .asistente-escribiendo-puntos i { animation: none; opacity: .85; }
}
