/* --- ESTILOS ASISTENTE IA (SIN GLOBO Y CORREGIDO) --- */
#ai-chat-container {
    position: fixed;
    bottom: 20px; 
    right: 20px;
    z-index: 9999; /* Z-index alto asegurando que nada lo tape */
    font-family: sans-serif;
}

#ai-chat-window {
    width: 320px;
    height: 450px;
    /* La magia ocurre aquí: Nunca será más alto que la pantalla menos 120px (para esquivar el menú) */
    max-height: calc(100vh - 120px); 
    background: white;
    border-radius: 15px;
    display: none; /* Se activa con el botón de la web */
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    border: 1px solid #ddd;
}

/* Cuando Javascript le pone la clase "chat-open", se muestra */
#ai-chat-container.chat-open #ai-chat-window { 
    display: flex; 
}

#ai-chat-header {
    background: #5c3012;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-header-info { display: flex; align-items: center; gap: 8px; }
.ai-status-dot { width: 8px; height: 8px; background: #4caf50; border-radius: 50%; }

.ai-close-btn {
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    transition: 0.3s;
}

.ai-close-btn:hover {
    color: #ff0844;
    transform: scale(1.2);
}

#ai-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fdfaf7; 
}

.msg {
    padding: 10px 14px;
    border-radius: 15px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.4;
}

.bot-msg { background: #e8e8e8; color: #333; align-self: flex-start; border-bottom-left-radius: 2px; }
.user-msg { background: #5c3012; color: white; align-self: flex-end; border-bottom-right-radius: 2px; }

#ai-chat-input-area {
    padding: 10px;
    display: flex;
    border-top: 1px solid #eee;
    background: #fff;
    align-items: center;
}

#ai-chat-input-area input {
    flex: 1;
    border: none;
    padding: 10px;
    outline: none;
    font-size: 14px;
    background: #f5f5f5;
    border-radius: 20px;
    margin-right: 10px;
}

#ai-chat-input-area button {
    background: none;
    border: none;
    font-size: 20px;
    color: #5c3012;
    cursor: pointer;
    padding: 0 5px;
    transition: 0.2s;
}

#ai-chat-input-area button:hover {
    color: #ff0844;
}



/* Adaptación inteligente para teléfonos móviles */
@media only screen and (max-width: 480px) {
    #ai-chat-container {
        bottom: 15px;
        right: 15px;
        left: 15px; 
    }
    #ai-chat-window {
        width: auto; /* Ocupa el 100% menos los márgenes */
        max-height: calc(100vh - 100px);
    }
}