/* ── CHAT FAQ ──
   Widget flottante con domande frequenti e fallback "contatta il team".
   Usa i token di landing.css (--navy-deep, --blue, --sky, --font-1, --font-2). */

.faq-chat {
    --faq-bottom: 24px;
    --faq-right: 24px;
    --faq-ink: var(--dark-blue, #0d1526);
    --faq-line: rgba(13, 21, 38, 0.1);
    --faq-bot: #eef3fb;
    position: fixed;
    right: var(--faq-right);
    bottom: var(--faq-bottom);
    z-index: 1000;
    font-family: var(--font-1, "Poppins"), sans-serif;
    color: var(--faq-ink);
}

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

/* ── launcher ── */
.faq-launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 0 20px 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--navy-deep, #000034);
    color: #fff;
    font: 600 0.92rem/1 var(--font-2, "Schibsted Grotesk"), sans-serif;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 12px 32px rgba(0, 0, 52, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    opacity: 0;
    transform: translateY(14px);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease, box-shadow 0.3s ease, background 0.3s ease;
}
.faq-chat.is-ready .faq-launcher { opacity: 1; transform: none; pointer-events: auto; }
.faq-chat.is-open .faq-launcher { opacity: 0; transform: translateY(14px); pointer-events: none; }
.faq-launcher:hover { background: #0a0a4a; box-shadow: 0 16px 38px rgba(0, 0, 52, 0.42), 0 0 0 1px rgba(93, 189, 230, 0.4) inset; }
.faq-launcher-icon { color: var(--sky, #5dbde6); flex-shrink: 0; transition: color 0.3s ease; }
/* sopra una sezione scura il navy si confonde con lo sfondo: il pulsante prende il blu dei bottoni della landing */
.faq-chat.is-on-dark .faq-launcher { background: var(--blue, #1a6bff); box-shadow: 0 12px 32px rgba(26, 107, 255, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.22) inset; }
.faq-chat.is-on-dark .faq-launcher:hover { background: #3a7fff; }
.faq-chat.is-on-dark .faq-launcher-icon { color: #fff; }
.faq-launcher:focus-visible,
.faq-close:focus-visible,
.faq-search-btn:focus-visible,
.faq-contact-link:focus-visible,
.faq-chip:focus-visible,
.faq-cta:focus-visible { outline: 3px solid var(--sky, #5dbde6); outline-offset: 3px; }

/* ── pannello ── */
.faq-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: min(392px, calc(100vw - 32px));
    height: min(620px, calc(100dvh - var(--faq-bottom) - 24px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 52, 0.35), 0 0 0 1px rgba(13, 21, 38, 0.08);
    transform-origin: bottom right;
}
.faq-panel[hidden] { display: none; }
.faq-chat.is-open .faq-panel { animation: faq-in 0.26s cubic-bezier(0.2, 0.8, 0.25, 1) both; }
@keyframes faq-in {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.faq-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 16px 18px;
    background: linear-gradient(135deg, #000034 0%, #083a7d 100%);
    color: #fff;
    flex-shrink: 0;
}
.faq-avatar { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }
.faq-head-text { flex: 1; min-width: 0; }
.faq-title { font: 700 1.05rem/1.2 var(--font-2, "Schibsted Grotesk"), sans-serif; letter-spacing: -0.01em; margin: 0; color: #fff; }
.faq-sub { margin: 2px 0 0; font-size: 0.78rem; color: rgba(255, 255, 255, 0.78); }
.faq-close {
    flex-shrink: 0;
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}
.faq-close:hover { background: rgba(255, 255, 255, 0.2); }

/* ── conversazione ── */
.faq-thread {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
    scroll-behavior: smooth;
    position: relative;
}
.faq-thread:focus-visible { outline-offset: -3px; }

.faq-msg {
    max-width: 88%;
    padding: 11px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
    animation: faq-pop 0.22s ease both;
}
@keyframes faq-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.faq-msg.bot  { align-self: flex-start; background: var(--faq-bot); border-bottom-left-radius: 5px; }
.faq-msg.user { align-self: flex-end; background: #0a52d9; color: #fff; border-bottom-right-radius: 5px; }
.faq-msg strong { font-weight: 600; }
.faq-msg ol, .faq-msg ul { margin: 8px 0 0; padding-left: 20px; }
.faq-msg li { margin: 4px 0; }
.faq-msg li::marker { color: #0a52d9; font-weight: 600; }

.faq-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.faq-typing i { width: 7px; height: 7px; border-radius: 50%; background: #6b7a99; animation: faq-dot 1s infinite ease-in-out; }
.faq-typing i:nth-child(2) { animation-delay: 0.15s; }
.faq-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes faq-dot { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* ── chip ── */
.faq-chips { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; max-width: 100%; animation: faq-pop 0.22s ease both; }
.faq-chip {
    min-height: 40px;
    padding: 8px 14px;
    border: 1.5px solid #0a52d9;
    border-radius: 999px;
    background: #fff;
    color: #0a52d9;
    font: 500 0.84rem/1.3 var(--font-1, "Poppins"), sans-serif;
    text-align: left;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}
.faq-chip:hover { background: #0a52d9; color: #fff; }
.faq-chip.soft { border-color: var(--faq-line); color: #3d4a66; }
.faq-chip.soft:hover { background: var(--faq-bot); color: var(--faq-ink); }
.faq-chip[disabled] { opacity: 0.45; pointer-events: none; }

.faq-group-title {
    align-self: flex-start;
    margin: 8px 2px 0;
    font: 700 0.7rem/1 var(--font-1, "Poppins"), sans-serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #51607f;
}

.faq-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #1a6bff, #0a52d9);
    color: #fff;
    font: 700 0.88rem/1 var(--font-2, "Schibsted Grotesk"), sans-serif;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(26, 107, 255, 0.3);
}

/* ── mini-form nel thread ── */
.faq-form-msg { width: 100%; max-width: 100%; }
.faq-form { display: grid; gap: 10px; margin-top: 10px; }
.faq-form label { display: block; font-size: 0.78rem; font-weight: 600; letter-spacing: 0; text-transform: none; margin-bottom: 4px; color: #2a3550; }
.faq-form input[type="text"],
.faq-form input[type="email"],
.faq-form textarea {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid var(--field-border, #8a94a6);
    border-radius: 8px;
    background: #fff;
    font: 400 16px/1.4 var(--font-1, "Poppins"), sans-serif;
    color: var(--faq-ink);
}
.faq-form textarea { min-height: 96px; resize: vertical; }
.faq-form input:focus, .faq-form textarea:focus { outline: 3px solid rgba(26, 107, 255, 0.35); border-color: #1a6bff; }
.faq-consent { display: flex; gap: 10px; align-items: flex-start; font-size: 0.76rem; line-height: 1.45; color: #3d4a66; }
.faq-consent input { width: 20px; height: 20px; margin-top: 1px; flex-shrink: 0; accent-color: #0a52d9; }
.faq-consent label { margin: 0; font-size: inherit; font-weight: 400; color: inherit; }
.faq-consent a { color: #0a52d9; }
.faq-form-error { display: none; padding: 9px 12px; border-radius: 8px; background: #fdecec; color: #8a1c1c; font-size: 0.8rem; }
.faq-form-error.is-shown { display: block; }
.faq-form-submit {
    min-height: 48px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #1a6bff, #0a52d9);
    color: #fff;
    font: 700 0.95rem/1 var(--font-2, "Schibsted Grotesk"), sans-serif;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(26, 107, 255, 0.3);
}
.faq-form-submit:disabled { opacity: 0.7; cursor: progress; }
.faq-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ── footer del pannello ── */
.faq-foot { flex-shrink: 0; padding: 10px 14px 12px; border-top: 1px solid var(--faq-line); background: #fff; display: grid; gap: 6px; }
.faq-search { display: flex; gap: 8px; }
.faq-search input {
    flex: 1; min-width: 0;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--field-border, #8a94a6);
    border-radius: 999px;
    background: #fff;
    font: 400 16px var(--font-1, "Poppins"), sans-serif;
    color: var(--faq-ink);
}
.faq-search input:focus { outline: 3px solid rgba(26, 107, 255, 0.35); border-color: #1a6bff; }
.faq-search-btn { width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: #0a52d9; color: #fff; cursor: pointer; }
.faq-search-btn:hover { background: #083a9a; }
.faq-contact-link { min-height: 40px; border: 0; background: none; font: 400 0.8rem/1.3 var(--font-1, "Poppins"), sans-serif; color: #3d4a66; cursor: pointer; text-align: center; }
.faq-contact-link strong { color: #0a52d9; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ── tablet e mobile ──
   la barra CTA fissa (landing.css, max-width 1024px) occupa ~76px in basso quando visibile */
@media (max-width: 1024px) {
    .faq-chat.has-sticky { --faq-bottom: calc(88px + env(safe-area-inset-bottom)); }
}

@media (max-width: 768px) {
    .faq-chat { --faq-bottom: 16px; --faq-right: 16px; }
    .faq-chat.has-sticky { --faq-bottom: calc(88px + env(safe-area-inset-bottom)); }
    .faq-launcher { min-height: 48px; padding: 0 16px 0 14px; }
    .faq-panel {
        position: fixed;
        inset: 0;
        width: auto;
        height: auto;
        border-radius: 0;
        box-shadow: none;
    }
    .faq-head { padding-top: calc(16px + env(safe-area-inset-top)); }
    .faq-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    .faq-msg { max-width: 92%; }
}
html.faq-lock { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .faq-chat * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
