/* =========================================================
   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;
    }

}

 
}
