#icb-chat-wrapper {
	position: fixed !important;
	z-index: 2147483647 !important;
	pointer-events: auto !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: var(--icb-font-size, 14px);
	color: #1f2937;
	margin: 0 !important;
}
#icb-chat-wrapper.icb-pos-bottom-right { right: 20px !important; bottom: 20px !important; left: auto !important; top: auto !important; }
#icb-chat-wrapper.icb-pos-bottom-left  { left: 20px !important;  bottom: 20px !important; right: auto !important; top: auto !important; }

/* Launcher */
#icb-launcher {
	width: 56px !important;
	height: 56px !important;
	min-width: 56px;
	min-height: 56px;
	border-radius: 50% !important;
	border: none !important;
	cursor: pointer;
	background: var(--icb-primary, #2563eb) !important;
	color: #fff !important;
	display: flex !important;
	visibility: visible !important;
	opacity: 1 !important;
	align-items: center; justify-content: center;
	box-shadow: 0 6px 18px rgba(0,0,0,0.18);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	padding: 0 !important;
}
#icb-launcher:hover  { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.22); }
#icb-launcher:active { transform: translateY(0); }
#icb-launcher:focus  { outline: 3px solid rgba(37, 99, 235, 0.4); outline-offset: 2px; }

/* Window */
#icb-window {
	position: absolute;
	bottom: 72px;
	width: var(--icb-width, 360px);
	height: var(--icb-height, 520px);
	max-width: calc(100vw - 32px);
	max-height: calc(100vh - 100px);
	background: var(--icb-bg, #ffffff);
	border-radius: var(--icb-radius, 12px);
	box-shadow: 0 14px 38px rgba(0,0,0,0.22);
	display: flex; flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	opacity: 0;
	transform: scale(0.95);
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.icb-pos-bottom-right #icb-window { right: 0; transform-origin: bottom right; }
.icb-pos-bottom-left  #icb-window { left: 0;  transform-origin: bottom left; }

#icb-chat-wrapper.icb-open #icb-window {
	opacity: 1;
	transform: scale(1);
}

/* Header */
#icb-header {
	background: var(--icb-primary, #2563eb);
	color: var(--icb-header-text, #ffffff);
	padding: 12px 14px;
	display: flex; align-items: center; gap: 10px;
	flex: 0 0 auto;
}
#icb-avatar {
	width: 28px; height: 28px;
	border-radius: 50%;
	object-fit: cover;
	background: rgba(255,255,255,0.25);
}
#icb-bot-name { font-weight: 600; flex: 1; }
#icb-close {
	background: transparent; border: none; cursor: pointer;
	color: var(--icb-header-text, #ffffff);
	font-size: 16px; padding: 4px 6px; border-radius: 4px;
}
#icb-close:hover { background: rgba(255,255,255,0.18); }

