/* =========================================================
   IL MILLENNIO AI
   Interfaccia principale
   ========================================================= */

.millennio-ai {
    width: 100%;
    max-width: 820px;
    height: min(760px, 80vh);
    min-height: 560px;
    margin: 30px auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;

    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.06);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    color: #1f2937;
}


/* =========================================================
   HEADER
   ========================================================= */

.millennio-ai-header {
    flex-shrink: 0;

    padding: 18px 24px 16px;

    background: #ffffff;
    border-bottom: 1px solid #eeeeee;
}

.millennio-ai-header h2 {
    margin: 0;

    color: #111827;

    font-size: 22px;
    line-height: 1.2;
    font-weight: 650;
    letter-spacing: -0.3px;
}

.millennio-ai-header p {
    margin: 5px 0 0;

    color: #6b7280;

    font-size: 12px;
    line-height: 1.4;
}


/* =========================================================
   AREA MESSAGGI
   ========================================================= */

.millennio-ai-messages {
    flex: 1;
    min-height: 0;

    padding: 28px 24px;

    overflow-y: auto;
    overflow-x: hidden;

    background: #ffffff;

    scroll-behavior: smooth;
}


/* scrollbar */

.millennio-ai-messages::-webkit-scrollbar {
    width: 7px;
}

.millennio-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.millennio-ai-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.millennio-ai-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}


/* =========================================================
   MESSAGGI
   ========================================================= */

.millennio-ai-message {
    max-width: 760px;

    margin: 0 auto 22px;

    padding: 0;

    font-size: 15px;
    line-height: 1.6;

    word-wrap: break-word;
}


/* messaggio AI */

.millennio-ai-message.ai {
    color: #1f2937;
}


/* messaggio utente */

.millennio-ai-message.user {
    max-width: 760px;

    margin-top: 8px;
    margin-bottom: 22px;

    padding: 11px 15px;

    background: #f3f4f6;

    border-radius: 12px;

    color: #111827;
}


/* =========================================================
   INDICATORE "STA PENSANDO"
   ========================================================= */

.millennio-ai-thinking {
    max-width: 760px;

    margin: 0 auto 22px;

    color: #6b7280;

    font-size: 14px;
    line-height: 1.5;
}

.millennio-ai-thinking .dots {
    display: inline-block;

    width: 0;

    overflow: hidden;

    vertical-align: bottom;

    animation: millennioDots 1.2s infinite steps(4);
}

@keyframes millennioDots {

    0% {
        width: 0;
    }

    50% {
        width: 10px;
    }

    100% {
        width: 24px;
    }
}


/* =========================================================
   AREA INPUT
   ========================================================= */

.millennio-ai-form {
    flex-shrink: 0;

    display: flex;
    align-items: center;
    gap: 10px;

    padding: 14px 18px;

    background: #ffffff;

    border-top: 1px solid #eeeeee;
}


/* campo */

.millennio-ai-input {
    flex: 1;
    min-width: 0;

    height: 46px;

    box-sizing: border-box;

    padding: 0 15px;

    background: #ffffff;

    border: 1px solid #d1d5db;
    border-radius: 12px;

    outline: none;

    color: #111827;

    font-family: inherit;
    font-size: 15px;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.millennio-ai-input::placeholder {
    color: #9ca3af;
}

.millennio-ai-input:focus {
    border-color: #9ca3af;

    box-shadow:
        0 0 0 3px rgba(156, 163, 175, 0.12);
}


/* pulsante */

.millennio-ai-submit {
    flex-shrink: 0;

    width: 46px;
    height: 46px;

    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 12px;

    background: #111827;
    color: #ffffff;

    cursor: pointer;

    font-size: 18px;
    line-height: 1;

    transition:
        background 0.15s ease,
        transform 0.1s ease;
}

.millennio-ai-submit:hover {
    background: #374151;
}

.millennio-ai-submit:active {
    transform: scale(0.96);
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    .millennio-ai {
        width: 100%;

        height: 78vh;
        min-height: 480px;

        margin: 15px 0;

        border-radius: 12px;
    }

    .millennio-ai-header {
        padding: 15px 16px 13px;
    }

    .millennio-ai-header h2 {
        font-size: 20px;
    }

    .millennio-ai-messages {
        padding: 22px 15px;
    }

    .millennio-ai-message {
        font-size: 15px;
        margin-bottom: 20px;
    }

    .millennio-ai-message.user {
        padding: 10px 13px;
    }

    .millennio-ai-form {
        padding: 10px;
        gap: 8px;
    }

    .millennio-ai-input {
        height: 44px;
        font-size: 16px;
    }

    .millennio-ai-submit {
        width: 44px;
        height: 44px;
    }
}


/* =========================================================
   MOBILE MOLTO STRETTO
   ========================================================= */

@media (max-width: 400px) {

    .millennio-ai {
        margin: 8px 0;
        border-radius: 10px;
    }

    .millennio-ai-header h2 {
        font-size: 19px;
    }

    .millennio-ai-header p {
        font-size: 11px;
    }

    .millennio-ai-messages {
        padding: 18px 12px;
    }
}

/* =========================================================
   PULSANTE CHIEDI A IL MILLENNIO AI
   ========================================================= */

.millennio-ai-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 10px 15px;

    background: #ffffff;

    border: 1px solid #d1d5db;
    border-radius: 10px;

    color: #1f2937;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    font-size: 14px;
    font-weight: 500;

    line-height: 1.3;

    text-decoration: none;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.millennio-ai-button:hover {
    background: #f9fafb;

    border-color: #9ca3af;

    color: #111827;

    text-decoration: none;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.05);
}

