/* AI chat for refining the product listing search.
 * Floating in-page widget (no iframe): a fixed-position toggle bubble in the corner
 * opens a fixed-position chat panel.
 */

:root {
	--chat-accent: #ecac4a;
	--chat-accent-hover: #d99a38;
}

/* Floating toggle bubble */
.product-chat-toggle {
	position: fixed;
	bottom: 20px;
	left: 20px;
	width: 50px;
	height: 50px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	border: none;
	background-color: var(--chat-accent, #ecac4a);
	color: #ffffff;
	font-size: 22px;
	line-height: 1;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	z-index: 1040;
	transition: background-color 0.2s ease-in-out, transform 0.15s ease-in-out;
}

.product-chat-toggle i {
	display: block;
	line-height: 1;
}

.product-chat-toggle:hover {
	background-color: var(--chat-accent-hover, #d99a38);
	transform: scale(1.05);
}

/* Speech-bubble label above the toggle; hidden while the chat panel is open */
.product-chat-toggle-bubble {
	position: fixed;
	bottom: 90px;
	left: 20px;
	max-width: 220px;
	padding: 8px 14px;
	background-color: #ffffff;
	color: #333333;
	font-size: 13px;
	line-height: 1.3;
	border: 1px solid var(--chat-accent, #ecac4a);
	border-radius: 14px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	z-index: 1040;
	white-space: nowrap;
	animation: product-chat-bubble-float 2.6s ease-in-out infinite;
}

@keyframes product-chat-bubble-float {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-5px); }
}

@media (prefers-reduced-motion: reduce) {
	.product-chat-toggle-bubble {
		animation: none;
	}
}

/* Bubble tail pointing down to the toggle button */
.product-chat-toggle-bubble::after {
	content: '';
	position: absolute;
	bottom: -7px;
	left: 21px;
	border-style: solid;
	border-width: 7px 7px 0 7px;
	border-color: #ffffff transparent transparent transparent;
	filter: drop-shadow(0 1px 0 var(--chat-accent, #ecac4a));
}

.product-chat-toggle-bubble.hidden {
	display: none;
}

/* Floating chat panel */
.product-chat {
	position: fixed;
	bottom: 90px;
	left: 20px;
	width: 360px;
	max-width: calc(100vw - 40px);
	max-height: calc(100vh - 120px);
	background: #ffffff;
	border: 1px solid #e1e1e1;
	border-radius: 4px;
	overflow: hidden;
	font-size: 13px;
	display: none;
	flex-direction: column;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
	z-index: 1041;
}

.product-chat.visible {
	display: flex;
	transform-origin: bottom left;
	animation: product-chat-slide-in 0.25s ease-out;
}

/* Slide in from the left edge */
@keyframes product-chat-slide-in {
	from {
		transform: translateX(-30px);
		opacity: 0;
	}
	to {
		transform: translateX(0);
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.product-chat.visible {
		animation: none;
	}
}

.product-chat-header {
	background-color: var(--chat-accent, #ecac4a);
	color: #ffffff;
	padding: 14px 15px;
	min-height: 48px;
	line-height: 1;
	font-size: 15px;
	font-weight: normal;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.product-chat-header .product-chat-title {
	display: flex;
	align-items: center;
	gap: 8px;
}

.product-chat-header .product-chat-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.product-chat-header .product-chat-reset,
.product-chat-header .product-chat-close {
	background: none;
	border: none;
	color: #ffffff;
	cursor: pointer;
	opacity: 0.85;
	padding: 0;
	width: 28px;
	height: 28px;
	font-size: 16px;
	line-height: 1;
	border-radius: 4px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.15s ease-in-out, opacity 0.15s ease-in-out;
}

.product-chat-header .product-chat-reset i,
.product-chat-header .product-chat-close i {
	display: block;
	line-height: 1;
}

.product-chat-header .product-chat-reset:hover,
.product-chat-header .product-chat-close:hover {
	opacity: 1;
	background-color: rgba(255, 255, 255, 0.18);
}

.product-chat-body {
	flex-grow: 1;
	min-height: 0;
	max-height: 60vh;
	overflow-y: auto;
	padding: 12px;
	background-color: #f7f7f8;
}

.product-chat-body:empty {
	min-height: 0;
	height: 0;
	padding: 0;
	background-color: transparent;
}

.product-chat-message {
	margin-bottom: 8px;
	padding: 7px 10px;
	border-radius: 6px;
	max-width: 95%;
	word-wrap: break-word;
	line-height: 1.4;
}

.product-chat-message.user {
	background-color: #ececec;
	color: #222;
	text-align: right;
	margin-left: auto;
}

.product-chat-message.bot {
	background-color: transparent;
	color: #222;
	margin-right: auto;
}

.product-chat-message.bot p {
	margin: 0 0 6px 0;
}

.product-chat-message.bot p:last-child {
	margin-bottom: 0;
}

.product-chat-loader {
	display: flex;
	gap: 4px;
	padding: 4px 0;
}

.product-chat-loader .dot {
	width: 6px;
	height: 6px;
	background-color: var(--chat-accent, #ecac4a);
	border-radius: 50%;
	animation: product-chat-typing 1.2s infinite ease-in-out;
}

.product-chat-loader .dot:nth-child(2) {
	animation-delay: 0.15s;
}

.product-chat-loader .dot:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes product-chat-typing {
	0%, 80%, 100% {
		transform: translateY(0);
		opacity: 0.5;
	}
	40% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

.product-chat-input-row {
	display: flex;
	flex-wrap: nowrap;
	align-items: stretch;
	padding: 8px;
	border-top: 1px solid #e1e1e1;
	background-color: #fff;
	gap: 6px;
	min-width: 0;
}

/* Selector kept intentionally specific: the theme's `input[type="text"]` rule
 * (brown background, white text, 52px height, float) outranks a lone class. */
.product-chat input.product-chat-input {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	height: auto;
	float: none;
	border: 1px solid #ccc;
	border-radius: 4px;
	padding: 7px 10px;
	font-size: 13px;
	line-height: 1.4;
	color: #222222;
	background-color: #ffffff;
	outline: none;
}

.product-chat input.product-chat-input::placeholder {
	color: #999999;
}

.product-chat input.product-chat-input:focus {
	border-color: var(--chat-accent, #ecac4a);
}

.product-chat-send,
.product-chat-mic {
	flex: 0 0 auto;
	background-color: var(--chat-accent, #ecac4a);
	color: #ffffff;
	border: none;
	padding: 7px 10px;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
	line-height: 1;
}

.product-chat-send:hover,
.product-chat-mic:hover {
	background-color: var(--chat-accent-hover, #d99a38);
}

.product-chat-send[disabled],
.product-chat-mic[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
}

.product-chat-mic.recording {
	background-color: #b00020;
}

.product-chat-mic.recording:hover {
	background-color: #8a0019;
}

.product-chat-mic.unsupported {
	display: none;
}

.product-chat-error {
	color: #b00020;
	font-size: 12px;
	margin-top: 4px;
}

@media (max-width: 480px) {
	.product-chat {
		right: 10px;
		left: 10px;
		width: auto;
		bottom: 80px;
	}

	.product-chat-toggle {
		left: 14px;
		bottom: 20px;
	}

	.product-chat-toggle-bubble {
		left: 14px;
		bottom: 76px;
	}
}
