/* AI Chatbot Assistant – Frontend widget */

.ai-chatbot-widget {
	--ai-chatbot-primary: #2563eb;
	--ai-chatbot-bg: #ffffff;
	--ai-chatbot-text: #1f2937;
	--ai-chatbot-user-bubble: #2563eb;
	--ai-chatbot-bot-bubble: #e5e7eb;
	--ai-chatbot-width: 400px;
	--ai-chatbot-height: 500px;
	--ai-chatbot-bottom: 20px;
	--ai-chatbot-side: 20px;
	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	box-sizing: border-box;
}

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

/* Position variants */
.ai-chatbot-pos-bottom-right {
	bottom: var(--ai-chatbot-bottom);
	right: var(--ai-chatbot-side);
}
.ai-chatbot-pos-bottom-left {
	bottom: var(--ai-chatbot-bottom);
	left: var(--ai-chatbot-side);
}
.ai-chatbot-pos-center-right {
	top: 50%;
	transform: translateY(-50%);
	right: var(--ai-chatbot-side);
}
.ai-chatbot-pos-center-left {
	top: 50%;
	transform: translateY(-50%);
	left: var(--ai-chatbot-side);
}

.ai-chatbot-toggle {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--ai-chatbot-primary);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ai-chatbot-toggle:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.ai-chatbot-toggle .ai-chatbot-cta-text {
	font-size: 14px;
	font-weight: 600;
	padding: 0 6px;
}
.ai-chatbot-toggle .ai-chatbot-icon {
	flex-shrink: 0;
}

.ai-chatbot-popup {
	position: absolute;
	bottom: calc(56px + 12px);
	width: var(--ai-chatbot-width);
	height: var(--ai-chatbot-height);
	max-height: calc(100vh - 120px);
	background: var(--ai-chatbot-bg);
	color: var(--ai-chatbot-text);
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(10px) scale(0.96);
	transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}
.ai-chatbot-widget.ai-chatbot-open .ai-chatbot-popup {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}
.ai-chatbot-popup[hidden] {
	display: flex !important;
}

.ai-chatbot-pos-center-right .ai-chatbot-popup,
.ai-chatbot-pos-center-left .ai-chatbot-popup {
	bottom: auto;
	top: calc(56px + 12px);
}

.ai-chatbot-pos-bottom-left .ai-chatbot-popup,
.ai-chatbot-pos-center-left .ai-chatbot-popup {
	right: auto;
	left: 0;
}

.ai-chatbot-header {
	background: var(--ai-chatbot-primary);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}
.ai-chatbot-title {
	font-weight: 600;
	font-size: 16px;
}
.ai-chatbot-header-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}
.ai-chatbot-clear {
	background: rgba(255, 255, 255, 0.2);
	border: none;
	color: inherit;
	font-size: 12px;
	padding: 4px 8px;
	border-radius: 4px;
	cursor: pointer;
	opacity: 0.95;
}
.ai-chatbot-clear:hover {
	background: rgba(255, 255, 255, 0.3);
}
.ai-chatbot-close {
	background: transparent;
	border: none;
	color: inherit;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
	opacity: 0.9;
}
.ai-chatbot-close:hover {
	opacity: 1;
}

.ai-chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-height: 0;
}
.ai-chatbot-msg {
	max-width: 85%;
	width: fit-content;
	padding: 10px 14px;
	border-radius: 14px;
	word-wrap: break-word;
}
.ai-chatbot-msg-user {
	align-self: flex-end;
	background: var(--ai-chatbot-user-bubble);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.ai-chatbot-msg-bot {
	align-self: flex-start;
	background: var(--ai-chatbot-bot-bubble);
	color: var(--ai-chatbot-text);
	border-bottom-left-radius: 4px;
}
.ai-chatbot-msg-text {
	white-space: pre-wrap;
}
.ai-chatbot-welcome {
	background: var(--ai-chatbot-bot-bubble);
}

.ai-chatbot-typing {
	padding: 8px 16px;
	min-height: 0;
	opacity: 0;
	transition: opacity 0.2s ease;
}
.ai-chatbot-typing-visible {
	opacity: 1;
}
.ai-chatbot-typing::after {
	content: '';
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--ai-chatbot-primary);
	animation: ai-chatbot-blink 1s ease-in-out infinite;
}
@keyframes ai-chatbot-blink {
	0%, 100% { opacity: 0.3; }
	50% { opacity: 1; }
}

.ai-chatbot-input-wrap {
	display: flex;
	gap: 8px;
	padding: 12px 16px;
	background: var(--ai-chatbot-bg);
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	flex-shrink: 0;
	align-items: flex-end;
}
.ai-chatbot-input {
	flex: 1;
	min-height: 44px;
	max-height: 120px;
	padding: 10px 14px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 22px;
	resize: none;
	font: inherit;
	color: var(--ai-chatbot-text);
	background: #f9fafb;
	transition: border-color 0.2s ease;
}
.ai-chatbot-input:focus {
	outline: none;
	border-color: var(--ai-chatbot-primary);
	background: #fff;
}
.ai-chatbot-send {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--ai-chatbot-primary);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: opacity 0.2s ease;
}
.ai-chatbot-send:hover:not(:disabled) {
	opacity: 0.9;
}
.ai-chatbot-send:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

@media (max-width: 480px) {
	.ai-chatbot-hide-mobile {
		display: none !important;
	}
	.ai-chatbot-popup {
		width: calc(100vw - 24px);
		left: 12px;
		right: 12px;
		max-width: var(--ai-chatbot-width);
	}
	.ai-chatbot-pos-bottom-right .ai-chatbot-popup,
	.ai-chatbot-pos-center-right .ai-chatbot-popup {
		left: 12px;
		right: 12px;
	}
}
