/* ========================= */
/* STILE PER IL CHATBOT */
/* ========================= */

/* ===== ICONA FLUTTUANTE ===== */
.chatbot-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #007bff;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
    transition: background 0.3s ease-in-out;
    z-index: 10000;
}

.chatbot-icon:hover {
    background: #0056b3;
}

/* ===== FINESTRA CHAT ===== */
.chat-popup {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 370px;
    background: white;
    border-radius: 10px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 9999;
    border: 1px solid #ccc;
}

/* ===== HEADER DELLA CHAT ===== */
.chat-header {
    background: #007bff;
    color: white;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    font-weight: bold;
    font-size: 16px;
    position: relative;
}

.btn-close {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 10px;
    top: 8px;
    transition: background 0.3s ease-in-out;
    z-index: 10001;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.6);
}

/* ===== BOX MESSAGGI ===== */
.chat-box {
    padding: 10px;
    height: 320px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
}

/* ===== STILE DEI MESSAGGI ===== */
.chat-message {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.bot-message {
    background: #f1f1f1;
    color: black;
    align-self: flex-start;
    padding: 8px 12px;
    border-radius: 6px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.4;
}

.bot-message strong {
    color: #007bff !important;
    font-weight: bold;
}

.user-message {
    background: #007bff;
    color: white;
    align-self: flex-end;
}

/* ===== FORM DI INPUT ===== */
#chat-form {
    display: flex;
    align-items: center;
    padding: 10px;
    border-top: 1px solid #ccc;
    background: white;
    gap: 8px;
}

.form-control {
    flex: 1;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 14px;
    outline: none;
    color: black !important;
    background: white !important;
    resize: none;
}

.form-control::placeholder {
    color: #777 !important;
    opacity: 1 !important;
}

#chat-form button {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    min-width: 80px;
    height: 44px;
}

#chat-form button:hover {
    background: #0056b3;
}

/* ===== ANIMAZIONE TRE PUNTINI ===== */
.loading-dots {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 10px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    margin: 0 3px;
    background-color: #007bff;
    border-radius: 50%;
    display: inline-block;
    animation: blink 1.4s infinite both;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* ===== STILE RESPONSIVE: SCHERMO INTERO SU MOBILE ===== */
@media (max-width: 768px) {
    .chat-popup {
        width: 100%;
        height: 90%;
        max-width: none;
        max-height: none;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .chat-header {
        font-size: 16px;
        padding: 14px;
        position: relative;
    }

    .btn-close {
        width: 40px;
        height: 40px;
        font-size: 20px;
        right: 15px;
        top: 10px;
        background: rgba(255, 255, 255, 0.5);
    }

    .chat-box {
        height: calc(100% - 100px);
        padding: 12px;
        flex-grow: 1;
        overflow-y: auto;
    }

    #chat-form {
        padding: 12px;
    }

    .form-control {
        font-size: 16px;
        padding: 14px;
    }

    #chat-form button {
        font-size: 16px;
        padding: 14px 18px;
    }

    /* ✅ Nasconde l'icona quando la chat è aperta su mobile */
    .chat-popup[style*="display: flex"] + .chatbot-icon {
        display: none;
    }
}
