/* ── Launcher flottante ── */
.mg-chat-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1050;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #C9A84C, #b8973f);
    color: #081D35;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    cursor: pointer;
    transition: transform .15s ease, opacity .2s ease;
}

.mg-chat-fab:hover {
    transform: translateY(-2px);
}

.mg-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(.9);
}

/* ── Pannello laterale (drawer) collassabile ── */
.mg-chat {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1060;
    height: 100vh;
    height: 100dvh;   /* iOS: si adatta a barre/tastiera; JS bindViewport affina l'altezza */
    width: 380px;
    max-width: 92vw;
    display: flex;
    flex-direction: column;
    background: #0c223d;
    color: #eef2f7;
    box-shadow: -10px 0 40px rgba(0, 0, 0, .4);
    transform: translateX(105%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}

.mg-chat-open {
    transform: translateX(0);
}

.mg-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #081D35;
    border-bottom: 1px solid rgba(201, 168, 76, .3);
}

.mg-chat-tabs {
    display: flex;
    gap: 4px;
}

.mg-chat-tabs button {
    background: none;
    border: none;
    color: #9fb0c3;
    font-size: .82rem;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 8px;
    cursor: pointer;
}

.mg-chat-tabs button:hover {
    color: #e7d9ac;
}

.mg-tab-on {
    color: #081D35 !important;
    background: #C9A84C !important;
}

.mg-chat-close {
    background: none;
    border: none;
    color: #9fb0c3;
    font-size: 1.1rem;
    cursor: pointer;
}

.mg-chat-close:hover {
    color: #fff;
}

/* Corpo scrollabile */
.mg-chat-msgs {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mg-chat-hello {
    background: rgba(255, 255, 255, .05);
    border-radius: 12px;
    padding: 14px;
    font-size: .92rem;
    line-height: 1.5;
    color: #cdd8e6;
}

.mg-chat-sugg {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mg-chat-sugg button {
    background: rgba(201, 168, 76, .12);
    border: 1px solid rgba(201, 168, 76, .35);
    color: #e7d9ac;
    border-radius: 999px;
    padding: 5px 11px;
    font-size: .8rem;
    cursor: pointer;
}

.mg-chat-sugg button:hover {
    background: rgba(201, 168, 76, .25);
}

/* Bolle */
.mg-msg {
    max-width: 85%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: .92rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.mg-msg-user {
    align-self: flex-end;
    background: #C9A84C;
    color: #081D35;
    border-bottom-right-radius: 4px;
}

.mg-msg-bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, .08);
    color: #eef2f7;
    border-bottom-left-radius: 4px;
}

.mg-msg-bot a {
    color: #f0dfa6;
    text-decoration: underline;
}

/* Risultati di navigazione */
.mg-results {
    align-self: stretch;
    margin-top: 4px;
}

.mg-results-h {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #8ea3ba;
    margin: 6px 2px;
}

.mg-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    border-left: 3px solid #C9A84C;
    border-radius: 10px;
    text-decoration: none;
    color: #eef2f7;
    transition: background .15s ease;
}

.mg-result:hover {
    background: rgba(201, 168, 76, .15);
}

.mg-result-sentence {
    border-left-color: #6fa8dc;
}

.mg-result-author {
    border-left-color: #b58bd6;
}

.mg-result-tag {
    border-left-color: #7fb98a;
}

.mg-result-ico {
    font-size: 1.1rem;
    flex: 0 0 auto;
}

.mg-result-tx {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mg-result-t {
    font-size: .88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mg-result-s {
    font-size: .76rem;
    color: #9fb0c3;
}

/* Footer input */
.mg-chat-foot {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    background: #0a1e37;
}

.mg-chat-foot textarea {
    flex: 1 1 auto;
    resize: none;
    max-height: 110px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .15);
    background: #0c223d;
    color: #eef2f7;
    padding: 9px 11px;
    font-size: .92rem;
}

.mg-chat-foot textarea:focus {
    outline: none;
    border-color: #C9A84C;
}

.mg-send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: #C9A84C;
    color: #081D35;
    font-size: 1.05rem;
    cursor: pointer;
}

.mg-send:disabled {
    opacity: .5;
    cursor: default;
}

/* Indicatore "sta scrivendo" */
.mg-typing {
    display: inline-flex;
    gap: 4px;
}

.mg-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9fb0c3;
    animation: mg-blink 1.2s infinite both;
}

.mg-typing span:nth-child(2) { animation-delay: .2s; }
.mg-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes mg-blink {
    0%, 80%, 100% { opacity: .25; }
    40% { opacity: 1; }
}

.mg-chat-warn {
    padding: 8px 12px;
    font-size: .78rem;
    background: #5a1d1d;
    color: #ffd7d7;
}

/* Contatto: campi nome/email + bolle thread */
.mg-contact-id {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.mg-ci {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .15);
    background: #0c223d;
    color: #eef2f7;
    padding: 7px 10px;
    font-size: .85rem;
}

.mg-ci:focus {
    outline: none;
    border-color: #C9A84C;
}

.mg-ci-err {
    border-color: #e06666;
}

.mg-contact-err {
    font-size: .78rem;
    color: #ffb3b3;
}

.mg-msg .mg-from {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    color: #C9A84C;
    margin-bottom: 2px;
}

.mg-msg .mg-when {
    display: block;
    font-size: .68rem;
    opacity: .6;
    margin-top: 3px;
}

.mg-msg-user .mg-when {
    text-align: right;
}

.mg-note {
    align-self: center;
    font-size: .8rem;
    color: #9fe0b0;
    background: rgba(80, 200, 120, .1);
    border: 1px solid rgba(80, 200, 120, .3);
    border-radius: 10px;
    padding: 7px 12px;
}
