/* ==========================================================================
   💬 COMPONENTE DE CHAT FLOTANTE - NH IMPORT EXPORT (SANEADO & OPTIMIZADO)
   ========================================================================== */

/* Contenedor padre para posicionar los elementos flotantes */
.nh-widget-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Un nivel por debajo de la ventana activa pero sobre la plantilla */
    z-index: 1040; 
}

/* --- GLOBO DE SALUDO INICIAL --- */
.nh-chat-welcome-bubble {
    font-family: Arial, Helvetica, sans-serif !important;
    background: #1d528f; 
    color: white;
    padding: 10px 35px 10px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: relative;
    white-space: nowrap;
    /* Corrección: Vinculado a la animación declarada abajo */
    animation: nhiaFadeInUp 0.4s ease forwards; 
}

/* Botón 'X' para cerrar solo la burbuja de saludo */
.nh-close-bubble-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.nh-close-bubble-btn:hover { opacity: 1; }

/* --- BOTÓN FLOTANTE ESTILO AVATAR --- */
.nh-chat-widget-btn-avatar {
    width: 65px;
    height: 65px;
    background-image: url('../images/team/saludo.png'); 
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
}
.nh-chat-widget-btn-avatar:hover { transform: scale(1.05); }
/* --- BURBUJA DE NOTIFICACIÓN (CORRECCIÓN) --- */
.nh-notification-badge {
    position: absolute;        /* Se posiciona de forma relativa al botón circular */
    top: -3px;                 /* Lo desplaza ligeramente hacia la parte superior */
    right: -3px;               /* Lo desplaza ligeramente hacia la parte derecha */
    background-color: #ef4444; /* Color rojo vibrante de alerta */
    color: #ffffff !important; /* Fuerza el texto en color blanco */
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 11px !important;/* Tamaño de fuente compacto */
    font-weight: bold !important;
    width: 20px;               /* Ancho fijo para formar un círculo perfecto */
    height: 20px;              /* Alto fijo para formar un círculo perfecto */
    border-radius: 50%;        /* Transforma la caja en un círculo */
    display: flex;             /* Centra el número perfectamente de forma vertical */
    align-items: center;       
    justify-content: center;   /* Centra el número perfectamente de forma horizontal */
    box-shadow: 0 2px 6px rgba(0,0,0,0.3); /* Sombra para darle profundidad */
    border: 2px solid white;   /* Borde blanco para separarlo estéticamente del avatar */
    z-index: 1045;             /* Se mantiene siempre por encima de la foto */
}


/* --- CONTENEDOR DEL CHAT (VENTANA FLOTANTE) --- */
.nh-chat-container {
    font-family: Arial, Helvetica, sans-serif !important;
    position: fixed;
    bottom: 95px; /* Ajustado para dar holgura sobre el botón */
    right: 20px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    /* Corrección: Z-index elevado para superar al reproductor de radio (1000) */
    z-index: 1050; 
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Clase activa para abrir el chat */
.nh-chat-container.active { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
    pointer-events: auto; 
}

/* --- CABECERA AZUL --- */
.nh-chat-header { 
    background: #3b82f6; 
    color: white; 
    padding: 15px 20px; 
    display: flex;       
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 10;
}

.nh-avatar-header {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-image: url('../images/team/nhia.jpeg'); 
    background-size: cover;    
    background-position: center; 
    background-repeat: no-repeat; 
    border: 2px solid rgba(255, 255, 255, 0.6);
}

.nh-header-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.nh-header-title {
    font-weight: 600;
    font-size: 1rem;
    color: #ffffff !important;
}

.nh-header-subtitle {
    font-size: 0.78rem;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    color: #f1f3f4 !important;
}

.nh-close-btn { 
    cursor: pointer; 
    opacity: 0.8; 
    font-size: 1.1rem;
    padding: 5px;
}
.nh-close-btn:hover { opacity: 1; }

/* --- ÁREA DE TRANSMISIÓN DE MENSAJES --- */
.nh-chat-box { 
    flex: 1; 
    padding: 20px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
    background: #ffffff; 
    /* Optimización de scroll fluido para dispositivos iOS (Safari) */
    -webkit-overflow-scrolling: touch; 
}

/* --- LOGOTIPO DE BIENVENIDA CENTRAL --- */
.nh-welcome-container {
    text-align: center;
    padding: 15px 10px 10px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.nh-welcome-logo {
    width: 85px;
    height: auto;
}

.nh-welcome-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
}

.nh-welcome-desc {
    font-size: 0.82rem;
    color: #666;
    line-height: 1.45;
    max-width: 280px;
}

/* --- BURBUJAS DE MENSAJES --- */
.nh-bot-msg-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    align-self: flex-start;
    max-width: 85%;
}

