/* --- BOTÓN FLOTANTE (ICONO) --- */
#chat-toggle-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 65px;
    height: 65px;
    background: var(--accent); 
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 9999;
    transition: transform 0.3s, filter 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px; /* Tamaño del icono */
}

#chat-toggle-btn:hover {
    transform: scale(1.1);
    filter: brightness(1.1);
}

/* Puntito rojo de notificación */
.notification-dot {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border: 2px solid var(--accent); 
    border-radius: 50%;
}

/* --- VENTANA DEL CHAT --- */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 25px;
    width: 360px; 
    height: 500px; 
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chat-window.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* --- CABECERA (HEADER) --- */
.chat-header {
    background: var(--accent);
    color: white;
    padding: 20px; 
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* NUEVA CLASE: Avatar Grande */
.bot-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover; /* Esto asegura que corte la foto para llenar el círculo */
    border: 3px solid rgba(255,255,255,0.9);
    background: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.header-text .name { font-weight: 700; font-size: 1.1rem; }
.header-text .status { font-size: 0.8rem; opacity: 0.9; display: flex; align-items: center; gap: 4px; }
.header-text .status::before { content: ''; width: 8px; height: 8px; background: #4ade80; border-radius: 50%; display: inline-block; }

#chat-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
    font-size: 20px;
    align-self: flex-start; 
    margin-top: 10px;
}
#chat-close-btn:hover { background: rgba(255,255,255,0.4); }

/* --- MENSAJES (Sin cambios importantes) --- */
.chat-messages {
    flex: 1; padding: 20px; overflow-y: auto; background: var(--bg-input);
    display: flex; flex-direction: column; gap: 12px;
}
.message {
    max-width: 80%; padding: 12px 16px; border-radius: 14px; font-size: 0.95rem;
    line-height: 1.5; word-wrap: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.message.bot { background: var(--bg-card); color: var(--text-primary); border-bottom-left-radius: 4px; align-self: flex-start; }
.message.user { background: var(--accent); color: white; border-bottom-right-radius: 4px; align-self: flex-end; }

/* Animación Escribiendo */
.loading-msg .dot { animation: blink 1.4s infinite both; }
.loading-msg .dot:nth-child(2) { animation-delay: .2s; }
.loading-msg .dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0% {opacity: .2;} 20% {opacity: 1;} 100% {opacity: .2;} }

/* --- INPUT AREA --- */
.chat-input-area {
    padding: 15px; background: var(--bg-card); border-top: 1px solid var(--border);
    display: flex; gap: 10px;
}
#chat-input {
    flex: 1; padding: 12px; border: 1px solid var(--border); border-radius: 25px;
    background: var(--bg-input); color: var(--text-primary); outline: none; font-size: 0.95rem; transition: 0.2s;
}
#chat-input:focus { border-color: var(--accent); background: var(--bg-card); }
#chat-send {
    background: var(--accent); border: none; color: white; width: 45px; height: 45px;
    border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 20px; transition: transform 0.2s;
}
#chat-send:hover { transform: scale(1.05); }

/* --- MÓVIL --- */
/* --- MÓVIL (Corregido: Estilo Tarjeta Flotante) --- */
@media (max-width: 480px) {
    .chat-window {
        /* Dimensiones controladas (NO pantalla completa) */
        width: 85vw;           /* Ocupa el 85% del ancho de la pantalla */
        height: 60vh;          /* Ocupa el 60% de la altura */
        min-height: 400px;     /* Altura mínima para que no se vea aplastado */
        max-height: 600px;     /* Límite para pantallas muy largas */
        
        /* Posicionamiento */
        position: fixed;
        bottom: 100px;         /* Deja espacio suficiente para el botón flotante */
        right: 50%;            /* Truco para centrar */
        transform: translateX(50%) translateY(20px) scale(0.95); /* Centrado + Animación inicial */
        left: auto;
        top: auto;
        
        /* Estética */
        border-radius: 16px;   /* Mantenemos las esquinas redondeadas */
        box-shadow: 0 10px 40px rgba(0,0,0,0.3); /* Sombra más fuerte para resaltar */
        z-index: 10000;
    }
    
    /* Ajuste necesario para la animación de entrada en móvil */
    .chat-window.active {
        transform: translateX(50%) translateY(0) scale(1);
    }

    /* Reducimos un poco el avatar en celular para equilibrar */
    .bot-avatar-large { 
        width: 65px; 
        height: 65px; 
    }
    
    #chat-close-btn { 
        width: 32px; 
        height: 32px; 
        font-size: 18px; 
        margin-top: 0; 
        align-self: center;
    }
    
    #chat-toggle-btn { 
        bottom: 20px; 
        right: 20px; 
        /* Aseguramos que el botón no quede gigante en pantallas pequeñas */
        width: 60px; 
        height: 60px; 
    }
}