/* --- COMIENZO DEL ARCHIVO css/chatbot.css (VERSIÓN MEJORADA) --- */

/* --- BOTÓN FLOTANTE (BURBUJA) --- */
.chatbot-toggler {
    position: fixed;
    bottom: 30px;
    right: 35px;
    outline: none;
    border: none;
    height: 60px;
    width: 60px;
    display: flex;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #8f793b; /* Color Madera */
    border: 3px solid white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    z-index: 9991; 
}

.chatbot-toggler:hover { 
    transform: scale(1.1); 
}

/* Imagen del Avatar */
.chatbot-toggler img { 
    width: 100%; 
    height: 100%; 
    border-radius: 50%; 
    object-fit: cover; 
}

/* --- VENTANA PRINCIPAL DEL CHAT --- */
.chatbot {
    position: fixed;
    right: 35px;
    bottom: 100px;
    width: 350px;
    height: 500px; /* Altura Fija en Escritorio */
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transform-origin: bottom right;
    box-shadow: 0 0 128px 0 rgba(0,0,0,0.1), 0 32px 64px -48px rgba(0,0,0,0.5);
    transition: all 0.1s ease;
    z-index: 9990; 
    border: 2px solid #8f793b;
    display: flex;
    flex-direction: column; 
}

body.show-chatbot .chatbot { 
    opacity: 1; 
    pointer-events: auto; 
    transform: scale(1); 
}

/* --- ENCABEZADO --- */
.chatbot header {
    background: #38761D; 
    padding: 16px 0; 
    position: relative;
    text-align: center; 
    color: #fff; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    flex-shrink: 0; /* Asegura que no se comprima por flex */
}

.chatbot header h2 { 
    font-size: 1.2rem; 
    margin: 0; 
    color: white; 
}

.chatbot header .close-btn {
    position: absolute; 
    right: 15px; 
    top: 50%; 
    transform: translateY(-50%);
    cursor: pointer; 
    font-size: 1.5rem; 
    display: none; 
    color: white;
}

/* --- ÁREA DE MENSAJES (SCROLL IMPLEMENTADO AQUÍ) --- */
.chatbox {
    /* CRÍTICO: Permite el desplazamiento vertical */
    overflow-y: auto; 
    
    /* Permite que el chatbox ocupe todo el espacio restante dentro del contenedor .chatbot */
    flex-grow: 1; 
    
    /* Configuración de la caja de mensajes */
    padding: 15px 20px 20px; 
    background: #f4f6f8;
    list-style: none; 
    
    /* Hace que los mensajes se alineen al fondo para ver el último mensaje */
    display: flex;
    flex-direction: column;
}

.chatbox .chat { 
    display: flex; 
    list-style: none; 
    margin-bottom: 15px; 
}

.chatbox .incoming span {
    width: 32px; 
    height: 32px; 
    background: #8f793b; 
    color: #fff;
    align-self: flex-end; 
    border-radius: 50%; 
    text-align: center;
    line-height: 32px; 
    margin: 0 10px 7px 0; 
    font-size: 0.8rem; 
    font-weight: bold;
}

.chatbox .outgoing { 
    justify-content: flex-end; 
    margin: 20px 0; 
}

.chatbox .outgoing p {
    background: #38761D; 
    color: #fff; 
    border-radius: 10px 10px 0 10px;
    white-space: pre-wrap; 
    padding: 12px 16px; 
    max-width: 75%; 
    font-size: 0.95rem;
}

.chatbox .incoming p {
    background: #fff; 
    color: #333; 
    border-radius: 10px 10px 10px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
    white-space: pre-wrap; 
    padding: 12px 16px; 
    max-width: 75%; 
    font-size: 0.95rem;
}

/* --- ÁREA DE INPUT --- */
.chat-input {
    display: flex; 
    gap: 5px; 
    background: #fff; 
    padding: 10px 20px; 
    border-top: 1px solid #ddd;
    flex-shrink: 0; /* Asegura que no se comprima por flex */
}

.chat-input textarea {
    height: 45px; 
    width: 100%; 
    border: none; 
    outline: none; 
    resize: none; 
    max-height: 180px;
    padding: 12px 0; 
    font-family: 'Poppins', sans-serif; 
    font-size: 0.95rem;
}

.chat-input span {
    align-self: flex-end; 
    color: #38761D; 
    cursor: pointer; 
    height: 45px;
    display: flex; 
    align-items: center; 
    font-size: 1.3rem; 
    transition: color 0.2s;
}

.chat-input span:hover { 
    color: #8f793b; 
}

/* --- RESPONSIVE MÓVIL (CHAT PANTALLA COMPLETA) --- */
@media (max-width: 490px) {
    .chatbot {
        right: 0; 
        bottom: 0; 
        height: 100%; /* Ocupa toda la altura de la pantalla */
        border-radius: 0; 
        width: 100%;
        border: none; 
        display: flex; 
        flex-direction: column;
    }
    
    .chatbot .chatbox {
        /* CRÍTICO PARA EL SCROLL EN MÓVIL: Ocupa el espacio restante */
        flex-grow: 1; 
        height: 100%; 
        overflow-y: auto; 
    }
    
    .chatbot header .close-btn {
        display: block; /* Muestra el botón X para cerrar en móvil */
    }
}
/* --- FIN DEL ARCHIVO css/chatbot.css (VERSIÓN MEJORADA) --- */