/* Define CSS variables */
:root {
    --primary-color: #007bff; /* Default primary color */
}

/* Chatbot container */
#chatbot-container {
    position: fixed;
    bottom: 20px;
    z-index: 1000;
}

#chatbot-container.chatbot-right {
    right: 20px;
}

#chatbot-container.chatbot-left {
    left: 20px;
}

/* Chatbot window */
#chatbot-window {
    position: fixed;
    bottom: 90px;
    width: 350px;
    height: 500px;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    font-family: 'Roboto', sans-serif;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#chatbot-container.chatbot-right #chatbot-window {
    right: 20px;
}

#chatbot-container.chatbot-left #chatbot-window {
    left: 20px;
}

#chatbot-window.open {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Chatbot header */
.chatbot-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--primary-color);
    color: white;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.chatbot-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
}

.chatbot-title {
    font-size: 18px;
    font-weight: bold;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    margin-left: auto;
}

/* Chatbot messages */
.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #fff;
    display: flex;
    flex-direction: column;
}

/* Chatbot message */
.chatbot-message {
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    animation: slideIn 0.3s ease-out;
    font-size: 14px;
    line-height: 1.5;
}

.chatbot-message.user-message {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 0;
}

.chatbot-message.bot-message {
    background-color: #f1f1f1;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 0;
}

/* Chatbot input area */
.chatbot-input-area {
    display: flex;
    padding: 10px 15px;
    background-color: #f9f9f9;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
}

#chatbot-user-input {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-right: 10px;
}

#chatbot-send-btn {
    background-color: var(--primary-color);
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

#chatbot-send-btn svg {
    width: 24px;
    height: 24px;
    fill: white;
}

/* Chatbot footer */
.chatbot-footer {
    text-align: center;
    font-size: 10px;
    color: #aaa;
    padding: 2px;
    opacity: 0.7;
}

/* Toggle button */
#chatbot-toggle-btn {
    position: fixed;
    bottom: 20px;
    background-color: var(--primary-color);
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    color: var(--icon-color); /* Colore dell'icona controllato via PHP */
}

#chatbot-container.chatbot-right #chatbot-toggle-btn {
    right: 20px;
}

#chatbot-container.chatbot-left #chatbot-toggle-btn {
    left: 20px;
}

/* External welcome message */
#external-welcome-message {
    position: fixed;
    bottom: 35px;
    background-color: #f9f9f9;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 220px;
    z-index: 1000;
    white-space: normal;
    word-wrap: break-word;
    font-size: 13px;
    color: #666;
}

#chatbot-container.chatbot-right #external-welcome-message {
    right: 90px;
}

#chatbot-container.chatbot-left #external-welcome-message {
    left: 90px;
}

/* Media queries */
@media (max-width: 480px) {
    #chatbot-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        border-radius: 0;
    }
    #chatbot-container.chatbot-right #chatbot-window,
    #chatbot-container.chatbot-left #chatbot-window {
        left: 0;
        right: 0;
    }
    #chatbot-container.chatbot-right #chatbot-toggle-btn {
        right: 10px;
    }
    #chatbot-container.chatbot-left #chatbot-toggle-btn {
        left: 10px;
    }
    #chatbot-container.chatbot-right #external-welcome-message {
        right: 80px;
    }
    #chatbot-container.chatbot-left #external-welcome-message {
        left: 80px;
    }
}

@media (max-width: 320px) {
    #chatbot-container.chatbot-right {
        right: 10px;
    }
    #chatbot-container.chatbot-left {
        left: 10px;
    }
}

/* Animation for messages */
@keyframes slideIn {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}