/* Adierre Cameco – Bot Assistente Mediazione
   Colori istituzionali: rosso #A71930 | grigio #616365
   Versione 2.0.0 – corretto troncamento file (media query mobile incompleta),
   aggiunti stili per badge di notifica, teaser proattivo e animazione pulse. */

:root {
    --ac-red:    #A71930;
    --ac-grey:   #616365;
    --ac-light:  #f5f5f5;
    --ac-white:  #ffffff;
    --ac-shadow: 0 4px 24px rgba(0,0,0,0.15);
    --ac-radius: 12px;
}

/* ── LAUNCHER (bottone flottante) ── */
#adierre-chat-launcher {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 58px;
    height: 58px;
    background: var(--ac-red);
    color: var(--ac-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--ac-shadow);
    z-index: 99999;
    transition: transform 0.2s ease, background 0.2s ease;
    user-select: none;
}
#adierre-chat-launcher:hover {
    background: #8a1426;
    transform: scale(1.08);
}
#adierre-chat-launcher.is-open {
    background: var(--ac-grey);
}
#adierre-chat-launcher svg,
#adierre-chat-launcher * {
    pointer-events: none;
}

/* ── RICHIAMO PROATTIVO: badge di notifica ── */
#adierre-chat-badge {
    position: fixed;
    bottom: 76px;
    right: 24px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--ac-grey);
    color: var(--ac-white);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    z-index: 100000;
    opacity: 0;
    transform: scale(0.6);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
#adierre-chat-badge.is-visible {
    opacity: 1;
    transform: scale(1);
}

/* ── RICHIAMO PROATTIVO: pulse sul launcher ── */
#adierre-chat-launcher.ac-pulse::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(167, 25, 48, 0.55);
    animation: ac-launcher-pulse 2.2s ease-out infinite;
    pointer-events: none;
}
@keyframes ac-launcher-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(167, 25, 48, 0.55); }
    70%  { box-shadow: 0 0 0 16px rgba(167, 25, 48, 0); }
    100% { box-shadow: 0 0 0 0 rgba(167, 25, 48, 0); }
}

/* ── RICHIAMO PROATTIVO: fumetto teaser ── */
#adierre-chat-teaser {
    position: fixed;
    bottom: 34px;
    right: 96px;
    max-width: 240px;
    background: var(--ac-white);
    color: #222;
    border-radius: 14px;
    border-bottom-right-radius: 4px;
    box-shadow: var(--ac-shadow);
    padding: 12px 32px 12px 14px;
    font-size: 13px;
    line-height: 1.4;
    z-index: 99998;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
#adierre-chat-teaser.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
#adierre-chat-teaser-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: #999;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}
#adierre-chat-teaser-close:hover { color: var(--ac-red); }
@media (max-width: 480px) {
    #adierre-chat-teaser { right: 16px; bottom: 96px; max-width: calc(100vw - 90px); }
}

/* ── FINESTRA CHAT ── */
#adierre-chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--ac-white);
    border-radius: var(--ac-radius);
    box-shadow: var(--ac-shadow);
    display: none !important;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
}
#adierre-chat-window.is-open {
    display: flex !important;
    flex-direction: column;
}

/* ── HEADER ── */
#adierre-chat-header {
    background: var(--ac-red);
    color: var(--ac-white);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#adierre-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
#adierre-chat-logo {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
#adierre-chat-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}
#adierre-chat-subtitle {
    font-size: 11px;
    opacity: 0.85;
    line-height: 1.2;
}
#adierre-chat-close {
    background: none;
    border: none;
    color: var(--ac-white);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}
#adierre-chat-close:hover { opacity: 1; }

/* ── AREA MESSAGGI ── */
#adierre-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#adierre-chat-body::-webkit-scrollbar { width: 4px; }
#adierre-chat-body::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* ── MESSAGGI ── */
.ac-msg {
    max-width: 88%;
    padding: 10px 13px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
    animation: ac-fade-in 0.18s ease;
}
@keyframes ac-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ac-msg-bot {
    background: var(--ac-light);
    color: #222;
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}
.ac-msg-user {
    background: var(--ac-red);
    color: var(--ac-white);
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}
.ac-msg-source {
    font-size: 11px;
    color: var(--ac-grey);
    margin-top: 5px;
    font-style: italic;
}

/* ── TYPING INDICATOR ── */
.ac-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 14px;
    background: var(--ac-light);
    border-radius: 10px;
    border-bottom-left-radius: 3px;
    align-self: flex-start;
    width: 52px;
}
.ac-typing span {
    width: 7px;
    height: 7px;
    background: var(--ac-grey);
    border-radius: 50%;
    animation: ac-bounce 1.2s infinite;
}
.ac-typing span:nth-child(2) { animation-delay: 0.2s; }
.ac-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ac-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* ── SUGGERIMENTI RAPIDI ── */
.ac-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 2px;
    align-self: flex-start;
    max-width: 100%;
}
.ac-suggestion-btn {
    background: var(--ac-white);
    border: 1.5px solid var(--ac-red);
    color: var(--ac-red);
    border-radius: 20px;
    padding: 5px 11px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.ac-suggestion-btn:hover {
    background: var(--ac-red);
    color: var(--ac-white);
}

/* ── INPUT AREA ── */
#adierre-chat-footer {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: var(--ac-white);
    flex-shrink: 0;
}
#adierre-chat-input {
    flex: 1;
    border: 1.5px solid #ddd;
    border-radius: 22px;
    padding: 9px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
#adierre-chat-input:focus {
    border-color: var(--ac-red);
}
#adierre-chat-send {
    width: 40px;
    height: 40px;
    background: var(--ac-red);
    color: var(--ac-white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
#adierre-chat-send:hover { background: #8a1426; }
#adierre-chat-send svg,
#adierre-chat-send * {
    pointer-events: none;
}

/* ── DISCLAIMER ── */
#adierre-chat-disclaimer {
    text-align: center;
    font-size: 10.5px;
    color: #999;
    padding: 6px 12px 8px;
    line-height: 1.4;
    background: var(--ac-white);
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

/* ── MOBILE ── */
@media (max-width: 480px) {
    #adierre-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 80vh;
        max-height: 80vh;
        border-radius: 12px 12px 0 0;
    }
    #adierre-chat-launcher {
        bottom: 18px;
        right: 18px;
    }
    #adierre-chat-badge {
        bottom: 66px;
        right: 14px;
    }
}
