#chatbot-widget {
	position: fixed;
	bottom: 10px;
	right: 20px;
	z-index: 1000;
	animation: chatbot-widget-in 0.7s ease both;
}

/* Solo opacity, niente transform: un elemento con un transform diverso da
   "none" (anche translateY(0), a fine animazione) diventa il containing
   block dei discendenti position:fixed. #chatbot-panel è fixed a schermo
   intero su mobile (vedi media query più sotto): se #chatbot-widget avesse
   un transform, il pannello si posizionerebbe relativo al widget invece che
   al viewport, restando ancorato nell'angolo dell'opener. */
@keyframes chatbot-widget-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

#chatbot-toggle {
	width: 80px;
	height: 80px;
	border-radius: 50%;
	border: none;
	background: linear-gradient(135deg, #c79a3a, #B08016);
	color: #fff;
	font-size: 24px;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(176, 128, 22, 0.45);
	transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

#chatbot-toggle:hover {
	transform: translateY(-2px) scale(1.05);
	box-shadow: 0 6px 18px rgba(176, 128, 22, 0.6);
	filter: brightness(1.08);
}

#chatbot-toggle:active {
	transform: translateY(0) scale(0.97);
}

/* Pulsazione dorata che invita al click: gira sempre finché la chat è chiusa.
   L'anello nasce da un box-shadow trasparente che si espande e svanisce,
   sovrapposto al box-shadow fisso del toggle. In pausa solo con l'hover o a
   pannello aperto (selettore fratello: nel DOM #chatbot-panel precede
   #chatbot-toggle, wrap.appendChild(panel) prima di wrap.appendChild(toggle)
   in chatbot.js), poi riparte automaticamente alla chiusura. */
#chatbot-toggle.chatbot-attention {
	animation: chatbot-toggle-pulse 2.4s ease-out infinite, chatbot-toggle-bounce 2.4s ease-in-out infinite;
}

#chatbot-toggle.chatbot-attention:hover,
#chatbot-panel.open ~ #chatbot-toggle.chatbot-attention {
	animation-play-state: paused;
}

@keyframes chatbot-toggle-pulse {
	0% {
		box-shadow: 0 4px 14px rgba(176, 128, 22, 0.45), 0 0 0 0 rgba(199, 154, 58, 0.55);
	}
	70% {
		box-shadow: 0 4px 14px rgba(176, 128, 22, 0.45), 0 0 0 16px rgba(199, 154, 58, 0);
	}
	100% {
		box-shadow: 0 4px 14px rgba(176, 128, 22, 0.45), 0 0 0 16px rgba(199, 154, 58, 0);
	}
}

@keyframes chatbot-toggle-bounce {
	0%, 60%, 100% {
		transform: translateY(0);
	}
	15% {
		transform: translateY(-6px);
	}
	30% {
		transform: translateY(0);
	}
}

/* Avatar reale al posto del fumetto 💬, quando configurato (vedi applyAvatar()
   in chatbot.js): il resto (bordo dorato, ombra, hover) resta quello del
   toggle normale. Selettore #chatbot-toggle.chatbot-toggle-avatar (più
   specifico del solo #chatbot-toggle) per azzerare qui il gradiente:
   altrimenti lo shorthand "background" della regola base vince comunque
   sulla sola background-size/position della classe. background-color resta
   come fallback dorato se l'immagine non dovesse caricare. */
#chatbot-toggle.chatbot-toggle-avatar {
	background-image: none;
	background-color: #B08016;
	background-size: cover;
	background-position: center;
}

#chatbot-panel {
	display: flex;
	position: absolute;
	bottom: 100px;
	right: 0;
	width: min(550px, calc(100vw - 40px));
	max-height: calc(90vh - 120px);
	background: #ffffffdb;
	border-radius: 35px;
	box-shadow: 0 10px 32px rgba(0,0,0,0.22), 0 0 0 1px rgba(176, 128, 22, 0.12);
	overflow: hidden;
	flex-direction: column;
	transform-origin: bottom right;
	opacity: 0;
	visibility: hidden;
	transform: translateY(10px) scale(0.94);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
	z-index: 1;
	/* top: 30px; */
	backdrop-filter: blur(5px);
	border: 1px solid #fff;
	height: 100vh;
}

#chatbot-panel.open {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	transition: opacity 0.22s cubic-bezier(0.2, 0.8, 0.3, 1.1), transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1.1), visibility 0s linear 0s;
}

#chatbot-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: #1a1a1a;
	color: #fff;
	padding: 14px 16px;
	font-size: 20px;
	border-bottom: 2px solid #B08016;
	font-family: 'Cinzel', serif;
	text-transform: uppercase;
	border-radius: 50px;
}

#chatbot-header-identity {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.chatbot-avatar-header {
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
}

#chatbot-header-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

