/* Stili di base (desktop) - MODIFICATO CON VARIABILI CSS */
#chatbox {
    position: fixed;
    bottom: -700px; /* Nascosta inizialmente */
    right: 20px;
    width: 400px;
    height: 600px;
    background-color: var(--chatbot-chatbox-bg-color, #fff); /* VARIABILE CSS per sfondo chatbox */
    border: none;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    transition: bottom 0.3s ease;
    display: flex;
    flex-direction: column;
    z-index: 9999;
    border-radius: 10px 10px 10px 10px;
    box-sizing: border-box; /* Aggiunto */
}

#chatbox.chatbox-closed {
    bottom: -700px; /* Nascondi la chatbox */
}

#chatbox-header {
    background-color: var(--chatbot-header-bg-color, #038AF9); /* VARIABILE CSS per sfondo header */
    color: var(--chatbot-header-text-color, #fff); /* VARIABILE CSS per testo header */
    padding: 10px;
    font-size: 18px;
    text-align: center;
    border-bottom: 0px solid #ccc;
    position: relative;
    min-height: 40px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px 10px 0 0; /* Bordi arrotondati */
    background-clip: padding-box; /* Ritaglia lo sfondo per rispettare il bordo */
    overflow: hidden; /* Assicura che il contenuto non fuoriesca dagli angoli smussati */
    border: none; /* Aggiungi un bordo trasparente */
    box-shadow: none;
    -webkit-appearance: none;
    transform: translateZ(0); /* Forza il rendering */
}

#chatbox-header #chatbox-close {
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 20px;
    cursor: pointer;
    color: var(--chatbot-header-text-color, #fff); /* VARIABILE CSS per colore icona chiusura (uguale a testo header) */
}

#chatbox-content {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    box-sizing: border-box; /* Aggiunto */
}

.chat-message {
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
}

.chat-message.user {
    flex-direction: row-reverse;
    margin-right: -10px;
}

.chat-message.user span {
    background-color: var(--chatbot-user-message-bg-color, #add8e6); /* VARIABILE CSS per sfondo messaggi utente */
    color: var(--chatbot-user-message-text-color, #000); /* VARIABILE CSS per testo messaggi utente */
    font-size: 15px;
    padding: 10px;
    border-radius: 10px;
    max-width: 90%; /* Aumenta la larghezza massima */
    word-wrap: break-word;
    margin-right: 10px;
    box-sizing: border-box; /* Aggiunto */
}

.chat-message.bot {
    justify-content: flex-start;
}

.chat-message.bot span {
    background-color: var(--chatbot-bot-message-bg-color, #ffc0cb);  /* VARIABILE CSS per sfondo messaggi bot */
    color: var(--chatbot-bot-message-text-color, #000); /* VARIABILE CSS per testo messaggi bot */
    font-size: 15px;
    padding: 10px;
    border-radius: 10px;
    max-width: 90%; /* Aumenta la larghezza massima */
    word-wrap: break-word;
    margin-right: 10px;
    box-sizing: border-box; /* Aggiunto */
    line-height: 1.4; /* Aggiunto per un aspetto più compatto */
}

.chat-message img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
}

.chat-message.loading img {
    width: 40px;
    height: 20px;
}

#chatbox-controls {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ccc;
    box-sizing: border-box;
    height: 60px !important; /* Forza l'altezza specifica */
    min-height: 60px !important; /* Previene l'espansione */
    max-height: 60px !important; /* Previene l'espansione */
}

#chatbox-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    font-size: 15px;
    border-radius: 5px;
    margin-right: 10px;
    box-sizing: border-box;
    height: 40px !important; /* Forza l'altezza dell'input */
    min-height: 40px !important;
    line-height: normal !important; /* Previene problemi di line-height */
}

#chatbox-send {
    padding: 10px 20px;
    border: none;
    font-size: 15px;
    border-radius: 5px;
    cursor: pointer;
    box-sizing: border-box;
    height: 40px !important; /* Forza l'altezza del bottone */
    min-height: 40px !important;
    line-height: 20px !important;
    background-color: var(--chatbot-send-button-bg-color, #dc3232);
    color: var(--chatbot-send-button-text-color, #fff);
}

#chatbox-send:hover {
    background-color: #b91919;
}

#chatbox-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    overflow: hidden; /* Nasconde ciò che esce dai bordi del contenitore */
    padding: 0px;
    box-sizing: border-box;
}

#chatbox-button img {
    display: block;
    width: 115%;  /* ATTENZIONE: Usare con cautela */
    height: 115%; /* ATTENZIONE: Usare con cautela */
    object-fit: cover;
    transform: translate(-0%, -2.5%); /* ATTENZIONE: Usare con cautela */
    border-radius: 50%;
}

/* Stili per il footer */
#chatbox-footer {
    padding: 5px 10px; /* Aggiunto padding per spazio interno */
    text-align: center;
    font-size: 0.8em; /* Dimensione del font più piccola */
    color: #808080; /* Colore del testo grigio */
    border-top: 1px solid #ccc; /* Aggiunto un bordo superiore */
    box-sizing: border-box; /* Aggiunto */
}

#chatbox-powered {
  text-align: center; /* Allinea il testo al centro */
  font-size: 0.8em; /* Dimensione del font più piccola */
  color: #808080; /* Colore del testo grigio */
}

#chatbox-powered a {
    color: #808080; /* Colore del testo grigio per il link */
    text-decoration: none; /* Rimossa la sottolineatura predefinita */
}

#chatbox-powered a:hover {
    text-decoration: underline; /* Sottolinea il link al passaggio del mouse */
}

/* Media query per schermi piccoli (telefoni) */
@media (max-width: 768px) {
    #chatbox {
        width: 100%;
        height: 85vh;
        bottom: -100vh; /* Questo si coordina con il JS */
        margin: 0;
        border-radius: 15px 15px 0 0;
        left: 0;
        right: 0;
    }
    
    #chatbox-header {
        height: 55px;
        background-color: var(--chatbot-header-bg-color, #038AF9);
        color: var(--chatbot-header-text-color, #fff);
        font-size: 18px;
        text-align: center;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 10px 10px 0 0;
        padding: 0 10px;
        margin: 0;
        z-index: 10;
    }
    
    #chatbox-content {
        flex: 1;
        padding: 10px;
        overflow-y: auto;
        margin: 0;
        height: calc(100% - 55px - 60px); /* Altezza contenuto adattata */
    }
    
    #chatbox-controls {
        height: 60px;
        padding: 10px;
        display: flex;
        align-items: center;
        border-top: 1px solid #ccc;
        background-color: var(--chatbot-controls-bg-color, #fff);
        box-sizing: border-box;
    }
    
    #chatbox-footer {
        padding: 5px 5px;
        text-align: center;
        font-size: 0.8em;
        color: #808080;
        border-top: 1px solid #ccc;
    }
    
    #chatbox-button {
        position: fixed;
        bottom: 5px; /* Bottone a soli 2px dal fondo */
        right: 5px;
        width: 50px;
        height: 50px;
        background-color: transparent;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10000;
        overflow: hidden;
    }
    
    #chatbox-button img {
        width: 115%;
        height: 115%;
        object-fit: cover;
        border-radius: 50%;
    }
                
}