/* Chat cliente <-> Distilleria (chat.js) */
/* icona a sinistra della barra di ricerca */
.cg-bottone {
    position: relative; flex: 0 0 auto; margin-right: 10px;
    width: 40px; height: 34px; border-radius: 10px; border: 0;
    background: #d5001f; color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.cg-tip {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 99992;
    padding: 6px 10px; border-radius: 8px; background: #222; color: #fff;
    font: 13px/1.2 sans-serif; white-space: nowrap; pointer-events: none;
    opacity: 0; visibility: hidden; transition: opacity .15s ease;
}
.cg-bottone:hover .cg-tip, .cg-bottone:focus-visible .cg-tip, .cg-bottone.cg-tip-visibile .cg-tip { opacity: 1; visibility: visible; }
.cg-fisso .cg-tip { top: auto; bottom: calc(100% + 8px); left: auto; right: 0; }
/* senza barra di ricerca: fissa in basso a destra */
.cg-bottone.cg-fisso { position: fixed; right: 18px; bottom: 72px; z-index: 99990; width: 54px; height: 54px; border-radius: 50%; margin: 0; }
.cg-badge {
    position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 4px;
    border-radius: 10px; background: #fff; color: #d5001f; border: 2px solid #d5001f;
    font: bold 12px/1 sans-serif; display: none; align-items: center; justify-content: center;
}
/* lampeggia finché il cliente non apre la chat */
.cg-lampeggia { animation: cg-lampeggia 1s ease-in-out infinite; }
@keyframes cg-lampeggia {
    0%, 100% { background: #d5001f; box-shadow: 0 0 0 0 rgba(255,210,80,.9); transform: scale(1); }
    50% { background: #ffb400; box-shadow: 0 0 0 8px rgba(255,210,80,0); transform: scale(1.12); }
}
/* barra più stretta sui telefoni piccoli, per far stare l'icona */
@media (max-width: 420px) {
    .cg-con-chat #inputRicerca { width: calc(100vw - 150px); }
}

/* link alla chat: menu Contattaci, popup orari, bacheca */
.cg-voce-icona {
    display: inline-flex; align-items: center; justify-content: center; vertical-align: bottom;
    width: 25px; height: 25px; margin: 8px 8px 0 0; border-radius: 6px; background: #d5001f; color: #fff;
}
.cg-voce-icona svg { width: 16px; height: 16px; }
.cg-chiedi-riga { margin-top: 14px; }
.cg-chiedi {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
    border: 0; border-radius: 10px; background: #d5001f; color: #fff;
    font: bold 15px sans-serif; cursor: pointer;
}
.cg-vibra {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 34px; margin-top: 6px; border: 0; border-radius: 10px;
    background: #d5001f; color: #fff; cursor: pointer;
    animation: cg-vibra 2.5s linear infinite;
}
/* una breve vibrazione ogni 2,5 secondi */
@keyframes cg-vibra {
    0%, 24%, 100% { transform: translateX(0) rotate(0); }
    3%, 9%, 15%, 21% { transform: translateX(-2px) rotate(-5deg); }
    6%, 12%, 18% { transform: translateX(2px) rotate(5deg); }
}

.cg-toast {
    position: fixed; right: 18px; bottom: 72px; z-index: 99990; max-width: calc(100vw - 36px);
    padding: 12px 16px; border: 0; border-radius: 12px; background: #222; color: #fff;
    font: 15px/1.3 sans-serif; text-align: left; cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,.3); display: none;
}
.cg-toast.cg-visibile { display: block; animation: cg-entra .3s ease; }
@keyframes cg-entra { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.cg-pannello {
    position: fixed; right: 18px; bottom: 72px; z-index: 99991;
    width: 340px; height: 460px; max-height: calc(100vh - 90px);
    background: #fff; color: #222; border-radius: 14px; overflow: hidden;
    box-shadow: 0 8px 28px rgba(0,0,0,.35);
    display: none; flex-direction: column; font: 15px/1.35 sans-serif;
}
.cg-pannello.cg-visibile { display: flex; animation: cg-entra .2s ease; }
.cg-testa {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 12px 10px 16px; background: #d5001f; color: #fff;
}
.cg-testa strong { display: block; font-size: 16px; }
.cg-testa small { display: block; opacity: .85; font-size: 12px; }
.cg-chiudi { background: none; border: 0; color: #fff; font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px; }

.cg-lista { flex: 1; overflow-y: auto; padding: 12px; background: #f3efe9; }
.cg-msg { display: flex; flex-direction: column; margin-bottom: 8px; }
.cg-fumetto {
    max-width: 82%; padding: 8px 11px; border-radius: 12px;
    white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.cg-ora { font-size: 11px; color: #888; margin-top: 2px; }
.cg-cliente { align-items: flex-end; }
.cg-cliente .cg-fumetto { background: #ffe1e5; border-bottom-right-radius: 4px; }
.cg-distilleria { align-items: flex-start; }
.cg-distilleria .cg-fumetto { background: #fff; border-bottom-left-radius: 4px; }
.cg-sistema { align-items: center; }
.cg-sistema .cg-fumetto { background: none; box-shadow: none; color: #777; font-size: 13px; font-style: italic; text-align: center; max-width: 95%; }

.cg-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e5e0d8; background: #fff; }
.cg-form textarea {
    flex: 1; resize: none; border: 1px solid #ccc; border-radius: 18px; padding: 8px 12px;
    font: 15px/1.3 sans-serif; max-height: 90px;
}
.cg-form button {
    border: 0; border-radius: 18px; padding: 0 16px; background: #d5001f; color: #fff;
    font: bold 14px sans-serif; cursor: pointer;
}
.cg-form button:disabled { opacity: .5; }

@media (max-width: 480px) {
    .cg-pannello { left: 10px; right: 10px; width: auto; }
    .cg-toast { right: 10px; left: 10px; }
}
