.mac-chat {
	--mac-primary: #6f9802;
	--mac-header-bg: #2c3a16;
	--mac-user-bubble: #6f9802;
	--mac-bot-text: #3a4a2a;
	--mac-light: #F4F5F6;
	--mac-white: #FFFFFF;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	position: relative;
	max-width: 560px;
	margin: 0 auto;
	border: 1px solid #E6E8EA;
	border-radius: 14px;
	overflow: hidden;
	background: var(--mac-white, #FFFFFF);
	display: flex;
	flex-direction: column;
	height: 600px;
	box-shadow: 0 8px 30px rgba(25, 25, 25, 0.06);
}

.mac-chat *,
.mac-fab-wrap * {
	box-sizing: border-box;
}

.mac-chat-header {
	background: var(--mac-header-bg, #2c3a16);
	color: var(--mac-white, #FFFFFF);
	padding: 16px 20px;
	display: flex;
	align-items: center;
	flex: 0 0 auto;
}

.mac-chat-title {
	font-weight: 500;
	font-size: 16px;
	letter-spacing: 0.02em;
}

.mac-chat-messages {
	flex: 1 1 auto;
	min-height: 0; /* indispensabile: senza questo i bubble si comprimono e si sovrappongono */
	overflow-y: auto;
	padding: 20px;
	background: var(--mac-light, #F4F5F6);
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.mac-bubble {
	flex: 0 0 auto; /* impedisce la compressione/sovrapposizione dei messaggi */
	max-width: 82%;
	width: fit-content;
	padding: 12px 15px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.55;
	color: var(--mac-bot-text, #3a4a2a);
	background: var(--mac-white, #FFFFFF);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.mac-bubble-bot {
	align-self: flex-start;
	border-bottom-left-radius: 4px;
	border: 1px solid #E3E7DD;
}

.mac-bubble-user {
	align-self: flex-end;
	background: var(--mac-user-bubble, #6f9802);
	color: var(--mac-white, #FFFFFF);
	border-bottom-right-radius: 4px;
}

.mac-bubble-user .mac-bubble-text strong { color: var(--mac-white, #FFFFFF); }
.mac-bubble-text strong { font-weight: 600; color: inherit; }

.mac-ul {
	margin: 6px 0 2px;
	padding-left: 18px;
	list-style: disc;
}
.mac-ul li { margin: 2px 0; }

.mac-bubble-sources {
	margin-top: 9px;
	padding-top: 8px;
	border-top: 1px solid #E3E7DD;
	font-size: 12px;
	display: flex;
	flex-direction: column;
	gap: 3px;
}
.mac-bubble-sources-label { color: #8A8F84; font-weight: 600; }
.mac-bubble-sources a { color: var(--mac-primary, #6f9802); text-decoration: none; font-weight: 500; }
.mac-bubble-sources a:hover { text-decoration: underline; }

/* "Potrebbe interessarti anche": suggerimenti di altri contenuti del sito,
   distinti dalle fonti usate per la risposta (testo più tenue, corsivo). */
.mac-bubble-related {
	margin-top: 6px;
	font-size: 12px;
	color: #8A8F84;
	font-style: italic;
}
.mac-bubble-related-label { margin-right: 2px; }
.mac-bubble-related a {
	color: var(--mac-primary, #6f9802);
	text-decoration: none;
	font-weight: 500;
	font-style: normal;
}
.mac-bubble-related a:hover { text-decoration: underline; }
.mac-bubble-related a:not(:last-child)::after { content: ' · '; color: #8A8F84; font-style: normal; }
.mac-bubble-sources + .mac-bubble-related { margin-top: 6px; padding-top: 0; border-top: none; }

/* Link alla scheda pianta: mostrato solo quando il server ha verificato che
   la pagina esiste (nessun rischio 404). Visivamente simile alle fonti ma
   con un pulsante/link leggermente più prominente per invitare all'approfondimento. */
.mac-bubble-plant {
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid #E3E7DD;
}
.mac-bubble-plant a {
	display: inline-block;
	color: var(--mac-primary, #6f9802);
	font-size: 12.5px;
	font-weight: 500;
	text-decoration: none;
}
.mac-bubble-plant a:hover { text-decoration: underline; }

.mac-typing { display: flex; gap: 5px; align-items: center; padding: 15px; }
.mac-dot { width: 7px; height: 7px; border-radius: 50%; background: #C4C8C0; animation: mac-blink 1.2s infinite both; }
.mac-dot:nth-child(2) { animation-delay: 0.2s; }
.mac-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes mac-blink { 0%,60%,100% { opacity: 0.3; } 30% { opacity: 1; } }

.mac-quick {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 12px 14px 0;
	background: var(--mac-white, #FFFFFF);
}
.mac-chip {
	border: 1px solid var(--mac-primary, #6f9802);
	color: var(--mac-primary, #6f9802);
	background: transparent;
	border-radius: 999px;
	padding: 7px 13px;
	font-family: inherit;
	font-size: 12.5px;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}
.mac-chip:hover { background: var(--mac-primary, #6f9802); color: #fff; }

.mac-chat-form {
	flex: 0 0 auto;
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 14px;
	background: var(--mac-white, #FFFFFF);
	border-top: 1px solid #E3E7DD;
}

.mac-chat-input {
	flex: 1 1 auto;
	resize: none;
	border: 1px solid #D5DAD0;
	border-radius: 10px;
	padding: 11px 13px;
	font-family: inherit;
	font-size: 14px;
	color: #1f2a14;
	line-height: 1.4;
	max-height: 120px;
	overflow-y: hidden;
	outline: none;
	transition: border-color 0.15s ease;
}
.mac-chat-input:focus { border-color: var(--mac-primary, #6f9802); }

.mac-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.mac-chat-send {
	flex: 0 0 44px;
	width: 44px;
	height: 44px;
	min-width: 44px;
	min-height: 44px;
	max-height: 44px;
	box-sizing: border-box;
	padding: 0 !important;
	border: none;
	border-radius: 10px;
	background: var(--mac-primary, #6f9802);
	color: var(--mac-white, #FFFFFF);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 0;
	-webkit-appearance: none;
	appearance: none;
	transition: opacity 0.15s ease;
}
.mac-chat-send .mac-send-icon {
	display: block;
	width: 22px;
	height: 22px;
	flex: 0 0 auto;
	fill: currentColor;
	color: var(--mac-white, #FFFFFF);
}
.mac-chat-send:hover { opacity: 0.9; }
.mac-chat-send:focus-visible { outline: 2px solid var(--mac-header-bg, #2c3a16); outline-offset: 2px; }

/* Pulsante microfono per la modalità vocale */
.mac-chat-disclaimer {
	flex: 0 0 auto;
	padding: 4px 14px 10px;
	background: var(--mac-white, #FFFFFF);
	font-size: 11px;
	color: #A0A4A8;
	text-align: left;
}

/* Trigger modalit\u00e0 vocale nella barra disclaimer */
.mac-voice-trigger {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	color: var(--mac-primary, #6f9802);
	font-size: 11.5px;
	font-family: inherit;
	font-weight: 500;
	text-decoration: underline;
	text-decoration-color: rgba(111,152,2,.35);
	text-underline-offset: 2px;
	transition: color 0.15s, text-decoration-color 0.15s;
}
.mac-voice-trigger:hover {
	color: var(--mac-header-bg, #2c3a16);
	text-decoration-color: rgba(44,58,22,.5);
}
.mac-voice-trigger.mac-voice-active {
	color: #e53935;
	text-decoration-color: rgba(229,57,53,.35);
}
.mac-voice-trigger.mac-voice-active:hover { color: #b71c1c; }
.mac-voice-guest-note {
	margin-left: 5px;
	color: #7A8070;
	font-size: 10.5px;
	font-style: normal;
	text-decoration: none;
}
.mac-voice-guest-link {
	color: var(--mac-primary, #6f9802);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}
.mac-voice-guest-link:hover {
	color: var(--mac-header-bg, #2c3a16);
}
.mac-voice-trigger-icon {
	width: 13px;
	height: 13px;
	flex-shrink: 0;
}
.mac-voice-trigger.mac-voice-active .mac-voice-trigger-icon {
	animation: mac-voice-pulse-icon 1s ease-in-out infinite;
}
@keyframes mac-voice-pulse-icon {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.4; }
}
.mac-voice-indicator {
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #e53935;
	margin-left: 6px;
	animation: mac-blink 0.8s ease-in-out infinite;
	vertical-align: middle;
}

/* Consenso */
.mac-consent {
	display: none;
	position: absolute;
	inset: 0;
	background: rgba(255,255,255,0.97);
	z-index: 5;
	align-items: center;
	justify-content: center;
	padding: 24px;
}
.mac-consent-visible { display: flex; }
.mac-consent-inner { text-align: center; max-width: 320px; }
.mac-consent-text { font-size: 13.5px; color: #3a4a2a; line-height: 1.55; margin: 0 0 16px; }
.mac-consent-text a { color: var(--mac-primary, #6f9802); }
.mac-consent-accept {
	border: none;
	background: var(--mac-primary, #6f9802);
	color: #fff;
	border-radius: 10px;
	padding: 11px 20px;
	font-family: inherit;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
}
.mac-consent-accept:hover { opacity: 0.9; }

@media (max-width: 600px) {
	.mac-chat { height: 70vh; border-radius: 0; border-left: none; border-right: none; }
}
@media (prefers-reduced-motion: reduce) {
	.mac-dot { animation: none; }
	.mac-chat-input, .mac-chat-send, .mac-chip { transition: none; }
}

/* ===== Widget fluttuante ===== */
/* ===== Chat dentro il widget fluttuante ===== */
.mac-chat-floating { height: 520px; max-width: 100%; margin: 0; border: none; box-shadow: none; }
.mac-fab-panel .mac-chat { height: 520px; max-width: 100%; margin: 0; border: none; box-shadow: none; }

/* Avatar nell'intestazione */
.mac-chat-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
	margin-right: 10px;
	border: 2px solid rgba(255,255,255,0.85);
	flex: 0 0 auto;
}

/* CTA (es. invito a registrarsi) dentro una bolla */
.mac-bubble-cta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.mac-cta-btn {
	display: inline-block;
	background: var(--mac-primary, #6f9802);
	color: #fff;
	text-decoration: none;
	font-weight: 600;
	font-size: 13px;
	padding: 8px 14px;
	border-radius: 8px;
	border: 1px solid var(--mac-primary, #6f9802);
}
.mac-cta-btn:hover { opacity: 0.9; color: #fff; }
.mac-cta-btn-secondary {
	background: transparent;
	color: var(--mac-primary, #6f9802);
}
.mac-cta-btn-secondary:hover { background: rgba(0,0,0,0.04); color: var(--mac-primary, #6f9802); }

@media (max-width: 480px) {
	.mac-chat-floating { height: 70vh; border-radius: 14px; }
	.mac-fab-panel .mac-chat { height: 70vh; border-radius: 14px; }
}
