/* Q-Bot Project Assistant: usa i token del sito (modern.css). Tutte le classi hanno prefisso qa- per non toccare il resto. */

/* ---------- pulsante flottante ---------- */
.qa-launcher {
    position: fixed; right: max(1.1rem, env(safe-area-inset-right, 0px)); bottom: max(1.1rem, env(safe-area-inset-bottom, 0px)); z-index: 1150;
    display: inline-flex; align-items: center; gap: .55rem; padding: .7rem 1.1rem .7rem .8rem; border: 0; border-radius: 999px; cursor: pointer;
    font: inherit; font-size: .92rem; font-weight: 650; letter-spacing: -.005em; color: #fff;
    background: linear-gradient(150deg, var(--navy, #0b1f4d) 0%, var(--navy-2, #13307a) 100%);
    box-shadow: 0 14px 34px -14px rgba(10, 31, 85, .7), inset 0 0 0 1px rgba(255, 255, 255, .12);
    transition: transform .25s var(--ease, ease), box-shadow .25s, bottom .3s var(--ease, ease);
}
.qa-launcher__icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--grad-brand, #2575fc); }
.qa-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -14px rgba(10, 31, 85, .8), inset 0 0 0 1px rgba(255, 255, 255, .2); }
.qa-launcher:focus-visible { outline: 3px solid var(--accent-2, #2575fc); outline-offset: 3px; }
/* la barra "suggerimento lingua" sta in basso: il pulsante si sposta sopra */
body:has(.lang-suggest.is-visible) .qa-launcher { bottom: 5.25rem; }
.qa-is-open .qa-launcher { opacity: 0; pointer-events: none; }
@media (max-width: 640px) {
    .qa-launcher { padding: .6rem; }
    .qa-launcher__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .qa-launcher__icon { width: 34px; height: 34px; }
}
@media print { .qa-launcher, .qa-root { display: none !important; } }

/* ---------- finestra ---------- */
.qa-root { position: fixed; inset: 0; z-index: 3500; hyphens: manual; -webkit-hyphens: manual; }
.qa-root[hidden] { display: none; }
.qa-backdrop { position: absolute; inset: 0; background: rgba(6, 18, 48, .35); opacity: 0; transition: opacity .22s ease; }
.qa-dialog {
    position: absolute; right: max(1.1rem, env(safe-area-inset-right, 0px)); bottom: max(1.1rem, env(safe-area-inset-bottom, 0px));
    width: min(420px, calc(100vw - 2.2rem)); height: min(640px, calc(100dvh - 2.2rem));
    display: flex; flex-direction: column; overflow: hidden; border-radius: 22px; background: #fff; color: var(--ink, #0b1b3a);
    box-shadow: 0 40px 90px -30px rgba(6, 18, 48, .6), 0 0 0 1px rgba(10, 31, 85, .08);
    opacity: 0; transform: translateY(14px) scale(.985); transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s var(--ease, ease);
    font-family: var(--font-family-sans, inherit);
}
.qa-root.is-open .qa-backdrop { opacity: 1; }
.qa-root.is-open .qa-dialog { opacity: 1; transform: none; }
@media (min-width: 641px) { .qa-backdrop { background: rgba(6, 18, 48, .18); } }
@media (max-width: 640px) {
    .qa-dialog { inset: 0; right: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; transform: translateY(24px); }
}
@media (prefers-reduced-motion: reduce) { .qa-dialog, .qa-backdrop, .qa-launcher { transition: none; } }

.qa-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1rem 1rem 1.2rem;
    padding-top: max(1rem, env(safe-area-inset-top, 0px));
    color: #fff; background: linear-gradient(150deg, var(--navy, #0b1f4d) 0%, var(--navy-2, #13307a) 100%);
}
.qa-head__brand { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.qa-head__icon { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 12px; background: var(--grad-brand, #2575fc); }
.qa-head__eyebrow { margin: 0; font-size: .68rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: #8dbbff; }
.qa-head__title { margin: .1rem 0 0; font-size: 1.05rem; font-weight: 750; letter-spacing: -.01em; color: #fff; line-height: 1.2; text-align: left; }
.qa-close {
    display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
    font-size: 1.6rem; line-height: 1; color: #fff; background: rgba(255, 255, 255, .1); transition: background .2s;
}
.qa-close:hover { background: rgba(255, 255, 255, .2); }
.qa-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.qa-progress { display: none; align-items: center; gap: .75rem; padding: .7rem 1.2rem; border-bottom: 1px solid var(--color-border, #e3e8f2); }
.qa-dialog.has-progress .qa-progress { display: flex; }
.qa-progress__track { flex: 1; height: 4px; border-radius: 99px; background: rgba(37, 117, 252, .12); overflow: hidden; }
.qa-progress__bar { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad-brand, #2575fc); transition: width .35s var(--ease, ease); }
.qa-progress__text { font-size: .75rem; font-weight: 600; color: var(--color-secondary, #5a6478); white-space: nowrap; font-variant-numeric: tabular-nums; }

.qa-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 1.3rem 1.2rem 1.2rem; -webkit-overflow-scrolling: touch; }
.qa-view { display: flex; flex-direction: column; gap: .9rem; min-height: 100%; animation: qaIn .28s var(--ease, ease) both; }
@keyframes qaIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .qa-view { animation: none; } }

/* domanda: "fumetto" tecnico, non da chatbot commerciale */
.qa-q {
    position: relative; margin: 0; padding: .95rem 1.05rem; border-radius: 4px 16px 16px 16px; outline: none;
    font-size: 1.02rem; font-weight: 650; line-height: 1.45; color: var(--ink, #0b1b3a);
    background: rgba(37, 117, 252, .07); border-left: 3px solid var(--accent-2, #2575fc); text-align: left;
}
.qa-q--lead { font-weight: 600; font-size: 1rem; }
.qa-note { margin: 0; font-size: .9rem; line-height: 1.5; color: var(--color-secondary, #5a6478); text-align: left; }
.qa-tag { align-self: flex-start; margin: -.35rem 0 0; padding: .15rem .55rem; border-radius: 99px; font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: var(--color-secondary, #5a6478); background: #f1f4fa; }
.qa-notice { margin: 0; padding: .85rem 1rem; border-radius: 12px; font-size: .88rem; line-height: 1.5; color: var(--ink, #0b1b3a); background: #f4f7fc; border: 1px solid var(--color-border, #e3e8f2); text-align: left; }

.qa-options { display: grid; gap: .5rem; }
.qa-option {
    width: 100%; padding: .8rem 1rem; border-radius: 12px; cursor: pointer; text-align: left;
    font: inherit; font-size: .95rem; font-weight: 600; line-height: 1.35; color: var(--ink, #0b1b3a);
    background: #fff; border: 1.5px solid var(--color-border, #dfe5f0);
    transition: border-color .18s, background .18s, transform .18s var(--ease, ease);
}
.qa-option:hover { border-color: rgba(37, 117, 252, .55); background: rgba(37, 117, 252, .04); }
.qa-option:focus-visible { outline: 3px solid rgba(37, 117, 252, .35); outline-offset: 1px; }
.qa-option.is-selected { border-color: var(--accent-2, #2575fc); background: rgba(37, 117, 252, .08); }
.qa-option--soft { border-style: dashed; }
.qa-option--check { position: relative; padding-left: 2.6rem; }
.qa-option--check::before {
    content: ""; position: absolute; left: 1rem; top: 50%; width: 1.05rem; height: 1.05rem; margin-top: -.525rem; border-radius: 5px;
    border: 1.5px solid #b9c4d8; background: #fff; transition: background .18s, border-color .18s;
}
.qa-option--check.is-selected::before { border-color: var(--accent-2, #2575fc); background: var(--accent-2, #2575fc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5 6.5 11.5 12.5 4.5' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 80% no-repeat; }

.qa-field { display: flex; flex-direction: column; gap: .35rem; }
.qa-field label, .qa-label { margin: 0; font-size: .85rem; font-weight: 650; color: var(--ink, #0b1b3a); text-align: left; }
.qa-input {
    width: 100%; padding: .75rem .9rem; border-radius: 12px; font: inherit; font-size: 1rem; line-height: 1.45; color: var(--ink, #0b1b3a);
    background: #fff; border: 1.5px solid var(--color-border, #dfe5f0); resize: vertical; transition: border-color .18s, box-shadow .18s;
}
textarea.qa-input { min-height: 7.5rem; }
.qa-input:focus { outline: none; border-color: var(--accent-2, #2575fc); box-shadow: 0 0 0 3px rgba(37, 117, 252, .15); }
.qa-counter { margin: -.5rem 0 0; min-height: 1em; font-size: .75rem; color: var(--color-secondary, #5a6478); text-align: right; }

.qa-chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.qa-chip { padding: .5rem 1rem; border-radius: 99px; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 600; color: var(--ink, #0b1b3a); background: #fff; border: 1.5px solid var(--color-border, #dfe5f0); }
.qa-chip.is-selected { border-color: var(--accent-2, #2575fc); background: rgba(37, 117, 252, .08); }
.qa-chip:focus-visible { outline: 3px solid rgba(37, 117, 252, .35); outline-offset: 1px; }

.qa-consent { display: flex; gap: .7rem; align-items: flex-start; text-align: left; }
.qa-check { flex: none; width: 1.2rem; height: 1.2rem; margin: .1rem 0 0; accent-color: var(--accent-2, #2575fc); }
.qa-consent label { font-size: .9rem; line-height: 1.45; color: var(--ink, #0b1b3a); }
.qa-consent a { color: var(--accent-2, #2575fc); font-weight: 650; }
.qa-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

.qa-error { margin: 0; padding: .7rem .9rem; border-radius: 10px; font-size: .88rem; line-height: 1.45; color: #8a1c1c; background: #fdeeee; border: 1px solid #f5c6c6; text-align: left; }
.qa-error p { margin: 0; }
.qa-error p + p { margin-top: .35rem; }

/* riepilogo */
.qa-summary { margin: 0; border: 1px solid var(--color-border, #e3e8f2); border-radius: 14px; overflow: hidden; }
.qa-summary__row { display: grid; grid-template-columns: 1fr auto; gap: .15rem .75rem; padding: .7rem .9rem; text-align: left; }
.qa-summary__row + .qa-summary__row { border-top: 1px solid var(--color-border, #e3e8f2); }
.qa-summary dt { grid-column: 1; margin: 0; font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--color-secondary, #5a6478); }
.qa-summary dd { grid-column: 1; margin: 0; font-size: .93rem; line-height: 1.45; color: var(--ink, #0b1b3a); white-space: pre-line; overflow-wrap: anywhere; }
.qa-summary dd.is-empty { color: #97a1b3; font-style: italic; }
.qa-summary .qa-link { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.qa-link { padding: .35rem .5rem; border: 0; border-radius: 8px; cursor: pointer; background: none; font: inherit; font-size: .85rem; font-weight: 700; color: var(--accent-2, #2575fc); }
.qa-link:hover { background: rgba(37, 117, 252, .08); }
.qa-link:focus-visible { outline: 2px solid var(--accent-2, #2575fc); outline-offset: 1px; }

/* pulsanti */
.qa-nav { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: auto; padding-top: .6rem; }
.qa-nav__actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.qa-stack { display: grid; gap: .6rem; margin-top: .4rem; }
.qa-btn {
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; min-height: 44px; padding: .6rem 1.15rem;
    border-radius: 999px; cursor: pointer; text-decoration: none; font: inherit; font-size: .93rem; font-weight: 700; line-height: 1.2;
    border: 1.5px solid transparent; transition: background .2s, border-color .2s, box-shadow .2s, transform .2s var(--ease, ease);
}
.qa-btn:focus-visible { outline: 3px solid rgba(37, 117, 252, .4); outline-offset: 2px; }
.qa-btn--primary { color: #fff; background: var(--grad-brand, #2575fc); box-shadow: 0 10px 22px -12px rgba(37, 117, 252, .9); }
.qa-btn--primary:hover { transform: translateY(-1px); background: var(--grad-hover, #0a3fb8); }
.qa-btn--primary[disabled] { opacity: .7; cursor: progress; transform: none; }
.qa-btn--secondary { color: var(--ink, #0b1b3a); background: #fff; border-color: var(--color-border, #dfe5f0); text-align: center; }
.qa-btn--secondary:hover { border-color: rgba(37, 117, 252, .55); }
.qa-btn--secondary small { font-size: .78rem; font-weight: 600; color: var(--accent-2, #2575fc); }
.qa-btn--ghost { color: var(--color-secondary, #5a6478); background: none; padding-left: .6rem; padding-right: .6rem; }
.qa-btn--ghost:hover { color: var(--ink, #0b1b3a); background: #f1f4fa; }
.qa-btn--block { width: 100%; }
.qa-btn.is-busy { position: relative; }

.qa-view--done { align-items: stretch; text-align: center; }
.qa-done-icon { align-self: center; display: grid; place-items: center; width: 64px; height: 64px; margin-top: 1rem; border-radius: 50%; font-size: 1.9rem; font-weight: 800; color: #fff; background: var(--grad-brand, #2575fc); box-shadow: 0 16px 34px -16px rgba(37, 117, 252, .9); }
.qa-id { margin: 0; padding: .6rem .8rem; border-radius: 10px; font-size: .88rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink, #0b1b3a); background: #f4f7fc; }

.qa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* niente scroll della pagina sotto la finestra a schermo intero su smartphone */
@media (max-width: 640px) { html.qa-is-open, html.qa-is-open body { overflow: hidden; } }

/* il sito sillaba p e li (hyphens: auto): nell'assistente le parole restano intere */
.qa-root p, .qa-root li, .qa-root dd, .qa-root label, .qa-root button, .qa-root a { hyphens: manual; -webkit-hyphens: manual; }

/* schermi bassi (telefono in orizzontale, finestre ridotte): schermo intero con intestazione compatta,
   testo su una colonna di larghezza leggibile */
@media (max-height: 520px) {
    .qa-dialog { inset: 0; right: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; transform: translateY(16px); }
    .qa-root.is-open .qa-dialog { transform: none; }
    .qa-head { padding: .45rem max(.8rem, env(safe-area-inset-right, 0px)) .45rem max(1rem, env(safe-area-inset-left, 0px)); }
    .qa-head__eyebrow { display: none; }
    .qa-head__icon { width: 30px; height: 30px; border-radius: 9px; }
    .qa-head__title { margin: 0; font-size: .98rem; }
    .qa-close { width: 36px; height: 36px; font-size: 1.4rem; }
    .qa-progress { padding: .35rem max(1rem, env(safe-area-inset-right, 0px)) .35rem max(1rem, env(safe-area-inset-left, 0px)); }
    .qa-body { padding: .8rem max(1rem, env(safe-area-inset-right, 0px)) .8rem max(1rem, env(safe-area-inset-left, 0px)); }
    .qa-view { gap: .6rem; max-width: 640px; margin: 0 auto; }
    .qa-q { padding: .65rem .9rem; font-size: .95rem; }
    .qa-option { padding: .6rem .9rem; }
    textarea.qa-input { min-height: 4.5rem; }
    .qa-btn { min-height: 40px; padding: .5rem 1rem; }
    html.qa-is-open, html.qa-is-open body { overflow: hidden; }
}
/* schermi larghi a tutto schermo (tablet in verticale con finestra stretta esclusa): colonna centrata */
@media (max-width: 640px) { .qa-view { max-width: 640px; margin: 0 auto; } }

/* pulsanti Indietro/Avanti sempre visibili in fondo alla finestra, anche quando il contenuto scorre */
.qa-body { padding-bottom: max(1.2rem, env(safe-area-inset-bottom, 0px)); }
.qa-nav {
    position: sticky; bottom: calc(-1 * max(1.2rem, env(safe-area-inset-bottom, 0px))); z-index: 1;
    margin-bottom: calc(-1 * max(1.2rem, env(safe-area-inset-bottom, 0px)));
    padding: .75rem 0 max(1.2rem, env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, #fff 78%, rgba(255, 255, 255, 0));
}
@media (max-height: 520px) {
    .qa-body { padding-bottom: max(.8rem, env(safe-area-inset-bottom, 0px)); }
    .qa-nav {
        bottom: calc(-1 * max(.8rem, env(safe-area-inset-bottom, 0px)));
        margin-bottom: calc(-1 * max(.8rem, env(safe-area-inset-bottom, 0px)));
        padding: .5rem 0 max(.8rem, env(safe-area-inset-bottom, 0px));
    }
}
