/* Chatbot Analisi e Prove - Stili */

* {
    box-sizing: border-box;
}


:root {
    --chatbot-window-bottom: 90px;
    --chatbot-window-height: 550px;
    --chatbot-button-gap: 8px; /* distanza tra finestra e pulsante quando la chat è aperta */
}

/* Pulsante chat fluttuante */
#chatbot-button {
    position: fixed;
    bottom: 120px;  /* ABBASSATO */
    left: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 9999;
    border: none;
}

/* Quando la chat è aperta, sposta il pulsante (che diventa una X) sopra la finestra per non coprire l'input */
#chatbot-button.active {
    bottom: calc(var(--chatbot-window-bottom) + var(--chatbot-window-height) + var(--chatbot-button-gap));
}

/* Badge "Hai domande?" */
.chatbot-badge {
    position: fixed;
    bottom: 125px;
    left: 90px;
    background: white;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    white-space: nowrap;
    animation: bounce 2s infinite;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.chatbot-badge.hidden {
    display: none;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

#chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#chatbot-button svg {
    width: 30px;
    height: 30px;
    fill: white;
}

#chatbot-button .close-icon {
    display: none;
}

#chatbot-button.active .chat-icon {
    display: none;
}

#chatbot-button.active .close-icon {
    display: block;
}

/* Finestra chat */
#chatbot-window {
    position: fixed;
    bottom: var(--chatbot-window-bottom);
    left: 20px;  /* SPOSTATA A SINISTRA */
    width: 380px;
    height: var(--chatbot-window-height);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#chatbot-window.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header chat */
.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #667eea;
    font-size: 16px;
}

.chatbot-info h3 {
    font-size: 16px;
    margin: 0 0 2px 0;
    font-weight: 600;
}

.chatbot-info p {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

/* Area messaggi */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

.chatbot-message {
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chatbot-message.bot {
    display: flex;
    gap: 10px;
}

.chatbot-message.user {
    display: flex;
    justify-content: flex-end;
}

.chatbot-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.chatbot-message.bot .chatbot-message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chatbot-message.user .chatbot-message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-bot-avatar {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

/* Suggerimenti rapidi */
.chatbot-quick-replies {
    padding: 10px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    overflow-x: auto;
    white-space: nowrap;
}

.chatbot-quick-reply {
    display: inline-block;
    padding: 8px 16px;
    margin-right: 8px;
    background: #f0f2ff;
    color: #667eea;
    border: 1px solid #667eea;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chatbot-quick-reply:hover {
    background: #667eea;
    color: white;
}

/* Area input */
.chatbot-input-area {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e9ecef;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.chatbot-input:focus {
    border-color: #667eea;
}

.chatbot-send-button {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.chatbot-send-button:hover {
    transform: scale(1.1);
}

.chatbot-send-button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.chatbot-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chatbot-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Link nel messaggio */
.chatbot-message-bubble a {
    color: inherit;
    text-decoration: underline;
}

.chatbot-message.bot .chatbot-message-bubble a {
    color: #667eea;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 480px) {
    :root {
        --chatbot-window-bottom: var(--chatbot-window-bottom);
        --chatbot-window-height: 450px;
        --chatbot-button-gap: 12px;
    }

    #chatbot-window {
        width: calc(100vw - 20px);
        height: var(--chatbot-window-height);  /* RIDOTTA anche su mobile */
        left: 10px;
        bottom: var(--chatbot-window-bottom);
    }
    
    #chatbot-button {
        bottom: 80px;  /* ABBASSATO su mobile */
        left: 15px;
    }
    
    .chatbot-badge {
        bottom: 85px;
        left: 80px;
        font-size: 12px;
        padding: 6px 12px;
    }
}