#chatbot-header-name {
	font-family: 'Cinzel', serif;
	font-size: 15px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#chatbot-header-hotel {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11px;
	text-transform: none;
	font-weight: normal;
	letter-spacing: normal;
	color: rgba(255, 255, 255, 0.65);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	text-align: left;
}

#chatbot-header-actions {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

#chatbot-minimize,
#chatbot-new {
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 18px;
	line-height: 1;
	padding: 0;
	width: 30px;
	height: 30px;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

#chatbot-minimize:hover,
#chatbot-new:hover {
	background: #B08016;
	color: #fff;
	transform: scale(1.08);
	box-shadow: 0 2px 8px rgba(176, 128, 22, 0.55);
}

#chatbot-minimize:active,
#chatbot-new:active {
	transform: scale(0.95);
}

/* Dichiarazione di interazione con un sistema di IA (art. 50 AI Act). Sempre
   visibile per tutta la durata della conversazione: flex-shrink a 0 perché il
   pannello è un flex column dove #chatbot-messages ha flex:1 e altrimenti la
   comprimerebbe. Colori in rgba invece che tinte piene per non stonare con le
   personalizzazioni grafiche dei singoli siti. */
#chatbot-ai-notice {
	flex-shrink: 0;
	padding: 7px 16px;
	font-size: 11px;
	line-height: 1.35;
	text-align: center;
	color: #666;
	/* background: rgba(0, 0, 0, 0.04); */
	border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

#chatbot-messages {
	position: relative;
	flex: 1;
	overflow-y: auto;
	padding: 14px 12px;
	line-height: 1.8;
	min-height: 200px;
}

#chatbot-messages::-webkit-scrollbar {
	width: 6px;
}

#chatbot-messages::-webkit-scrollbar-thumb {
	background: rgba(176, 128, 22, 0.4);
	border-radius: 3px;
}

.chatbot-msg {
	margin-bottom: 15px;
	padding: 18px;
	border-radius: 25px;
	max-width: 80%;
	white-space: pre-wrap;
	text-align: left;
	font-size: 1rem;
	box-shadow: 0 1px 2px rgba(0,0,0,0.2);
	animation: chatbot-msg-in 0.25s ease;
}

/* Riga che affianca l'avatar alle risposte dell'IA (e alla bolla "sta
   scrivendo"): la bolla mantiene la stessa larghezza/comportamento di prima
   grazie a flex-grow, l'avatar occupa una colonna fissa a sinistra. */
.chatbot-row {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	margin-bottom: 15px;
}

.chatbot-row .chatbot-msg {
	flex: 1 1 auto;
	margin-bottom: 0;
}

.chatbot-avatar {
	flex: 0 0 36px;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background-color: #B08016;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' fill='%23B08016'/%3E%3Cellipse cx='20' cy='14.5' rx='8.6' ry='9' fill='%23fff'/%3E%3Cellipse cx='12.3' cy='19' rx='3' ry='6.4' fill='%23fff'/%3E%3Cellipse cx='27.7' cy='19' rx='3' ry='6.4' fill='%23fff'/%3E%3Cellipse cx='20' cy='37' rx='12.5' ry='9' fill='%23fff'/%3E%3C/svg%3E");
	background-size: cover;
	background-position: center;
	box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}

.chatbot-msg p, .chatbot-msg li {
	font-size: 0.95rem;
	line-height: 1.6;
	margin-bottom: 5px;
	color: var(--darkercolor);
}

@keyframes chatbot-msg-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.chatbot-msg.user {
	background: #B08016;
	color: #fff;
	margin-left: auto;
	border-top-right-radius: 0;
	border-bottom-right-radius: 25px;
}

.chatbot-msg.bot {
	background: #fff;
	/*border: 1px solid #eee;
	border-left: 3px solid #B08016;*/
	margin-right: auto;
	border-top-left-radius: 0;
	border-bottom-left-radius: 25px;
}
.chatbot-msg.bot p{
	text-align: left;
}

.chatbot-msg.error {
	background: #fdecea;
	color: #611a15;
	border-left: 3px solid #c0392b;
}

.chatbot-msg.warning {
	background: #fdf3df;
	color: #6b4e0a;
	border-left: 3px solid #B08016;
}

.chatbot-typing {
	display: flex;
	align-items: center;
	padding: 12px 14px;
}

.chatbot-typing-dots {
	display: inline-flex;
	gap: 4px;
	margin: 5px 0;
}

.chatbot-typing-dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #B08016;
	opacity: 0.6;
	animation: chatbot-typing-bounce 1.1s infinite ease-in-out;
}

.chatbot-typing-dots span:nth-child(2) {
	animation-delay: 0.15s;
}

.chatbot-typing-dots span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes chatbot-typing-bounce {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.5;
	}
	30% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

.chatbot-msg p,
.chatbot-msg ul {
	margin: 0 0 8px;
}

.chatbot-msg ul {
	padding-left: 18px;
}

.chatbot-msg p:last-child,
.chatbot-msg ul:last-child {
	margin-bottom: 0;
}

