/**
 * AI Assistant Chatbot — Ghootmee AI public-facing widget styles.
 *
 * Every selector is namespaced under .gai-chatbot- to minimize the
 * risk of colliding with theme or other-plugin styles, per the
 * plugin's CSS isolation requirements. Colors/sizes are driven by CSS
 * custom properties set inline by chatbot.js from admin-configured,
 * already-validated Appearance settings — nothing here hard-codes a
 * color/size that Appearance is supposed to control.
 *
 * A defensive `all: initial` boundary is intentionally NOT used here
 * (it was in the v0.1.0 placeholder) because it also resets properties
 * the widget itself needs to inherit or set (box-sizing, font
 * smoothing) and fights with the explicit resets below; explicit
 * property resets on each namespaced class are more predictable.
 */

.gai-chatbot-root,
.gai-chatbot-root * {
	box-sizing: border-box;
}

.gai-chatbot-root {
	--gai-primary-color: #4f46e5;
	--gai-button-bg: #4f46e5;
	--gai-button-icon-color: #ffffff;
	--gai-button-size: 60px;
	--gai-window-width: 380px;
	--gai-window-height: 600px;

	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	color: #1f2328;
}

/* Position variants, applied as a class on .gai-chatbot-root */
.gai-chatbot-pos-bottom-right { bottom: 20px; right: 20px; }
.gai-chatbot-pos-bottom-left  { bottom: 20px; left: 20px; }
.gai-chatbot-pos-middle-right { top: 50%; right: 20px; transform: translateY(-50%); }
.gai-chatbot-pos-middle-left  { top: 50%; left: 20px; transform: translateY(-50%); }

/* ---------------------------------------------------------------- */
/* Button                                                            */
/* ---------------------------------------------------------------- */

.gai-chatbot-button {
	width: var(--gai-button-size);
	height: var(--gai-button-size);
	border-radius: 50%;
	background: var(--gai-button-bg);
	color: var(--gai-button-icon-color);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
	transition: transform 0.15s ease;
	padding: 0;
}

.gai-chatbot-button:hover {
	transform: scale(1.05);
}

.gai-chatbot-button:focus-visible {
	outline: 3px solid var(--gai-primary-color);
	outline-offset: 2px;
}

.gai-chatbot-button svg,
.gai-chatbot-button img {
	width: 55%;
	height: 55%;
	object-fit: contain;
}

/* ---------------------------------------------------------------- */
/* Window                                                             */
/* ---------------------------------------------------------------- */

.gai-chatbot-window {
	position: absolute;
	bottom: calc(var(--gai-button-size) + 16px);
	width: var(--gai-window-width);
	height: var(--gai-window-height);
	max-width: calc(100vw - 32px);
	max-height: calc(100vh - 120px);
	background: #ffffff;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.gai-chatbot-pos-bottom-right .gai-chatbot-window,
.gai-chatbot-pos-middle-right .gai-chatbot-window { right: 0; }
.gai-chatbot-pos-bottom-left .gai-chatbot-window,
.gai-chatbot-pos-middle-left .gai-chatbot-window { left: 0; }

.gai-chatbot-window.gai-chatbot-open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.gai-chatbot-header {
	background: var(--gai-primary-color);
	color: #ffffff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.gai-chatbot-header-titles {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.gai-chatbot-header-title {
	font-weight: 600;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.gai-chatbot-header-subtitle {
	font-size: 12px;
	opacity: 0.85;
}

.gai-chatbot-close {
	background: transparent;
	border: none;
	color: #ffffff;
	cursor: pointer;
	width: 28px;
	height: 28px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.gai-chatbot-close:hover {
	background: rgba(255, 255, 255, 0.15);
}

.gai-chatbot-close:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 1px;
}

.gai-chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f7f7f8;
}

.gai-chatbot-message {
	max-width: 82%;
	padding: 9px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-break: break-word;
}

.gai-chatbot-message-user {
	align-self: flex-end;
	background: var(--gai-primary-color);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}

.gai-chatbot-message-assistant {
	align-self: flex-start;
	background: #ffffff;
	color: #1f2328;
	border: 1px solid #e5e5e8;
	border-bottom-left-radius: 4px;
}

.gai-chatbot-message-error {
	align-self: center;
	background: #fdecec;
	color: #7a1f1f;
	border: 1px solid #f3c6c6;
	font-size: 13px;
}

.gai-chatbot-typing {
	align-self: flex-start;
	font-size: 12px;
	color: #6b7280;
	padding: 4px 13px;
}

.gai-chatbot-input-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #e5e5e8;
	background: #ffffff;
	flex-shrink: 0;
}

.gai-chatbot-input {
	flex: 1;
	resize: none;
	border: 1px solid #d7d7db;
	border-radius: 10px;
	padding: 9px 12px;
	font-family: inherit;
	font-size: 14px;
	max-height: 100px;
	min-height: 38px;
}

.gai-chatbot-input:focus-visible {
	outline: 2px solid var(--gai-primary-color);
	outline-offset: 1px;
}

.gai-chatbot-send {
	background: var(--gai-primary-color);
	color: #ffffff;
	border: none;
	border-radius: 10px;
	width: 38px;
	height: 38px;
	flex-shrink: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.gai-chatbot-send:disabled {
	opacity: 0.5;
	cursor: default;
}

.gai-chatbot-send:focus-visible {
	outline: 2px solid var(--gai-primary-color);
	outline-offset: 2px;
}

/* ---------------------------------------------------------------- */
/* Mobile                                                             */
/* ---------------------------------------------------------------- */

@media (max-width: 480px) {
	.gai-chatbot-window {
		position: fixed;
		top: env(safe-area-inset-top, 0);
		left: 0;
		right: 0;
		bottom: 0;
		width: 100vw;
		height: 100vh;
		max-width: 100vw;
		max-height: 100vh;
		border-radius: 0;
	}

	.gai-chatbot-pos-bottom-right .gai-chatbot-window,
	.gai-chatbot-pos-bottom-left .gai-chatbot-window,
	.gai-chatbot-pos-middle-right .gai-chatbot-window,
	.gai-chatbot-pos-middle-left .gai-chatbot-window {
		right: 0;
		left: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gai-chatbot-window,
	.gai-chatbot-button {
		transition: none;
	}
}
