/* AI Chatbot KB - stili frontend */
#aickb-widget {
	--aickb-primary: #2563eb;
	position: fixed;
	bottom: 20px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}
#aickb-widget.aickb-pos-right { right: 20px; }
#aickb-widget.aickb-pos-left { left: 20px; }

/* Bolla di apertura */
.aickb-toggle {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	background: var(--aickb-primary);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .15s ease, box-shadow .15s ease;
	position: relative;
	margin-left: auto;
}
.aickb-toggle:hover { transform: scale(1.06); }
.aickb-toggle .aickb-icon-close { display: none; }
#aickb-widget.aickb-open .aickb-toggle .aickb-icon-chat { display: none; }
#aickb-widget.aickb-open .aickb-toggle .aickb-icon-close { display: block; }

/* Pannello */
.aickb-panel {
	position: absolute;
	bottom: 74px;
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
	display: none;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px);
	transition: opacity .2s ease, transform .2s ease;
}
#aickb-widget.aickb-pos-right .aickb-panel { right: 0; }
#aickb-widget.aickb-pos-left .aickb-panel { left: 0; }
#aickb-widget.aickb-open .aickb-panel {
	display: flex;
	opacity: 1;
	transform: translateY(0);
}

/* Header */
.aickb-header {
	background: var(--aickb-primary);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.aickb-title { font-weight: 600; }
.aickb-min {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	opacity: .85;
}
.aickb-min:hover { opacity: 1; }

/* Messaggi */
.aickb-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #f7f8fa;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.aickb-msg {
	max-width: 82%;
	padding: 10px 13px;
	border-radius: 14px;
	word-wrap: break-word;
	white-space: pre-wrap;
	animation: aickb-fade .18s ease;
}
.aickb-msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.aickb-msg-bot {
	background: #fff;
	color: #1f2937;
	align-self: flex-start;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
}
.aickb-msg-user {
	background: var(--aickb-primary);
	color: #fff;
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}
.aickb-link-cta {
	display: inline-block;
	margin-top: 8px;
	padding: 8px 12px;
	background: var(--aickb-primary);
	color: #fff !important;
	border-radius: 8px;
	text-decoration: none !important;
	font-weight: 600;
	font-size: 14px;
}

/* Indicatore "sta scrivendo" */
.aickb-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	padding: 12px 14px;
}
.aickb-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9ca3af;
	animation: aickb-bounce 1.2s infinite ease-in-out;
}
.aickb-typing span:nth-child(2) { animation-delay: .2s; }
.aickb-typing span:nth-child(3) { animation-delay: .4s; }

/* Barra input */
.aickb-inputbar {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
}
#aickb-input {
	flex: 1;
	border: 1px solid #d1d5db;
	border-radius: 22px;
	padding: 10px 14px;
	font-size: 15px;
	outline: none;
}
#aickb-input:focus { border-color: var(--aickb-primary); }
.aickb-send {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: none;
	background: var(--aickb-primary);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
}
.aickb-send:disabled { opacity: .5; cursor: default; }

@keyframes aickb-fade {
	from { opacity: 0; transform: translateY(4px); }
	to { opacity: 1; transform: translateY(0); }
}
@keyframes aickb-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

@media (max-width: 480px) {
	.aickb-panel { height: calc(100vh - 100px); }
}
