/*
 * Assistente virtuale Formacenter: stili del widget.
 * Tutto sotto .fca / prefisso fca-: non tocca header, footer né CSS condivisi.
 * File servito così com'è (niente build).
 */
.fca, .fca * { box-sizing: border-box; }
.fca {
    --fca-blu: #1a3a52;
    --fca-blu-scuro: #173b5b;
    --fca-testo: #173b5b;
    --fca-tenue: #526b7e;
    --fca-bordo: #d7e5ee;
    --fca-sfondo: #f5f8fa;
    --fca-bot: #ffffff;
    --fca-utente: #1a3a52;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.45;
    color: var(--fca-testo);
}
.fca-sr {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.fca [hidden] { display: none !important; }

/* Pulsante di apertura: stessa posizione del widget precedente */
.fca-lancio {
    position: fixed; right: 20px; bottom: 20px; z-index: 9999;
    width: 60px; height: 60px; padding: 0; border: 2px solid rgba(214, 239, 250, .9); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; background: var(--fca-blu);
    box-shadow: none; cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}
.fca-lancio:hover { transform: scale(1.06); box-shadow: none; }
.fca-lancio:focus-visible { outline: 3px solid #0b3d63; outline-offset: 3px; }
.fca-icona { width: 30px; height: 30px; }
.fca-aperto .fca-lancio { display: none; }

/* Pannello */
.fca-pannello {
    position: fixed; right: 20px; bottom: 20px; z-index: 100001;
    width: 390px; height: min(640px, calc(100vh - 40px));
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--fca-sfondo); border-radius: 14px;
    box-shadow: 0 12px 40px rgba(16, 42, 67, .28);
}
.fca-testata {
    display: flex; align-items: center; gap: 6px; padding: 12px 10px 12px 16px;
    color: #fff; background: var(--fca-blu);
}
.fca-testata-testi { flex: 1; min-width: 0; }
.fca .fca-titolo { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.25; color: #fff; }
.fca .fca-sottotitolo { margin: 2px 0 0; font-size: 12.5px; color: #eef8fd; }
.fca-icon-btn {
    width: 38px; height: 38px; padding: 8px; border: 0; border-radius: 8px;
    color: #fff; background: transparent; cursor: pointer;
}
.fca-icon-btn svg { width: 22px; height: 22px; display: block; }
.fca-icon-btn:hover { background: rgba(255, 255, 255, .16); }
.fca-icon-btn:focus-visible, .fca-btn:focus-visible, .fca-azione:focus-visible, .fca-invia:focus-visible,
.fca-link:focus-visible, .fca-log:focus-visible { outline: 3px solid #0b3d63; outline-offset: 2px; }

.fca-avviso-ticket {
    padding: 8px 14px; font-size: 13.5px; background: #fff8e1; border-bottom: 1px solid #f0e0a8;
}
.fca-avviso-ticket a { color: #7a4f00; font-weight: 600; text-decoration: underline; }

/* Messaggi */
.fca-log { flex: 1; overflow-y: auto; padding: 14px 12px 6px; overscroll-behavior: contain; }
.fca-msg { display: flex; flex-direction: column; margin: 0 0 10px; max-width: 88%; }
.fca-msg-bot { align-items: flex-start; }
.fca-msg-utente { align-items: flex-end; margin-left: auto; }
.fca-bolla {
    padding: 9px 12px; border-radius: 12px; white-space: pre-line; overflow-wrap: anywhere;
}
.fca-msg-bot .fca-bolla { background: var(--fca-bot); border: 1px solid var(--fca-bordo); border-top-left-radius: 4px; }
.fca-msg-utente .fca-bolla { color: #fff; background: var(--fca-utente); border-top-right-radius: 4px; }
.fca-msg-errore .fca-bolla { background: #fdecea; border-color: #f5c2bd; }
.fca-links, .fca-azioni { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.fca .fca-link {
    display: inline-block; padding: 5px 10px; font-size: 13.5px; font-weight: 600;
    color: var(--fca-blu-scuro); background: #eef8fd; border-radius: 6px; text-decoration: underline;
}
.fca-azione {
    min-height: 36px; padding: 6px 12px; font: inherit; font-size: 14px; text-align: left;
    color: var(--fca-blu-scuro); background: #fff; border: 1.5px solid var(--fca-blu); border-radius: 18px; cursor: pointer;
}
.fca-azione:hover { background: #eef8fd; }
.fca-azione small { display: block; font-size: 12px; color: var(--fca-tenue); }
.fca-azione[disabled] { opacity: .55; cursor: default; }

.fca-scrive { display: flex; gap: 4px; padding: 0 22px 8px; }
.fca-scrive span {
    width: 7px; height: 7px; border-radius: 50%; background: #9aa5b1; animation: fca-punto 1.2s infinite ease-in-out;
}
.fca-scrive span:nth-child(2) { animation-delay: .15s; }
.fca-scrive span:nth-child(3) { animation-delay: .3s; }
@keyframes fca-punto { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* Composer */
.fca-composer {
    display: flex; align-items: flex-end; gap: 8px; padding: 10px; background: #fff; border-top: 1px solid var(--fca-bordo);
}
.fca-composer textarea {
    flex: 1; min-height: 42px; max-height: 120px; padding: 10px 12px; resize: none;
    font: inherit; color: var(--fca-testo); background: #fff; border: 1.5px solid #9aa5b1; border-radius: 10px;
}
.fca-composer textarea:focus { outline: none; border-color: var(--fca-blu); box-shadow: 0 0 0 3px rgba(26, 58, 82, .25); }
.fca-invia {
    width: 44px; height: 42px; padding: 10px; border: 0; border-radius: 10px;
    color: #fff; background: var(--fca-blu); cursor: pointer;
}
.fca-invia svg { width: 22px; height: 22px; display: block; }
.fca-invia[disabled] { opacity: .5; cursor: default; }

/* Saluto che si compone alla prima apertura */
.fca-componendo .fca-bolla::after {
    content: ''; display: inline-block; width: 2px; height: 1em; margin-left: 2px;
    vertical-align: text-bottom; background: var(--fca-tenue); animation: fca-punto 1s infinite;
}

/* Modulo ticket */
.fca-ticket { flex: 1; overflow-y: auto; padding: 14px 16px; background: #fff; }
.fca .fca-ticket-titolo { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.fca-ticket-intro { margin: 0 0 10px; font-size: 13.5px; color: var(--fca-tenue); }
.fca-ticket label { display: block; margin: 8px 0 3px; font-size: 13.5px; font-weight: 600; }
.fca-ticket input[type="text"], .fca-ticket input[type="email"], .fca-ticket input[type="tel"], .fca-ticket textarea {
    width: 100%; padding: 9px 10px; font: inherit; color: var(--fca-testo); border: 1.5px solid #9aa5b1; border-radius: 8px; background: #fff;
}
.fca-ticket input:focus, .fca-ticket textarea:focus { outline: none; border-color: var(--fca-blu); box-shadow: 0 0 0 3px rgba(26, 58, 82, .25); }
.fca-ticket .fca-check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.fca-ticket .fca-check input { margin-top: 3px; width: 18px; height: 18px; }
.fca-ticket a { color: var(--fca-blu-scuro); text-decoration: underline; }
.fca-errore { margin: 8px 0 0; padding: 8px 10px; font-size: 13.5px; color: #8a1c12; background: #fdecea; border-radius: 6px; }
.fca-ticket-azioni { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.fca-btn {
    min-height: 40px; padding: 8px 16px; font: inherit; font-weight: 600;
    color: #fff; background: var(--fca-blu); border: 1.5px solid var(--fca-blu); border-radius: 8px; cursor: pointer;
}
.fca-btn-secondario { color: var(--fca-blu-scuro); background: #fff; }
.fca-btn[disabled] { opacity: .6; cursor: default; }

/* Telefono: pannello a tutto schermo, sul viewport visibile (tastiera aperta) */
@media (max-width: 600px) {
    .fca-pannello {
        top: var(--fc-visual-viewport-offset-top, 0); left: var(--fc-visual-viewport-offset-left, 0); right: auto; bottom: auto;
        width: var(--fc-visual-viewport-width, 100vw);
        height: 100vh; height: 100dvh; height: var(--fc-visual-viewport-height, 100dvh);
        border-radius: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .fca-lancio { right: 16px; bottom: 16px; }
    .fca-msg { max-width: 92%; }
    /* 16px evita lo zoom automatico di iOS sui campi */
    .fca-composer textarea, .fca-ticket input, .fca-ticket textarea { font-size: 16px; }
    body.fca-blocca { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .fca-lancio { transition: none; }
    .fca-scrive span { animation: none; opacity: .7; }
}
