/*
 * =============================================================================
 * css/AI_chat.css - ASSISTENTE VIRTUALE del sito pubblico (prefisso AI_)
 * -----------------------------------------------------------------------------
 * Pulsante tondo in basso a destra + pannello di chat (js/AI_chat.js).
 * Misure in px: il body del sito pubblico ha font-size 10px storico.
 * Colori del sito: blu #15476c, blu notte #0f2f45, primario #007bff,
 * arancio #ff9900, fondo #f4f7fb. Su telefono il pannello occupa lo schermo.
 * Il pulsante "torna su" del template (.back-to-top) sale sopra il pulsante
 * della chat quando l'assistente c'e' (body.AI_con).
 * =============================================================================
 */
.AI_widget { position: fixed; right: 16px; bottom: 16px; z-index: 1040; font-family: Montserrat, system-ui, sans-serif; font-size: 15px; line-height: 1.5; text-align: left; color: #1d2b36; }
.AI_widget *, .AI_widget *::before, .AI_widget *::after { box-sizing: border-box; }
body.AI_con .back-to-top { bottom: 84px; }
/* assets/css/Features-Boxed.css da' a TUTTI gli svg font 60px, colore blu e margine: qui si annulla */
.AI_widget svg { font-size: inherit; color: inherit; margin: 0; flex: none; }

/* pulsante */
.AI_lancia { display: flex; align-items: center; gap: 8px; height: 54px; padding: 0 20px 0 16px; border: 0; border-radius: 27px;
    background: #15476c; color: #fff; font: 600 15px Montserrat, system-ui, sans-serif; cursor: pointer;
    box-shadow: 0 6px 20px rgba(15, 47, 69, .35); transition: transform .15s, background .15s; }
.AI_lancia:hover { background: #0f2f45; transform: translateY(-2px); }
.AI_lancia:focus-visible, .AI_widget button:focus-visible, .AI_widget a:focus-visible, .AI_tk input:focus-visible {
    outline: 3px solid #ff9900; outline-offset: 2px; }
.AI_widget textarea:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 3px rgba(0, 123, 255, .2); }
.AI_aperto .AI_lancia_t { display: none; }
.AI_aperto .AI_lancia { padding: 0 16px; }

/* pannello */
.AI_pannello { position: absolute; right: 0; bottom: 66px; width: 380px; max-width: calc(100vw - 32px);
    height: 600px; max-height: calc(100vh - 100px); display: flex; flex-direction: column;
    background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 12px 40px rgba(15, 47, 69, .3); }
.AI_pannello[hidden] { display: none; }
.AI_testa { display: flex; align-items: flex-start; gap: 6px; padding: 14px 12px 12px 18px; background: #15476c; color: #fff; }
.AI_testa_t { flex: 1; min-width: 0; }
.AI_tit { margin: 0; font-size: 17px; font-weight: 700; color: #fff; line-height: 1.3; }
.AI_sotto { margin: 2px 0 0; font-size: 12.5px; opacity: .85; color: #fff; }
.AI_icona { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%;
    background: transparent; color: #fff; cursor: pointer; }
.AI_icona:hover { background: rgba(255, 255, 255, .15); }

.AI_lista { flex: 1; overflow-y: auto; padding: 16px 14px 8px; background: #f4f7fb; scroll-behavior: smooth; }
.AI_msg { max-width: 88%; margin: 0 0 12px; }
.AI_msg_u { margin-left: auto; }
.AI_chi { display: block; font-size: 11.5px; font-weight: 600; color: #5b6b78; margin: 0 4px 3px; }
.AI_msg_u .AI_chi { text-align: right; }
.AI_corpo { padding: 10px 14px; border-radius: 14px; background: #fff; border: 1px solid #dfe7ef; word-wrap: break-word; overflow-wrap: anywhere; }
.AI_msg_u .AI_corpo { background: #007bff; border-color: #007bff; color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.AI_msg_a .AI_corpo { border-bottom-left-radius: 4px; }
.AI_corpo p { margin: 0 0 8px; font-size: 15px; }
.AI_corpo p:last-child { margin-bottom: 0; }
.AI_corpo ul { margin: 0 0 8px; padding-left: 20px; list-style: disc; }
.AI_corpo li { margin: 0 0 4px; list-style: disc; font-size: 15px; }
.AI_link { color: #0056b3; text-decoration: underline; font-weight: 600; }
.AI_msg_err .AI_corpo { background: #fff6e5; border-color: #ffd28a; }
.AI_msg_ok .AI_corpo { background: #eaf7ee; border-color: #9fd8ae; }

.AI_esempi { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.AI_esempio { border: 1px solid #b7cde0; background: #fff; color: #15476c; border-radius: 18px; padding: 7px 13px;
    font: 500 13.5px Montserrat, system-ui, sans-serif; cursor: pointer; text-align: left; }
.AI_esempio:hover { background: #e8f1fa; }

.AI_scrive .AI_corpo { display: none; }
.AI_punti { display: inline-flex; gap: 5px; padding: 12px 16px; background: #fff; border: 1px solid #dfe7ef; border-radius: 14px; }
.AI_punti i { width: 8px; height: 8px; border-radius: 50%; background: #8aa3b8; animation: AI_punto 1.2s infinite ease-in-out; }
.AI_punti i:nth-child(2) { animation-delay: .15s; }
.AI_punti i:nth-child(3) { animation-delay: .3s; }
@keyframes AI_punto { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.AI_sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* piede */
.AI_piede { padding: 10px 12px 10px; border-top: 1px solid #e3eaf1; background: #fff; }
.AI_form { display: flex; gap: 8px; align-items: flex-end; }
.AI_campo { flex: 1; resize: none; min-height: 44px; max-height: 120px; padding: 10px 12px; border: 1px solid #c4d3e0; border-radius: 12px;
    font: 15px Montserrat, system-ui, sans-serif; color: #1d2b36; background: #fff; }
.AI_invia { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: #007bff; color: #fff; cursor: pointer; }
.AI_invia:hover { background: #0062cc; }
.AI_invia:disabled { background: #9bb8d6; cursor: wait; }
.AI_riga { display: flex; justify-content: space-between; align-items: center; margin: 6px 2px 0; }
.AI_conta { font-size: 11.5px; color: #7a8a97; }
.AI_umano { border: 0; background: none; padding: 2px 0; color: #15476c; font: 600 13px Montserrat, system-ui, sans-serif; text-decoration: underline; cursor: pointer; }
.AI_umano_forte { display: inline-block; margin: 6px 4px 0; padding: 7px 14px; border-radius: 18px; background: #ff9900; color: #1d2b36; text-decoration: none; }
.AI_umano_forte:hover { background: #ffad33; }
.AI_avviso { margin: 6px 2px 0; font-size: 11.5px; line-height: 1.4; color: #6a7a87; }
.AI_priv { border: 0; background: none; padding: 0; color: #0056b3; font-size: 11.5px; text-decoration: underline; cursor: pointer; }

/* modulo "Scrivi all'assistenza" */
.AI_tk { flex: none; padding: 14px 16px; border-top: 3px solid #ff9900; background: #fffaf0; max-height: 80%; overflow-y: auto; }
.AI_con_tk .AI_piede { display: none; }          /* mentre il modulo e' aperto la casella della domanda sparisce */
.AI_tk_t { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: #15476c; }
.AI_tk_x { margin: 0 0 10px; font-size: 13px; color: #4a5a67; }
.AI_tk_l { display: block; margin: 0 0 8px; font-size: 13px; font-weight: 600; color: #33424e; }
.AI_tk_l span { display: block; margin-bottom: 3px; }
.AI_tk_l input, .AI_tk_l textarea { width: 100%; padding: 8px 10px; border: 1px solid #c4d3e0; border-radius: 8px; font: 14px Montserrat, system-ui, sans-serif; background: #fff; }
.AI_tk_l textarea { min-height: 60px; resize: vertical; }
.AI_tk_c { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: #33424e; margin: 4px 0 8px; font-weight: 400; }
.AI_tk_c input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.AI_tk_err { margin: 0 0 6px; color: #b42318; font-size: 13px; min-height: 0; }
.AI_tk_err:empty { display: none; }
.AI_tk_az { display: flex; justify-content: flex-end; gap: 8px; }
.AI_btn { border: 0; border-radius: 8px; padding: 9px 16px; background: #15476c; color: #fff; font: 600 14px Montserrat, system-ui, sans-serif; cursor: pointer; }
.AI_btn:disabled { opacity: .6; cursor: wait; }
.AI_btn_chiaro { background: #e3eaf1; color: #15476c; }

@media (max-width: 560px) {
    .AI_widget { right: 12px; bottom: 12px; }
    .AI_lancia_t { display: none; }
    .AI_lancia { width: 54px; padding: 0; justify-content: center; }
    .AI_widget.AI_aperto { left: 0; right: 0; top: 0; bottom: 0; }
    .AI_widget.AI_aperto .AI_lancia { display: none; }
    .AI_pannello { position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; }
    body.AI_con .back-to-top { bottom: 76px; }
}
@media (prefers-reduced-motion: reduce) {
    .AI_punti i { animation: none; opacity: .7; }
    .AI_lancia, .AI_lista { transition: none; scroll-behavior: auto; }
}
@media print { .AI_widget { display: none !important; } }
