.aiwc-widget,
.aiwc-widget *,
.aiwc-widget *::before,
.aiwc-widget *::after {
	box-sizing: border-box;
}

.aiwc-widget {
	position: fixed;
	z-index: 999999;
	bottom: 20px;
	right: 20px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #1d2327;
}

.aiwc-widget.aiwc-position-left {
	right: auto;
	left: 20px;
}

.aiwc-widget .aiwc-button {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	background: var(--aiwc-button-color, #2563eb);
	color: var(--aiwc-text-color, #ffffff);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	padding: 0;
}

.aiwc-widget .aiwc-button:hover {
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
}

.aiwc-widget .aiwc-button-icon {
	display: inline-flex;
}

.aiwc-widget .aiwc-window {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: var(--aiwc-width, 380px);
	height: var(--aiwc-height, 560px);
	max-width: calc(100vw - 40px);
	max-height: calc(100vh - 140px);
	background: #ffffff;
	border-radius: var(--aiwc-radius, 12px);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid rgba(0, 0, 0, 0.08);
	animation: aiwc-pop 0.18s ease-out;
}

.aiwc-position-left .aiwc-window {
	right: auto;
	left: 0;
}

@keyframes aiwc-pop {
	from {
		opacity: 0;
		transform: translateY(8px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.aiwc-widget .aiwc-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 12px 14px;
	color: var(--aiwc-text-color, #ffffff);
	background: var(--aiwc-primary-color, #2563eb);
}

.aiwc-widget .aiwc-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.aiwc-widget .aiwc-avatar {
	width: 38px;
	height: 38px;
	flex: 0 0 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.22);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #fff;
}

.aiwc-widget .aiwc-avatar::after {
	content: "🤖";
	font-size: 20px;
}

.aiwc-widget .aiwc-bot-name {
	display: block;
	font-size: 14px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.aiwc-widget .aiwc-online {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 11px;
	opacity: 0.92;
}

.aiwc-widget .aiwc-online-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #4ade80;
}

.aiwc-widget .aiwc-header-actions {
	display: flex;
	gap: 4px;
	flex: 0 0 auto;
}

.aiwc-widget .aiwc-icon-btn {
	background: transparent;
	border: none;
	color: inherit;
	cursor: pointer;
	width: 30px;
	height: 30px;
	border-radius: 6px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.aiwc-widget .aiwc-icon-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

.aiwc-widget .aiwc-body {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.aiwc-widget .aiwc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f8fafc;
	scroll-behavior: smooth;
}

.aiwc-widget .aiwc-msg {
	display: flex;
	max-width: 86%;
}

.aiwc-widget .aiwc-msg.aiwc-bot {
	align-self: flex-start;
}

.aiwc-widget .aiwc-msg.aiwc-user {
	align-self: flex-end;
}

.aiwc-widget .aiwc-msg-bubble {
	padding: 10px 13px;
	border-radius: 16px;
	word-break: break-word;
	white-space: pre-wrap;
	font-size: 13.5px;
	line-height: 1.55;
}

.aiwc-widget .aiwc-bot .aiwc-msg-bubble {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-bottom-left-radius: 4px;
}

.aiwc-widget .aiwc-user .aiwc-msg-bubble {
	background: var(--aiwc-primary-color, #2563eb);
	color: var(--aiwc-text-color, #ffffff);
	border-bottom-right-radius: 4px;
}

.aiwc-widget .aiwc-msg-meta {
	margin-top: 6px;
	display: flex;
	gap: 8px;
	align-items: center;
}

.aiwc-widget .aiwc-feedback {
	display: inline-flex;
	gap: 4px;
}

.aiwc-widget .aiwc-feedback button {
	background: transparent;
	border: 1px solid #cbd5e1;
	color: #64748b;
	border-radius: 50%;
	width: 24px;
	height: 24px;
	cursor: pointer;
	font-size: 12px;
	line-height: 1;
	padding: 0;
}

.aiwc-widget .aiwc-feedback button:hover,
.aiwc-widget .aiwc-feedback button.aiwc-active {
	background: #e2e8f0;
	color: #1d2327;
}

.aiwc-widget .aiwc-sources {
	margin-top: 8px;
	font-size: 12px;
}

.aiwc-widget .aiwc-sources-title {
	font-weight: 600;
	color: #475569;
	margin-bottom: 3px;
}

.aiwc-widget .aiwc-source-link {
	display: block;
	color: var(--aiwc-primary-color, #2563eb);
	text-decoration: underline;
}

.aiwc-widget .aiwc-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	padding: 10px 13px;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 16px;
	border-bottom-left-radius: 4px;
}

.aiwc-widget .aiwc-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #94a3b8;
	animation: aiwc-blink 1.2s infinite;
}

.aiwc-widget .aiwc-typing span:nth-child(2) {
	animation-delay: 0.2s;
}

.aiwc-widget .aiwc-typing span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes aiwc-blink {
	0%, 80%, 100% {
		opacity: 0.2;
	}
	40% {
		opacity: 1;
	}
}

.aiwc-widget .aiwc-msg.aiwc-error .aiwc-msg-bubble {
	background: #fef2f2;
	border-color: #fecaca;
	color: #b91c1c;
}

.aiwc-widget .aiwc-error-actions {
	margin-top: 6px;
	display: flex;
	gap: 8px;
}

.aiwc-widget .aiwc-error-actions button {
	background: transparent;
	border: 1px solid #cbd5e1;
	border-radius: 14px;
	padding: 4px 12px;
	font-size: 12px;
	cursor: pointer;
	color: #475569;
}

.aiwc-widget .aiwc-footer {
	border-top: 1px solid #e2e8f0;
	background: #ffffff;
	padding: 10px;
}

.aiwc-widget .aiwc-input-row {
	display: flex;
	gap: 8px;
	align-items: flex-end;
}

.aiwc-widget .aiwc-input {
	flex: 1;
	border: 1px solid #cbd5e1;
	border-radius: 20px;
	padding: 9px 14px;
	font-size: 14px;
	font-family: inherit;
	resize: none;
	max-height: 120px;
	line-height: 1.4;
	background: #f8fafc;
	outline: none;
}

.aiwc-widget .aiwc-input:focus {
	border-color: var(--aiwc-primary-color, #2563eb);
	background: #ffffff;
}

.aiwc-widget .aiwc-send {
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: var(--aiwc-primary-color, #2563eb);
	color: var(--aiwc-text-color, #ffffff);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: filter 0.15s ease;
}

.aiwc-widget .aiwc-send:hover {
	filter: brightness(1.08);
}

.aiwc-widget .aiwc-lead-form,
.aiwc-widget .aiwc-handoff-panel {
	padding: 12px 14px;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	font-size: 13px;
}

.aiwc-widget .aiwc-lead-form input,
.aiwc-widget .aiwc-handoff-panel input,
.aiwc-widget .aiwc-handoff-panel textarea {
	display: block;
	width: 100%;
	margin-bottom: 8px;
	padding: 8px 10px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	font-size: 13px;
	font-family: inherit;
}

.aiwc-widget .aiwc-lead-form button,
.aiwc-widget .aiwc-handoff-panel button {
	background: var(--aiwc-primary-color, #2563eb);
	color: var(--aiwc-text-color, #ffffff);
	border: none;
	border-radius: 8px;
	padding: 8px 14px;
	cursor: pointer;
	font-size: 13px;
}

.aiwc-widget .aiwc-handoff-panel a {
	display: inline-block;
	margin: 2px 8px 2px 0;
	color: var(--aiwc-primary-color, #2563eb);
	font-weight: 600;
}

.aiwc-widget .aiwc-clear-note {
	font-size: 11px;
	color: #94a3b8;
	text-align: center;
	margin-top: 6px;
}

.aiwc-widget[hidden],
.aiwc-widget .aiwc-window[hidden] {
	display: none !important;
}

@media (max-width: 480px) {
	.aiwc-widget {
		bottom: 14px;
		right: 14px;
		left: 14px;
	}

	.aiwc-widget.aiwc-position-left {
		right: auto;
		left: 14px;
	}

	.aiwc-widget .aiwc-window {
		width: 100%;
		width: calc(100vw - 28px);
		left: 0;
		right: 0;
		bottom: 66px;
		max-height: calc(100vh - 100px);
	}

	.aiwc-widget.aiwc-position-left .aiwc-window {
		left: 0;
		right: 0;
	}
}