/* =========================
   ASISTENTE VIRTUAL (chat flotante)
========================= */

.asistente {
    position: fixed;

    right: 20px;
    bottom: 20px;

    /* Por encima de todo el sitio, incluido el encabezado fijo (z-index 1000). */
    z-index: 2000;

    display: flex;
    flex-direction: column;
    align-items: flex-end;

    gap: 12px;

    font-family: "DM Sans", sans-serif;
}

.asistente-boton {
    display: flex;
    align-items: center;

    gap: 8px;

    height: 48px;

    padding: 0 18px 0 16px;

    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;

    background: var(--primary);

    border: 0;
    border-radius: 999px;

    box-shadow: 0 10px 24px rgba(38, 63, 130, 0.35);

    cursor: pointer;

    transition: background 0.2s ease, transform 0.2s ease;
}

.asistente-boton:hover {
    background: var(--primary-dark);

    transform: translateY(-1px);
}

.asistente-boton:focus-visible,
.asistente-form button:focus-visible,
.asistente-cerrar:focus-visible,
.asistente-atajos button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.asistente-panel {
    display: flex;
    flex-direction: column;

    width: 360px;
    max-width: calc(100vw - 40px);
    height: min(540px, calc(100vh - 110px));

    overflow: hidden;

    color: var(--text);

    background: #fff;

    border: 1px solid var(--border);
    border-radius: 18px;

    box-shadow: 0 24px 60px rgba(13, 27, 61, 0.28);
}

.asistente-panel[hidden] {
    display: none;
}

.asistente-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 14px 16px;

    color: #fff;

    background: var(--primary);
}

.asistente-cabecera strong {
    display: block;

    font-size: 15px;
}

.asistente-cabecera span {
    font-size: 12px;

    opacity: 0.8;
}

.asistente-cerrar {
    width: 32px;
    height: 32px;

    padding: 0 0 3px;

    color: #fff;
    font-size: 24px;
    line-height: 1;

    background: transparent;

    border: 0;
    border-radius: 50%;

    cursor: pointer;
}

.asistente-cerrar:hover {
    background: rgba(255, 255, 255, 0.15);
}

.asistente-aviso {
    margin: 0;

    padding: 8px 16px;

    color: var(--text-light);
    font-size: 12px;
    line-height: 1.45;

    background: var(--background-soft);

    border-bottom: 1px solid var(--border);
}

/* Mensajes y botones sugeridos comparten una sola zona con desplazamiento (una sola barra). */
.asistente-cuerpo {
    flex: 1;

    min-height: 96px;

    overflow-y: auto;
}

.asistente-mensajes {
    display: flex;
    flex-direction: column;

    gap: 10px;

    padding: 14px 16px 10px;
}

.asistente-burbuja {
    max-width: 88%;

    padding: 10px 13px;

    font-size: 14px;
    line-height: 1.5;

    border-radius: 14px;

    overflow-wrap: anywhere;
}

.asistente-burbuja p {
    margin: 0;
}

.asistente-burbuja.es-asistente {
    align-self: flex-start;

    background: var(--background-soft);

    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.asistente-burbuja.es-usuario {
    align-self: flex-end;

    color: #fff;

    background: var(--primary);

    border-bottom-right-radius: 4px;
}

.asistente-burbuja.es-pensando {
    color: var(--text-light);
}

.asistente-burbuja.es-crisis {
    background: #fef3f2;

    border-color: #fda29b;
}

.asistente-enlace {
    display: block;

    margin-top: 8px;

    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    text-decoration: underline;
}

.asistente-atajos {
    display: flex;
    flex-wrap: wrap;

    gap: 6px;

    padding: 0 16px 12px;
}

.asistente-atajos:empty {
    display: none;
}

.asistente-atajos button {
    padding: 6px 12px;

    color: var(--primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;

    background: #fff;

    border: 1px solid var(--primary);
    border-radius: 999px;

    cursor: pointer;

    transition: background 0.2s ease;
}

.asistente-atajos button:hover {
    background: var(--accent-light);
}

.asistente-form {
    display: flex;

    gap: 8px;

    padding: 10px 12px;

    border-top: 1px solid var(--border);
}

.asistente-form input {
    flex: 1;

    min-width: 0;

    padding: 10px 14px;

    font-family: inherit;
    font-size: 14px;

    border: 1px solid var(--border);
    border-radius: 999px;
}

.asistente-form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.asistente-form button {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;

    padding: 0;

    color: #fff;

    background: var(--primary);

    border: 0;
    border-radius: 50%;

    cursor: pointer;
}

.asistente-persona {
    padding: 8px 16px 12px;

    color: var(--text-light);
    font-size: 12px;
    text-align: center;
    text-decoration: underline;
}

.asistente-sr {
    position: absolute;

    width: 1px;
    height: 1px;

    overflow: hidden;

    clip: rect(0 0 0 0);
}

@media (max-width: 640px) {
    .asistente {
        right: 12px;
        bottom: 12px;
    }

    .asistente-boton span {
        display: none;
    }

    .asistente-boton {
        width: 52px;
        height: 52px;

        padding: 0;

        justify-content: center;
    }

    .asistente-panel {
        width: calc(100vw - 24px);
        height: min(560px, calc(100vh - 90px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .asistente-boton,
    .asistente-atajos button {
        transition: none;
    }
}