.chatbot-msg img {
	display: block;
	max-width: 100%;
	height: auto;
	border-radius: 8px;
	margin: 6px 0;
}

.chatbot-msg a:not(.chatbot-booking-link) {
	color: #B08016;
	font-weight: bold;
}

/* Le foto aprono l'originale in una nuova scheda. Bordi/underline azzerati
   qui perché il widget vive dentro siti con CSS proprio, che spesso decora
   i link e le immagini dentro i link. */
.chatbot-msg a.chatbot-img-link {
	display: block;
	border: none;
	text-decoration: none;
	cursor: zoom-in;
}

.chatbot-booking-link {
	display: inline-block;
	margin-top: 6px;
	padding: 7px 12px;
	background: #B08016;
	color: #fff !important;
	border-radius: 6px;
	font-size: 12px;
	font-weight: bold;
	text-decoration: none;
	box-shadow: 0 2px 6px rgba(176, 128, 22, 0.35);
	transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.chatbot-booking-link:hover {
	background: #8f6812;
	transform: translateY(-1px);
	box-shadow: 0 4px 10px rgba(176, 128, 22, 0.5);
}

#chatbot-form {
	position: relative;
	display: flex;
	margin: 10px 15px;
}

/*
#chatbot-form::before{
    content: "";
    display: block;
    position: absolute;
    top: -50px;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, rgba(255, 255, 255, 100), rgba(255, 255, 255, 0));
}*/

#chatbot-input {
	flex: 1;
	border: 0;
	padding: 15px;
	font-size: 14px;
	font-family: 'Poppins', sans-serif;
	outline: none;
	transition: background 0.15s ease;
	border-radius: 65px;
}

#chatbot-input:focus {
	/* background: #fdf6e8; */
}

/* Spazio per il pulsante microfono, che galleggia dentro il campo di testo. */
#chatbot-form.has-mic #chatbot-input {
	padding-right: 44px;
}

#chatbot-mic {
	display: flex;
	align-items: center;
	justify-content: center;
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: #B08016;
	cursor: pointer;
	padding: 0;
	transition: background 0.15s ease, color 0.15s ease;
}

#chatbot-mic:hover {
	background: rgba(176, 128, 22, 0.12);
}

#chatbot-mic.listening {
	color: #fff;
	background: #c0392b;
	animation: chatbot-mic-pulse 1.2s infinite;
}

@keyframes chatbot-mic-pulse {
	0%, 100% {
		box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.45);
	}
	50% {
		box-shadow: 0 0 0 8px rgba(192, 57, 43, 0);
	}
}

#chatbot-send {
	display: none;
	border: none;
	background: #B08016;
	color: #fff;
	padding: 0 16px;
	cursor: pointer;
	font-weight: bold;
	font-family: 'Poppins', sans-serif;
	transition: background 0.15s ease;
}

#chatbot-send:hover:not(:disabled) {
	background: #8f6812;
}

#chatbot-send:disabled {
	opacity: 0.5;
	cursor: default;
}

/* Visibile solo su chat nuova (nessun messaggio ancora scambiato): il toggle
   display none/'' è gestito da JS (updatePrivacyNotice). */
#chatbot-privacy-notice {
	padding: 4px 15px 14px;
	font-size: 11px;
	line-height: 1.4;
	color: #999;
	text-align: center;
}

#chatbot-privacy-notice a {
	color: #B08016;
	text-decoration: underline;
}

/* --- Mobile: popup a schermo intero, opener più piccolo --- */
@media (max-width: 640px) {
	#chatbot-widget {
		right: 14px;
		bottom: 14px;
	}

	#chatbot-toggle {
		width: 54px;
		height: 54px;
		font-size: 18px;
	}

	/* A schermo intero il pannello non è più una "finestra" ancorata
	   all'opener: copre il viewport e scivola dal basso come un foglio,
	   invece di scalare da un angolo (transform-origin bottom right ha senso
	   solo per un popup). position:fixed + inset:0 è più affidabile di
	   width/height:100vh sui browser mobile, la cui barra degli indirizzi
	   si nasconde/mostra facendo variare l'altezza reale del viewport. */
	#chatbot-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-height: none;
		border-radius: 0;
		transform: translateY(100%);
		transition: opacity 0.2s ease, transform 0.25s ease, visibility 0s linear 0.25s;
	}

	#chatbot-panel.open {
		transform: translateY(0);
		transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0s;
	}

	#chatbot-messages {
		min-height: 0;
	}

	/* Con il pannello a schermo intero, la pagina sotto resterebbe altrimenti
	   scrollabile (classe aggiunta/rimossa da setPanelOpen() in chatbot.js). */
	body.chatbot-body-lock {
		overflow: hidden;
	}

	/* Spazio per notch/status bar e home indicator quando il foglio copre tutto lo schermo. */
	#chatbot-header {
		padding-top: calc(14px + env(safe-area-inset-top, 0px));
	}

	#chatbot-form {
		margin-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
	}
}
