#rdc-assistant-root {
	position: fixed;
	z-index: 99999;
	right: 20px;
	bottom: 20px;
	font-family: inherit;
}

.rdc-hidden {
	display: none !important;
}

/* --- Launcher (iconcina rotonda) --------------------------------- */

#rdc-launcher {
	position: relative;
	width: 62px;
	height: 62px;
	border-radius: 50%;
	border: none !important;
	background: #f2994a !important; /* placeholder colore brand - da allineare al tema */
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22) !important;
	cursor: pointer !important;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 28px !important;
	padding: 0 !important;
	overflow: visible;
	animation: rdc-idle-bounce 3.5s ease-in-out infinite;
}

#rdc-launcher img {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
}

/* Alone pulsante: il solo bounce è troppo sottile per notare che l'icona è
   interattiva, questo anello che si espande e sfuma richiama l'attenzione
   come una notifica, senza essere invasivo (si ferma quando il pannello è aperto,
   perché il launcher stesso viene nascosto in quel momento). */
#rdc-launcher::after {
	content: '';
	position: absolute;
	top: 0; left: 0; right: 0; bottom: 0;
	border-radius: 50%;
	border: 3px solid #f2994a;
	animation: rdc-launcher-pulse 2.4s ease-out infinite;
	pointer-events: none;
}

/* --- Pannello chat ------------------------------------------------- */

#rdc-panel {
	position: fixed;
	right: 20px;
	bottom: 20px;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 40px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

#rdc-panel-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px !important;
	background: #f2994a !important;
	color: #fff !important;
	flex-shrink: 0;
}

#rdc-header-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

#rdc-panel-title {
	display: flex;
	flex-direction: column;
	flex: 1;
	line-height: 1.25;
}

#rdc-panel-title span {
	font-size: 0.78rem;
	opacity: 0.85;
}

#rdc-panel-close {
	background: transparent !important;
	border: none !important;
	color: #fff !important;
	font-size: 1.1rem !important;
	cursor: pointer !important;
	padding: 4px 6px !important;
	line-height: 1;
}

#rdc-panel-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #fafafa;
}

#rdc-panel-form {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #eee;
	flex-shrink: 0;
	background: #fff;
}

#rdc-panel-input {
	flex: 1;
	border: 1px solid #ddd !important;
	border-radius: 20px !important;
	padding: 10px 14px !important;
	font-size: 0.95rem !important;
	box-sizing: border-box;
	color: #333 !important;
	background: #fff !important;
}

#rdc-panel-send {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: none !important;
	background: #f2994a !important;
	color: #fff !important;
	font-size: 1rem;
	cursor: pointer !important;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 !important;
	line-height: 1;
}

#rdc-panel-footer {
	font-size: 0.7rem;
	color: #999;
	text-align: center;
	padding: 4px 0 8px;
	flex-shrink: 0;
}

/* --- Righe messaggio ------------------------------------------------ */

.rdc-row {
	display: flex;
	margin-bottom: 14px;
	align-items: flex-end;
	gap: 8px;
}

.rdc-row-user {
	justify-content: flex-end;
}

.rdc-bubble {
	max-width: 78%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 0.92rem;
	line-height: 1.4;
	word-wrap: break-word;
}

.rdc-bubble-user {
	background: #f2994a !important;
	color: #fff !important;
	border-bottom-right-radius: 4px;
}

.rdc-bubble-assistant {
	background: #fff;
	border: 1px solid #eee;
	color: #333;
	border-bottom-left-radius: 4px;
}

.rdc-bubble-text {
	white-space: pre-wrap;
}

.rdc-highlight {
	color: #b9631f !important;
	font-weight: 700 !important;
}

.rdc-link {
	color: #b9631f !important;
	text-decoration: underline !important;
}

.rdc-cta {
	display: block;
	margin-top: 10px;
	padding: 10px 14px !important;
	border-radius: 10px;
	background: #f2994a !important;
	color: #fff !important;
	font-weight: 600 !important;
	text-align: center;
	text-decoration: none !important;
}

.rdc-note {
	margin: 10px 0 0;
	font-size: 0.85rem;
	color: #2e7d32;
}

.rdc-quick-replies {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 10px;
}

.rdc-quick-reply {
	border: 1px solid #f2994a !important;
	background: #fff7ef !important;
	color: #b9631f !important;
	border-radius: 16px;
	padding: 8px 12px !important;
	font-size: 0.85rem !important;
	font-weight: 600 !important;
	cursor: pointer !important;
	text-align: left !important;
}

.rdc-quick-reply:hover {
	background: #fdeee0;
}

/* Indicatore "sta scrivendo" */
.rdc-typing {
	display: flex;
	gap: 4px;
	align-items: center;
	padding: 12px 14px;
}

.rdc-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #bbb;
	animation: rdc-typing-bounce 1.2s infinite ease-in-out;
}

.rdc-typing span:nth-child(2) { animation-delay: 0.15s; }
.rdc-typing span:nth-child(3) { animation-delay: 0.3s; }

/* --- Avatar mascotte nei messaggi assistente ------------------------ */

.rdc-avatar {
	position: relative;
	width: 32px;
	height: 32px;
	flex-shrink: 0;
	border-radius: 50%;
	overflow: hidden;
	background: #fff3e0;
}

.rdc-avatar img {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 160%;
	transform: translate(-50%, -50%);
}

@keyframes rdc-idle-bounce {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-4px); }
}

@keyframes rdc-launcher-pulse {
	0%   { transform: scale(1);   opacity: 0.6; }
	100% { transform: scale(1.45); opacity: 0; }
}

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

/* --- Mobile: riquadro flottante, MAI fullscreen (l'header con la X deve
   restare sempre visibile — su iOS Safari "100vh" non tiene conto della barra
   degli indirizzi dinamica, quindi un pannello ancorato in basso con height:100vh
   sfora sopra lo schermo visibile e nasconde l'header: qui si evita del tutto
   usando margini fissi invece di percentuali di viewport) --- */

@media (max-width: 480px) {
	#rdc-assistant-root {
		right: 12px;
		bottom: 12px;
	}

	#rdc-panel {
		right: 12px;
		bottom: 84px;
		left: auto;
		width: min(300px, calc(100vw - 24px));
		height: min(420px, calc(100vh - 140px));
		max-width: none;
		max-height: calc(100vh - 140px);
		border-radius: 16px;
	}
}