.millennio-ai-button-icon {
    color: #6b7280;

    font-size: 13px;
}

/* =========================================================
   PULSANTE VOLANTE
   ========================================================= */

.millennio-ai-button-floating {
    position: fixed !important;

    right: 24px !important;
    bottom: 24px !important;

    left: auto !important;

    z-index: 999999 !important;

    width: auto !important;
    max-width: calc(100vw - 48px);

    box-sizing: border-box;

    box-shadow:
        0 4px 18px rgba(0, 0, 0, 0.12);
}

.millennio-ai-button-floating:hover {
    box-shadow:
        0 6px 22px rgba(0, 0, 0, 0.16);
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    .millennio-ai-button-floating {
        right: 14px !important;
        bottom: 14px !important;

        max-width: calc(100vw - 28px);

        padding: 10px 13px;

        font-size: 13px;
    }

}

  
 /* =========================================================
   MODALITÀ MOBILE — INPUT VICINO ALLA CONVERSAZIONE
   ========================================================= */

@media (max-width: 700px) {

    .millennio-ai {
        height: auto;
        min-height: 0;

        max-height: none;

        margin: 10px 0;

        overflow: visible;
    }

    .millennio-ai-messages {
        flex: none;

        height: auto;
        min-height: 0;

        max-height: none;

        overflow: visible;

        padding: 20px 15px 10px;
    }

    .millennio-ai-form {
        position: relative;

        flex-shrink: 0;

        margin: 0;

        border-top: 0;

        padding: 8px 10px 14px;

        background: #ffffff;
    }

}

/* =========================================================
   STATISTICHE IL MILLENNIO AI
   ========================================================= */

.millennio-ai-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;

    margin: 8px 15px 18px;

    font-size: 12px;
    line-height: 1.5;

    color: #777;
    text-align: center;
}

.millennio-ai-stats strong {
    font-weight: 700;
    color: #333;
}

.millennio-ai-stats span:not(:last-child)::after {
    content: "·";
    margin-left: 14px;
    color: #aaa;
}

@media (max-width: 700px) {

    .millennio-ai-stats {
        gap: 3px 8px;
        margin: 7px 10px 15px;
        font-size: 11px;
    }

    .millennio-ai-stats span:not(:last-child)::after {
        margin-left: 8px;
    }

}

/* =========================================================
   WIDGET FLOTTANTE IL MILLENNIO AI
   ========================================================= */

.millennio-ai-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;

    z-index: 999999;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}


/* =========================================================
   PULSANTE
   ========================================================= */

.millennio-ai-widget-trigger {
    display: flex;
    align-items: center;
    gap: 9px;

    min-height: 48px;

    padding: 0 17px;

    border: 0;
    border-radius: 14px;

    background: #111827;
    color: #ffffff;

    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.18);

    cursor: pointer;

    font-family: inherit;
    font-size: 14px;
    font-weight: 600;

    transition:
        background 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.millennio-ai-widget-trigger:hover {
    background: #374151;

    transform: translateY(-1px);

    box-shadow:
        0 10px 32px rgba(0, 0, 0, 0.22);
}

.millennio-ai-widget-trigger-icon {
    font-size: 16px;
}


/* =========================================================
   FINESTRA
   ========================================================= */

.millennio-ai-widget-window {
    position: absolute;

    right: 0;
    bottom: 62px;

    width: 360px;
    height: 520px;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 18px;

    box-shadow:
        0 18px 55px rgba(0, 0, 0, 0.18);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform:
        translateY(10px)
        scale(0.98);

    transform-origin: bottom right;

    transition:
        opacity 0.15s ease,
        transform 0.15s ease,
        visibility 0.15s ease;
}


