.chat-header {
        background: #075e54;
        color: white;
        padding: 15px 20px;
        display: flex;
        align-items: center;
        gap: 10px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        position: fixed;
        top: 64px;
        z-index: 9999;
        width: 100%;
    }

    .chat-header h1 {
        font-size: 18px;
        font-weight: 500;
        margin: 0;
    }

    .chat-container {
        display: flex;
        flex-direction: column;
        max-width: 100%;
        margin: 0 auto;
        background: #fff;
        box-shadow: 0 0 10px rgba(0,0,0,0.1);
        border-radius: 8px;
        overflow: hidden;
        position: fixed;
        bottom: 0;
        width: 100%;
        height: calc(100vh - 64px);
    }

    .chat-messages {
        flex: 1;
        overflow-y: auto;
        padding: 120px 20px 120px 20px; /* Padding per header e input fissi */
        background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="pattern" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="1" fill="%23ffffff" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23pattern)"/></svg>');
        background-color: #e5ddd5;
        scroll-behavior: smooth;
    }

    .message {
        margin-bottom: 20px;
        display: flex;
        flex-direction: column;
        clear: both;
        position: relative;
        transition: all 0.3s ease;
    }

    .message.sent {
        align-items: flex-end;
    }

    .message.received {
        align-items: flex-start;
    }

    .message-bubble {
        max-width: 85%;
        padding: 12px 16px;
        border-radius: 18px;
        word-wrap: break-word;
        position: relative;
        line-height: 1.4;
        transition: background-color 0.5s ease;
    }

    .message.sent .message-bubble {
        background: #dcf8c6;
        margin-right: 10px;
    }

    .message.received .message-bubble {
        background: white;
        margin-left: 10px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

    /* NUOVO: Badge sovrapposto come notifica */
    .message-status-badge {
        position: absolute;
        top: -18px;
        right: 5px;
        font-size: 10px;
        padding: 4px 8px;
        border-radius: 12px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.15);
        z-index: 10;
        display: flex;
        align-items: center;
        gap: 3px;
        min-width: fit-content;
        white-space: nowrap;
        animation: badgeAppear 0.3s ease-out;
    }

    @keyframes badgeAppear {
        from {
            opacity: 0;
            transform: scale(0.8) translateY(-5px);
        }
        to {
            opacity: 1;
            transform: scale(1) translateY(0);
        }
    }

    /* Posizionamento per messaggi inviati */
    .message.sent .message-status-badge {
        right: 15px; /* Compensazione per il margin del bubble */
    }

    .status-selected {
        background: linear-gradient(135deg, #17a2b8, #138496);
        color: white;
        border: 2px solid #ffffff;
    }

    .status-answered {
        background: linear-gradient(135deg, #28a745, #1e7e34);
        color: white;
        border: 2px solid #ffffff;
    }

    /* Nasconde il badge per stato "In attesa" */
    .status-waiting {
        display: none;
    }

    .message-time {
        font-size: 11px;
        color: #666;
        margin-top: 5px;
        padding: 0 10px;
    }

    .chat-input-container {
        padding: 15px 20px;
        background: #f0f0f0;
        display: flex;
        align-items: flex-end;
        gap: 10px;
        border-top: 1px solid #ddd;
        position: fixed;
        bottom: 0;
        width: 100%;
        z-index: 1000;
    }

    .chat-input {
        flex: 1;
        padding: 12px 16px;
        border: none;
        border-radius: 20px;
        background: white;
        font-size: 16px;
        outline: none;
        resize: none;
        min-height: 20px;
        max-height: 100px;
        overflow-y: auto;
        font-family: inherit;
    }

    .chat-input:focus {
        box-shadow: 0 0 0 2px #075e54;
    }

    .send-button {
        background: #075e54;
        color: white;
        border: none;
        border-radius: 50%;
        width: 45px;
        height: 45px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s;
        font-size: 18px;
        flex-shrink: 0;
    }

    .send-button:hover:not(:disabled) {
        background: #128c7e;
    }

    .send-button:disabled {
        background: #ccc;
        cursor: not-allowed;
        opacity: 0.6;
    }

    .loading {
        display: none;
        text-align: center;
        padding: 20px;
        color: #666;
    }

    .typing-indicator {
        display: none;
        padding: 10px 20px;
        font-style: italic;
        color: #666;
        font-size: 14px;
    }

    /* Scrollbar personalizzata */
    .chat-messages::-webkit-scrollbar {
        width: 6px;
    }

    .chat-messages::-webkit-scrollbar-track {
        background: #f1f1f1;
    }

    .chat-messages::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }

    .chat-messages::-webkit-scrollbar-thumb:hover {
        background: #a1a1a1;
    }

    /* Animazione per i badge che appaiono */
    .message-status-badge {
        animation: badgeAppear 0.3s ease-out;
    }

    @keyframes badgeAppear {
        from {
            opacity: 0;
            transform: scale(0.8) translateY(-5px);
        }
        to {
            opacity: 1;
            transform: scale(1) translateY(0);
        }
    }