/* Messages */
.icb-msgs {
	flex: 1 1 auto;
	overflow-y: auto;
	scroll-behavior: smooth;
	padding: 12px 14px;
	background: var(--icb-bg, #ffffff);
}

.icb-msg {
	display: flex;
	margin-bottom: 10px;
}
.icb-msg-user      { justify-content: flex-end; }
.icb-msg-assistant { justify-content: flex-start; }
.icb-msg-error     { justify-content: flex-start; }

.icb-msg-bubble {
	max-width: 78%;
	padding: 8px 12px;
	border-radius: 14px;
	line-height: 1.4;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.icb-msg-user .icb-msg-bubble {
	background: var(--icb-user-bubble, #2563eb);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}
.icb-msg-assistant .icb-msg-bubble {
	background: var(--icb-bot-bubble, #f1f5f9);
	color: #111827;
	border-bottom-left-radius: 4px;
}
.icb-msg-error .icb-msg-bubble {
	background: #fee2e2;
	color: #991b1b;
	border: 1px solid #fecaca;
}

/* Disclaimer riquadro mostrato all'apertura della chat */
.icb-msg-disclaimer { justify-content: stretch; }
.icb-msg-disclaimer .icb-msg-bubble {
	max-width: 100%;
	background: #fef3c7;
	color: #78350f;
	border: 1px solid #fbbf24;
	border-radius: 8px;
	font-size: 0.92em;
	font-style: italic;
	padding: 10px 12px;
	line-height: 1.45;
}

.icb-cache-badge {
	display: inline-block;
	margin-left: 6px;
	font-size: 10px;
	opacity: 0.55;
	vertical-align: middle;
}

/* Launcher base needs relative positioning for absolutely-placed arcs and visible overflow so arcs that extend slightly past the button don't get clipped. */
#icb-launcher { position: relative; overflow: visible; }

/* ── Animations ── */

/* Arcs */
@keyframes meic-arc-spin {
	from { transform: rotate(0deg); }
	to   { transform: rotate(360deg); }
}
.icb-arcs {
	position: absolute;
	inset: -4px;
	pointer-events: none;
}
.icb-arc {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}
.icb-arc-path {
	stroke-width: var(--meic-arc-thickness, 3.5px);
	stroke-linecap: round;
}

/* Bounce keyframes */
@keyframes meic-bounce-soft {
	0%,100% { transform: translateY(0); }
	40%     { transform: translateY(-8px); }
	60%     { transform: translateY(-5px); }
}
@keyframes meic-bounce-hard {
	0%,100% { transform: translateY(0)    scale(1, 1); }
	30%     { transform: translateY(-12px) scale(0.95, 1.05); }
	50%     { transform: translateY(-8px)  scale(1.05, 0.95); }
	70%     { transform: translateY(-4px)  scale(1, 1); }
}
@keyframes meic-bounce-pulse {
	0%,100% { transform: scale(1); }
	50%     { transform: scale(1.08); }
}

/* Animations apply by default when chat is closed. !important guards against the
 * launcher base rule (which uses several !important declarations for visibility hardening). */
#icb-chat-wrapper:not(.icb-open) #icb-launcher.icb-anim-arc .icb-arc {
	animation: meic-arc-spin var(--meic-arc-speed, 2s) linear infinite !important;
	transform-origin: center !important;
}
#icb-chat-wrapper:not(.icb-open) #icb-launcher.icb-anim-bounce.icb-bounce-soft  { animation: meic-bounce-soft  var(--meic-bounce-speed, 1.2s) ease-in-out infinite !important; }
#icb-chat-wrapper:not(.icb-open) #icb-launcher.icb-anim-bounce.icb-bounce-hard  { animation: meic-bounce-hard  var(--meic-bounce-speed, 1.2s) ease-in-out infinite !important; }
#icb-chat-wrapper:not(.icb-open) #icb-launcher.icb-anim-bounce.icb-bounce-pulse { animation: meic-bounce-pulse var(--meic-bounce-speed, 1.2s) ease-in-out infinite !important; }

/* Pause bounce on hover so the existing hover translateY(-2px) doesn't fight the keyframes */
#icb-launcher.icb-anim-bounce:hover { animation-play-state: paused; }

/* Accessibility: respect explicit reduce-motion preference */
@media (prefers-reduced-motion: reduce) {
	#icb-chat-wrapper #icb-launcher.icb-anim-arc .icb-arc,
	#icb-chat-wrapper #icb-launcher.icb-anim-bounce { animation: none !important; }
}

/* Launcher icon when using <img> instead of inline SVG */
#icb-launcher img {
	width: 26px;
	height: 26px;
	object-fit: contain;
}
/* White-tint only the bundled monochrome SVG presets so they stand out on the colored button */
#icb-launcher img.icb-launcher-preset {
	filter: brightness(0) invert(1);
}
/* Custom-uploaded images keep their original colors but get a slightly larger box for photos/logos */
#icb-launcher img.icb-launcher-custom {
	width: 36px;
	height: 36px;
	border-radius: 50%;
}

/* Bubble avatars */
.icb-bubble-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}
.icb-msg-user      .icb-bubble-avatar { order: 2; margin-left: 6px; }
.icb-msg-assistant .icb-bubble-avatar { order: 0; margin-right: 6px; }
.icb-msg { align-items: flex-end; }