.nh-avatar-msg {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-image: url('../images/team/nhia.jpeg'); 
    background-size: cover;
    background-position: center;
    flex-shrink: 0; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.nh-message { 
    padding: 11px 16px; 
    font-size: 0.92rem; 
    line-height: 1.45; 
}

/* Corrección: Reset de estilos heredados por Bootstrap en las listas del Bot */
.nh-message ul {
    margin: 8px 0 0 0 !important;
    padding-left: 20px !important;
    list-style-type: disc !important;
}

.nh-message li {
    margin-bottom: 4px !important;
    font-size: 0.92rem !important;
    line-height: 1.4 !important;
    list-style: disc !important;
}

.nh-message p {
    margin-bottom: 8px !important;
}
.nh-message p:last-child {
    margin-bottom: 0 !important;
}

/* Estilo Bot */
.nh-bot-message { 
    background: #f1f3f4; 
    color: #1f1f1f; 
    font-size: 0.85rem !important; 
    border-radius: 20px 20px 20px 4px; 
}

/* Estilo Usuario */
.nh-user-message { 
    max-width: 80%; 
    background: #e3f2fd; 
    color: #0d47a1; 
    align-self: flex-end; 
    border-radius: 20px 20px 4px 20px; 
}

.nh-system-message { 
    color: #5f6368; 
    font-style: italic; 
    font-size: 0.85rem; 
    text-align: center; 
    align-self: center; 
    background: transparent; 
}

/* --- BARRA DE ENTRADA INFERIOR --- */
.nh-chat-input-wrapper {
    padding: 12px 15px 15px 15px;
    background: #ffffff;
}

.nh-chat-input-area { 
    display: flex; 
    align-items: center;
    background: #f1f3f4; 
    border-radius: 25px; 
    padding: 5px 12px; 
}

.nh-input-icon {
    color: #5f6368;
    margin-right: 6px;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
}

.nh-chat-input { 
    flex: 1; 
    border: none; 
    background: transparent;
    padding: 8px 5px; 
    outline: none; 
    font-size: 0.92rem; 
    color: #1f1f1f;
    /* Corrección: Evita que el padding interno rompa el ancho del contenedor */
    box-sizing: border-box !important; 
}

.nh-send-btn { 
    background: #3b82f6; 
    color: white; 
    border: none; 
    border-radius: 50%; 
    width: 34px; 
    height: 34px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: background 0.2s;
    padding: 0;
}
.nh-send-btn:hover { background: #1d4ed8; }

/* --- MEDIA QUERY RESPONSIVE PARA SMARTPHONES --- */
@media (max-width: 576px) {
    .nh-chat-container {
        width: 100% !important;
        height: 100% !important;
        bottom: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
        z-index: 10000 !important; /* Supera todo control nativo en móviles */
    }
    .nh-widget-wrapper {
        bottom: 15px;
        right: 15px;
    }
}

/* --- DECLARACIÓN DE ANIMACIÓN FALTANTE --- */
@keyframes nhiaFadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

