/**
 * CSS Base per il Chatbot
 */

#chatbot-widget {
    border: 1px solid #ccc;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    font-family: Arial, sans-serif;
    background: #fff;
}

#chatbot-messages {
    flex-direction: column;
    display: flex;
    flex: 1;
    padding: 10px;
    overflow-y: auto;
	box-sizing: border-box;
	scrollbar-gutter: stable;
	scroll-snap-type: y proximity;
	scroll-behavior: smooth;
}

.message {
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 10px;
	max-width: 95%;
	scroll-snap-align: start;
	word-wrap: break-word;
}

.message.user {
    background: #007bff;
    color: white;
    text-align: left;
    align-self: flex-end;
	border-top-right-radius: 0px; 
}

.message.bot {
    background: #f1f1f1;
    color: #333;
	border-top-left-radius: 0px; 
}

#chatbot-typing {
    padding: 10px;
    font-style: italic;
    color: #666;
}

#chatbot-form {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ccc;
}

#chatbot-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#chatbot-send {
    padding: 8px 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    margin-left: 5px;
    cursor: pointer;
}

#chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}


/* WP */
/* Posizionamento fisso in basso a destra */
#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
	max-width: 90vw;
    min-height: 460px;
	height: 70vh;
    z-index: 9999;
    box-shadow: 0 0 12px #CC2F24;
}
#chatbot-widget.hidden {
    display: none;
}
.chat-header {
    position: relative;
    display: flex;
    justify-content: center;
    border-radius: 8px 0 0;
    padding: 3px;
}

/* Pulsante apertura chat — stile cliccabile */
#chat-open {
    position: fixed;
    right: 1em;
    bottom: 8.5em;
    background: none;
    padding: 0;
    filter: drop-shadow(5px 5px 7px black);
    z-index: 10;
    cursor: pointer;           /* mano */
    border: none;              /* nessun bordo */
    outline: none;             /* nessun outline al focus */
}
#chat-open img {
    border: none;              /* nessun bordo sull'immagine */
    cursor: pointer;
    display: block;
}
#chat-open:focus-visible {
    outline: 2px solid #007bff; /* focus accessibile ma discreto */
    outline-offset: 2px;
}

@media (width < 768px ) {
	#chat-open {
    bottom: 5.5em;
	}
}
	
#chat-close {
    position: absolute;
    right: -0.5em;
    top: -0.5em;
    background: var(--color-primary);
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    color: #fff;
    padding: 0.50em 0.7em;
    cursor: pointer;
    font-size: 1em;
    line-height: 1;
    transition: opacity 0.2s;
}
#chat-close:hover {
    opacity: 0.85;
}
@keyframes shake-timer {
  0%, 90% { transform: translate(0, 0); }
  91% { transform: translate(-5px, -5px); }
  93% { transform: translate(10px, -5px); }
  95% { transform: translate(-5px, 10px); }
  97% { transform: translate(5px, 5px); }
  100% { transform: translate(0, 0); }
}

.iconchat {
  animation: shake-timer 2s linear 3;
}

button#chat-open:before {
    width: 6rem;
    height: 3.8rem;
    position: absolute;
    content: attr(data-content);
    right: 20%;
    bottom: 90%;
    background: #fff;
    color: #111;
    border-radius: 50%;
    padding: 0.5rem;
	animation: fumetto 3s ease-in, fumettoHidden linear forwards;
	animation-timeline: auto, scroll();
    animation-range: normal, 0px 5px;
	
}
@keyframes fumetto {
	0% { opacity: 0; }
	30% { opacity: 0; }
    100% { opacity: 1; }
}
@keyframes fumettoHidden {
    to { opacity: 0; visibility: hidden; }
}
@keyframes sparisciPerSempre {
    to { opacity: 0; visibility: hidden; }
}

button#chat-open:active:before,
button#chat-open:focus:before {
    opacity: 0 !important;
    visibility: hidden !important;
	animation: sparisciPerSempre 0.1s forwards;
    animation-play-state: paused; 
}
