/* AlBas "vivo" (js/albas-vivo.js): intestazione con avatar che reagisce, fumetto proattivo,
   schede del 112 e dell'errore, suggerimenti che compaiono. Solo transform/opacity; tutto
   spento con "riduci animazioni" del sistema. */

/* ---- intestazione della chat ---- */
.albas-testata { display: flex; align-items: center; gap: 10px; min-width: 0; }
.albas-testata-avatar { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%; background: #fff; padding: 3px; object-fit: contain; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); animation: albasRespira 4.5s ease-in-out infinite; }
.albas-nome { font-weight: 800; line-height: 1.15; }
.albas-stato { font-size: .72rem; font-weight: 500; opacity: .85; line-height: 1.2; }
#chatbot-panel.albas-pensa .albas-testata-avatar { animation: albasPensa 1.1s ease-in-out infinite; }
#chatbot-panel.albas-scrive .albas-testata-avatar { animation: albasParla .45s ease-in-out infinite alternate; }

/* ---- pulsante flottante ---- */
.chatbot-image-icon { animation: albasSaluta 9s ease-in-out infinite; transform-origin: 50% 90%; }
#chatbot-button.albas-attenzione::after { content: ''; position: absolute; top: 1px; right: 1px; width: 15px; height: 15px; border-radius: 50%; background: #e74c3c; border: 2px solid #fff; animation: albasBadge 1.6s ease-out infinite; }

/* ---- fumetto proattivo ---- */
.albas-bolla {
    position: fixed; left: 20px; bottom: 155px; z-index: 9990; display: flex; align-items: flex-start;
    max-width: min(280px, calc(100vw - 40px)); background: #fff; border: 1px solid #cfe0f1;
    border-radius: 16px 16px 16px 4px; box-shadow: 0 8px 24px rgba(0, 30, 70, .28);
    animation: albasBolla .4s cubic-bezier(.3, 1.4, .5, 1);
}
.albas-bolla::after { content: ''; position: absolute; left: 22px; bottom: -8px; width: 14px; height: 14px; background: inherit; border-right: 1px solid #cfe0f1; border-bottom: 1px solid #cfe0f1; transform: rotate(45deg); }
.albas-bolla-alta { background: #fff7ee; border-color: #e67e22; }
.albas-bolla-alta::after { border-color: #e67e22; }
.albas-bolla-testo { flex: 1; background: none; border: 0; padding: 11px 2px 11px 14px; text-align: left; font: inherit; font-size: .9rem; line-height: 1.35; color: #12324f; cursor: pointer; }
.albas-bolla-chiudi { flex: 0 0 auto; background: none; border: 0; padding: 6px 11px; font-size: 1.3rem; line-height: 1; color: #7d8d9c; cursor: pointer; }
@media (max-width: 768px) { .albas-bolla { left: 15px; bottom: 142px; } }

/* ---- schede dentro la chat ---- */
.albas-card { align-self: stretch; display: flex; flex-direction: column; gap: 7px; background: #fff; border: 1px solid #dbe6f1; border-radius: 12px; padding: 10px 12px; font-size: .85rem; line-height: 1.4; color: #24384d; animation: popIn .25s ease-out; }
.albas-card-emergenza { border: 2px solid #e74c3c; background: #fff5f4; }
.albas-card-errore { border-color: #efc46d; background: #fffaf0; }
.albas-tel { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; background: #c0392b; color: #fff; text-decoration: none; font-weight: 800; padding: 9px 16px; border-radius: 22px; }
.albas-riprova { align-self: flex-start; background: #003366; color: #fff; border: 0; border-radius: 16px; padding: 7px 14px; font: inherit; font-weight: 700; cursor: pointer; }

.albas-attesa { margin-left: 8px; font-size: .75rem; color: #6b7c8d; white-space: nowrap; }
.typing-indicator { align-items: center; }

/* ---- suggerimenti che compaiono uno dopo l'altro ---- */
.albas-chips-in button { animation: albasChip .3s ease-out both; }
.albas-chips-in button:nth-child(2) { animation-delay: .05s; }
.albas-chips-in button:nth-child(3) { animation-delay: .1s; }
.albas-chips-in button:nth-child(4) { animation-delay: .15s; }
.albas-chips-in button:nth-child(n+5) { animation-delay: .2s; }

@keyframes albasRespira { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes albasPensa { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes albasParla { from { transform: scale(1) translateY(0); } to { transform: scale(1.09) translateY(-1px); } }
@keyframes albasSaluta { 0%, 88%, 100% { transform: rotate(0); } 91% { transform: rotate(-11deg); } 94% { transform: rotate(9deg); } 97% { transform: rotate(-6deg); } }
@keyframes albasBadge { 0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, .7); } 70%, 100% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); } }
@keyframes albasBolla { from { transform: translateY(10px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes albasChip { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .albas-testata-avatar, .chatbot-image-icon, .albas-bolla, .albas-card, .albas-chips-in button,
    #chatbot-button.albas-attenzione::after { animation: none !important; }
}

/* Il pulsante di AlBas non deve coprire il testo dei pannelli a tutto schermo (Cosa fare se..., SOS,
   impostazioni...): si nasconde finche' uno e' aperto. Dove :has non c'e' la regola e' ignorata. */
body:has(.sos-overlay[style*="display: flex"]) #chatbot-button,
body:has(.sos-overlay[style*="display: flex"]) .albas-bolla { display: none; }
