/* IDC Chatbot – stile widget
   Il colore principale arriva dall'admin via --idc-accent. */

#idc-chatbot-root {
	--idc-accent: #5b3a8c;
	--idc-accent-soft: color-mix(in srgb, var(--idc-accent) 12%, #ffffff);
	--idc-text: #2b2333;
	--idc-radius: 16px;
	--idc-bottom: 20px;
	--idc-side: 20px;
	position: fixed;
	bottom: var(--idc-bottom);
	z-index: 99999;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.5;
	color: var(--idc-text);
}

/* Posizioni */
#idc-chatbot-root.idc-pos-right { right: var(--idc-side); }
#idc-chatbot-root.idc-pos-left  { left: var(--idc-side); }
#idc-chatbot-root.idc-pos-center {
	left: 50%;
	transform: translateX(-50%);
}

/* FIX: qualsiasi display in CSS vince sull'attributo [hidden];
   senza questa regola il pannello non si chiude mai. */
#idc-chatbot-root .idc-panel[hidden] { display: none !important; }

/* Bolla */
#idc-chatbot-root .idc-bubble {
	width: 58px;
	height: 58px;
	border: 0;
	border-radius: 50%;
	background: var(--idc-accent);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
	transition: transform 0.15s ease;
}
#idc-chatbot-root .idc-bubble:hover { transform: scale(1.06); }
#idc-chatbot-root .idc-bubble:focus-visible {
	outline: 3px solid var(--idc-accent);
	outline-offset: 3px;
}

/* Pannello */
#idc-chatbot-root .idc-panel {
	position: absolute;
	bottom: 72px;
	width: min(370px, calc(100vw - 32px));
	height: min(540px, calc(100vh - 120px));
	background: #fff;
	border-radius: var(--idc-radius);
	box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: idc-pop 0.18s ease;
}
@keyframes idc-pop {
	from { opacity: 0; transform: translateY(10px) scale(0.98); }
	to   { opacity: 1; transform: none; }
}
#idc-chatbot-root.idc-pos-right .idc-panel  { right: 0; }
#idc-chatbot-root.idc-pos-left .idc-panel   { left: 0; }
#idc-chatbot-root.idc-pos-center .idc-panel {
	left: 50%;
	transform: translateX(-50%);
}
/* In posizione centrale l'animazione non deve sovrascrivere il centraggio */
#idc-chatbot-root.idc-pos-center .idc-panel { animation: none; }

/* Header */
#idc-chatbot-root .idc-header {
	background: var(--idc-accent);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
#idc-chatbot-root .idc-header-title { font-weight: 600; }
#idc-chatbot-root .idc-close {
	background: none;
	border: 0;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
}
#idc-chatbot-root .idc-close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
	border-radius: 4px;
}

/* Disclaimer */
#idc-chatbot-root .idc-disclaimer {
	font-size: 11.5px;
	color: #6b6475;
	background: var(--idc-accent-soft);
	padding: 7px 14px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Messaggi */
#idc-chatbot-root .idc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #faf9fb;
}
#idc-chatbot-root .idc-msg {
	max-width: 84%;
	padding: 9px 13px;
	border-radius: 14px;
	word-wrap: break-word;
	overflow-wrap: break-word;
}
#idc-chatbot-root .idc-msg--assistant {
	align-self: flex-start;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-bottom-left-radius: 4px;
}
#idc-chatbot-root .idc-msg--user {
	align-self: flex-end;
	background: var(--idc-accent);
	color: #fff;
	border-bottom-right-radius: 4px;
}
#idc-chatbot-root .idc-msg a {
	color: var(--idc-accent);
	text-decoration: underline;
	font-weight: 600;
}
#idc-chatbot-root .idc-msg--user a { color: #fff; }

/* Indicatore digitazione */
#idc-chatbot-root .idc-typing {
	display: inline-flex;
	gap: 4px;
	padding: 2px 0;
}
#idc-chatbot-root .idc-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #b9b3c2;
	animation: idc-blink 1.2s infinite ease-in-out;
}
#idc-chatbot-root .idc-typing span:nth-child(2) { animation-delay: 0.15s; }
#idc-chatbot-root .idc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes idc-blink {
	0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-3px); }
}

/* Input */
#idc-chatbot-root .idc-input-row {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	background: #fff;
	margin: 0;
}
#idc-chatbot-root .idc-input {
	flex: 1;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 999px;
	padding: 9px 15px;
	font-size: 15px;
	font-family: inherit;
	outline: none;
	background: #fff;
	color: var(--idc-text);
}
#idc-chatbot-root .idc-input:focus {
	border-color: var(--idc-accent);
	box-shadow: 0 0 0 3px var(--idc-accent-soft);
}
#idc-chatbot-root .idc-send {
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: var(--idc-accent);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
#idc-chatbot-root .idc-send:disabled,
#idc-chatbot-root .idc-input:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}
#idc-chatbot-root .idc-send:focus-visible {
	outline: 3px solid var(--idc-accent);
	outline-offset: 2px;
}

/* Mobile */
@media (max-width: 480px) {
	#idc-chatbot-root .idc-panel {
		width: calc(100vw - 24px);
		height: min(70vh, 560px);
	}
}

/* Riduzione movimento */
@media (prefers-reduced-motion: reduce) {
	#idc-chatbot-root .idc-panel { animation: none; }
	#idc-chatbot-root .idc-bubble { transition: none; }
	#idc-chatbot-root .idc-typing span { animation: none; opacity: 0.7; }
}