/* aperta */

.millennio-ai-widget.is-open
.millennio-ai-widget-window {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transform:
        translateY(0)
        scale(1);
}


/* =========================================================
   HEADER
   ========================================================= */

.millennio-ai-widget-header {
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 15px 16px;

    border-bottom: 1px solid #eeeeee;

    background: #ffffff;
}

.millennio-ai-widget-header strong {
    display: block;

    color: #111827;

    font-size: 14px;
}

.millennio-ai-widget-header span {
    display: block;

    margin-top: 2px;

    color: #6b7280;

    font-size: 11px;
}

.millennio-ai-widget-close {
    width: 32px;
    height: 32px;

    padding: 0;

    border: 0;
    border-radius: 8px;

    background: transparent;
    color: #6b7280;

    cursor: pointer;

    font-size: 22px;
    line-height: 1;
}

.millennio-ai-widget-close:hover {
    background: #f3f4f6;
    color: #111827;
}


/* =========================================================
   MESSAGGI
   ========================================================= */

.millennio-ai-widget-messages {
    flex: 1;
    min-height: 0;

    padding: 18px;

    overflow-y: auto;

    background: #ffffff;
}


/* =========================================================
   INPUT
   ========================================================= */

.millennio-ai-widget-form {
    flex-shrink: 0;

    display: flex;
    align-items: center;
    gap: 8px;

    padding: 10px;

    border-top: 1px solid #eeeeee;

    background: #ffffff;
}

.millennio-ai-widget-input {
    flex: 1;
    min-width: 0;

    height: 42px;

    box-sizing: border-box;

    padding: 0 12px;

    border: 1px solid #d1d5db;
    border-radius: 10px;

    outline: none;

    color: #111827;

    font-family: inherit;
    font-size: 14px;
}

.millennio-ai-widget-input:focus {
    border-color: #9ca3af;

    box-shadow:
        0 0 0 3px rgba(156, 163, 175, 0.12);
}

.millennio-ai-widget-submit {
    flex-shrink: 0;

    width: 42px;
    height: 42px;

    padding: 0;

    border: 0;
    border-radius: 10px;

    background: #111827;
    color: #ffffff;

    cursor: pointer;

    font-size: 17px;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    .millennio-ai-widget {
        right: 14px;
        bottom: 14px;
    }

    .millennio-ai-widget-window {
        right: 0;
        bottom: 58px;

        width: min(
            360px,
            calc(100vw - 28px)
        );

        height: min(
            520px,
            calc(100vh - 90px)
        );
    }

    .millennio-ai-widget-trigger {
        min-height: 46px;

        padding: 0 14px;

        font-size: 13px;
    }

}
 
/* =====================================================
   WIDGET IL MILLENNIO AI
   ===================================================== */

.millennio-ai-widget {
    width: 100%;
    box-sizing: border-box;
    padding: 18px;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}


/* Titolo */

.millennio-ai-widget-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;

    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.millennio-ai-widget-icon {
    color: #d71920;
    font-size: 20px;
}


/* Area messaggi */

.millennio-ai-widget-messages {
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 12px;
}


/* Messaggi */

.millennio-ai-widget .millennio-ai-message {
    margin-bottom: 8px;
    padding: 9px 11px;

    border-radius: 9px;

    font-size: 14px;
    line-height: 1.4;
}

.millennio-ai-widget .millennio-ai-message.ai {
    background: #f3f3f3;
    color: #222;
}


/* Form */

.millennio-ai-widget-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}


/* Textbox */

.millennio-ai-widget-input {
    width: 100%;
    min-height: 42px;
    box-sizing: border-box;

    padding: 10px 12px;

    border: 1px solid #ccc;
    border-radius: 8px;

    background: #fff;
    color: #222;

    font-size: 14px;

    outline: none;
}

.millennio-ai-widget-input:focus {
    border-color: #d71920;
}


/* Pulsante */

.millennio-ai-widget-submit {
    width: 100%;

    min-height: 40px;

    border: 0;
    border-radius: 8px;

    background: #d71920;
    color: #fff;

    font-size: 13px;
    font-weight: 700;

    cursor: pointer;
}

.millennio-ai-widget-submit:hover {
    background: #b9151b;
}


/* Thinking */

.millennio-ai-widget .millennio-ai-thinking {
    padding: 8px 10px;

    color: #777;
    font-size: 13px;
    font-style: italic;
}