/* Typing dots */
.icb-typing {
	padding: 6px 16px 0;
	display: flex; gap: 4px;
}
.icb-typing[hidden] { display: none; }
.icb-typing span {
	width: 6px; height: 6px;
	border-radius: 50%;
	background: #94a3b8;
	animation: icb-bounce 1s infinite ease-in-out;
}
.icb-typing span:nth-child(2) { animation-delay: 0.15s; }
.icb-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes icb-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
	40%           { transform: translateY(-4px); opacity: 1; }
}

/* Input */
.icb-input-area {
	flex: 0 0 auto;
	display: flex !important;
	flex-direction: row !important;
	align-items: stretch !important;
	gap: 6px;
	border-top: 1px solid #e5e7eb;
	padding: 8px 10px;
	background: var(--icb-bg, #ffffff);
	box-sizing: border-box;
	width: 100%;
}
.icb-input {
	flex: 1 1 0 !important;
	min-width: 0 !important;
	max-width: 100% !important;
	min-height: 38px !important;
	box-sizing: border-box !important;
	resize: none;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 8px 10px;
	font: inherit;
	line-height: 1.4;
	color: inherit;
	max-height: 120px;
	background: #fff;
}
.icb-input:focus {
	outline: none;
	border-color: var(--icb-primary, #2563eb);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.icb-send {
	flex: 0 0 38px !important;
	width: 38px !important;
	height: 38px !important;
	min-width: 38px !important;
	min-height: 38px !important;
	max-width: 38px !important;
	box-sizing: border-box !important;
	background: var(--icb-primary, #2563eb) !important;
	color: #fff !important;
	border: none !important;
	border-radius: 10px !important;
	padding: 0 !important;
	margin: 0 !important;
	display: flex !important;
	visibility: visible !important;
	opacity: 1 !important;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
.icb-send:disabled { opacity: 0.5 !important; cursor: not-allowed; }
.icb-send svg { width: 20px; height: 20px; flex-shrink: 0; }

/* Mobile */
@media (max-width: 480px) {
	#icb-chat-wrapper.icb-pos-bottom-right,
	#icb-chat-wrapper.icb-pos-bottom-left {
		right: 12px; left: 12px; bottom: 12px;
	}
	#icb-window {
		position: fixed;
		left: 0; right: 0; top: 0; bottom: 0;
		width: 100vw; height: 100vh;
		max-width: 100vw; max-height: 100vh;
		border-radius: 0;
	}
	#icb-launcher {
		position: absolute;
		right: 0; bottom: 0;
	}
	.icb-pos-bottom-left #icb-launcher {
		left: 0; right: auto;
	}
}

/* ── Inline mode (shortcode [me_chatbot]) ── */
/* Safety net: page builders may render the shortcode twice — JS removes
   duplicates from DOM but if JS fails to run, hide all but the first sibling. */
.icb-inline-chat ~ .icb-inline-chat { display: none !important; }
.icb-inline-chat {
	width: 100%;
	max-width: 100%;
	height: var(--meic-inline-height, 600px);
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	background: var(--icb-bg, #fff);
	border: 1px solid #e5e7eb;
	border-radius: var(--icb-radius, 12px);
	overflow: hidden;
	box-shadow: 0 4px 12px rgba(0,0,0,0.08);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: var(--icb-font-size, 14px);
	color: #1f2937;
	box-sizing: border-box;
	margin: 1em 0;
}
.icb-inline-header {
	background: var(--icb-primary, #2563eb);
	color: var(--icb-header-text, #fff);
	padding: 12px 14px;
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 0 0 auto;
}
.icb-inline-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
	background: rgba(255,255,255,0.25);
}
.icb-inline-bot-name {
	font-weight: 600;
	flex: 1;
}
