/* =========================================================
   SISAEM – Asistente flotante
   public/css/components/asistente.css
   ========================================================= */


/* ── CONTENEDOR PRINCIPAL ─────────────────────────────────
   Fija el widget en la esquina inferior derecha de pantalla. */
#sisaem-asistente {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 1080;
    font-family: 'Golos Text', sans-serif;
}


/* ── BOTÓN FLOTANTE (PERSONAJE LOTTIE) ────────────────────
   Sin color de fondo para que el personaje sea el protagonista.
   Fondo transparente + sombra suave + forma circular. */
#sisaem-asistente .boton-toggle {
    width: 78px;
    height: 78px;
    border: 0;
    border-radius: 50%;
    padding: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Efecto hover: sube ligeramente */
#sisaem-asistente .boton-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.24);
}

/* Imagen del asistente dentro del botón */
#sisaem-asistente .imagen-asistente {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    object-fit: cover;
    pointer-events: none;
    display: block;
}


/* ── PANEL DEL CHAT ───────────────────────────────────────
   Se posiciona encima del botón. bottom=90px para no tapar
   el personaje de 78px. */
#sisaem-asistente .panel-asistente {
    position: absolute;
    left: 0;
    bottom: 90px;
    width: min(380px, calc(100vw - 32px));
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
    display: none;
}

/* Animación de entrada: sube suavemente al abrirse */
#sisaem-asistente .panel-asistente.abierto {
    display: block;
    animation: asistente-slide-up 0.22s ease-out;
}


/* ── ENCABEZADO ───────────────────────────────────────────
   bg-primary y text-white se ponen desde Bootstrap en el HTML. */
#sisaem-asistente .encabezado-asistente {
    padding: 16px 18px;
}

/* Nombre del asistente */
#sisaem-asistente .titulo-encabezado {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
}

/* Subtítulo más pequeño y sutil */
#sisaem-asistente .subtitulo-encabezado {
    font-size: 12px;
    opacity: 0.86;
    margin-top: 2px;
}

/* Botón "Nuevo chat" en el encabezado */
#sisaem-asistente .boton-nuevo-chat {
    border-radius: 10px;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}


/* ── ÁREA DE MENSAJES ─────────────────────────────────────
   Fondo gris muy claro, scroll vertical, burbujas en columna. */
#sisaem-asistente .area-mensajes {
    height: 340px;
    overflow-y: auto;
    padding: 14px;
    background: linear-gradient(180deg, #f8fbff 0%, #f4f7fb 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
}


/* ── BURBUJAS ─────────────────────────────────────────────
   Estilos base, colores desde Bootstrap en el JS. */
#sisaem-asistente .burbuja {
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 16px;
    line-height: 1.45;
    font-size: 14px;
    white-space: pre-wrap;
}

/* Burbuja del usuario: derecha */
#sisaem-asistente .burbuja.usuario {
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}

/* Fila del bot: avatar + burbuja alineados a la izquierda */
#sisaem-asistente .fila-bot {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    align-self: flex-start;
    max-width: 92%;
}

/* Avatar pequeño con ícono de robot */
#sisaem-asistente .avatar-bot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bs-primary, #0d6efd);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 14px;
}

/* Burbuja del bot: izquierda */
#sisaem-asistente .burbuja.bot {
    border-bottom-left-radius: 6px;
}


/* ── INDICADOR ESCRIBIENDO (3 PUNTOS) ─────────────────────
   Tres puntos que pulsan en secuencia mientras el bot responde. */
#sisaem-asistente .puntos-carga {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 2px;
}

#sisaem-asistente .puntos-carga span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--bs-primary, #0d6efd);
    animation: asistente-pulso 1.2s infinite ease-in-out;
}

/* Desfase para efecto de ola */
#sisaem-asistente .puntos-carga span:nth-child(2) { animation-delay: 0.2s; }
#sisaem-asistente .puntos-carga span:nth-child(3) { animation-delay: 0.4s; }


/* ── COMPOSITOR (INPUT + BOTÓN ENVIAR) ────────────────────
   Barra inferior fija con textarea y botón de envío. */
#sisaem-asistente .compositor {
    padding: 12px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    gap: 8px;
    background: #fff;
}

/* Campo de texto del usuario */
#sisaem-asistente .campo-mensaje {
    flex: 1;
    border: 1px solid rgba(15, 23, 42, 0.15);
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 14px;
    min-height: 42px;
    resize: none;
}

/* Botón enviar: cuadrado centrado, color de Bootstrap */
#sisaem-asistente .boton-enviar {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 14px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}


/* ── RESPONSIVE ───────────────────────────────────────────
   En móvil el widget se acerca a las esquinas y el panel
   ocupa casi todo el ancho de pantalla. */
@media (max-width: 576px) {
    #sisaem-asistente {
        left: 12px;
        bottom: 12px;
    }

    #sisaem-asistente .panel-asistente {
        width: calc(100vw - 24px);
        left: -4px;
        bottom: 88px;
    }

    #sisaem-asistente .area-mensajes {
        height: 300px;
    }
}


/* ── BURBUJA DE HABLA ────────────────────────────────────
   Globo de texto junto al botón flotante del asistente. */
#sisaem-asistente .contenedor-toggle-asistente {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-direction: row;
}

#sisaem-asistente .burbuja-habla {
    background: #ffffff;
    color: #333333;
    padding: 10px 14px;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    font-size: 0.92rem;
    line-height: 1.35;
    max-width: 220px;
    position: relative;
    border: 1px solid #e9ecef;
    animation: asistente-fade-in-burbuja 0.6s ease-out;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-shrink: 1;
    word-break: break-word;
}

#sisaem-asistente .texto-burbuja {
    flex: 1;
    min-width: 0;
}

#sisaem-asistente .burbuja-habla::after {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 8px 8px 8px 0;
    border-style: solid;
    border-color: transparent #ffffff transparent transparent;
}

#sisaem-asistente .btn-cerrar-burbuja {
    background: none;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    color: #adb5bd;
    cursor: pointer;
    padding: 0;
    margin: -2px -4px 0 0;
    flex-shrink: 0;
}

#sisaem-asistente .btn-cerrar-burbuja:hover {
    color: #495057;
}

#sisaem-asistente .burbuja-habla.oculta {
    display: none !important;
}


/* ── ANIMACIONES ──────────────────────────────────────────
   slide-up : el panel sube al abrirse.
   pulso    : los tres puntos del indicador de escritura. */
@keyframes asistente-slide-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0);    }
}

@keyframes asistente-pulso {
    0%, 80%, 100% { transform: scale(0.5); opacity: 0.35; }
    40%           { transform: scale(1);   opacity: 1;    }
}

@keyframes asistente-fade-in-burbuja {
    from { opacity: 0; transform: translateX(10px); }
    to   { opacity: 1; transform: translateX(0); }
}
