/*
 * The trigger reuses the theme's own .btn.btn-primary class (same button
 * the search form itself uses) so it automatically matches the theme's
 * real primary color/hover state instead of a hardcoded blue that could
 * drift from the active theme skin. .techmarket-ai-trigger-wrap sits
 * flush against the search input group with no gap, like a natural
 * extension of the search bar rather than a separate floating button.
 */
.techmarket-ai-trigger-wrap {
	margin-left: 6px;
	display: inline-flex;
}
.techmarket-ai-trigger {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}
.techmarket-ai-trigger svg { flex-shrink: 0; }
@media (max-width: 991px) {
	.techmarket-ai-trigger-text { display: none; }
}

body.techmarket-ai-open { overflow: hidden; }

.techmarket-ai-panel {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: rgba(15, 23, 42, 0.45);
	display: flex;
	justify-content: flex-end;
}
.techmarket-ai-panel[hidden] { display: none; }

/*
 * Everything below is scoped under #techmarket-ai-page (the popup's inner
 * content area) and given explicit font-weight/font-size on every text
 * element (rather than relying on inheritance) since the theme and
 * WooCommerce's own CSS both set heavier default button/link weights that
 * were bleeding through and made plain body text look unintentionally bold.
 */
#techmarket-ai-page {
	display: flex;
	width: min(760px, 100%);
	height: 100%;
	background: #fff;
	box-shadow: -8px 0 30px rgba(0,0,0,0.15);
	animation: techmarket-ai-slide-in 0.2s ease;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.5;
	color: #1e293b;
}
#techmarket-ai-page * { box-sizing: border-box; }
@keyframes techmarket-ai-slide-in {
	from { transform: translateX(24px); opacity: 0; }
	to { transform: translateX(0); opacity: 1; }
}

.techmarket-ai-sidebar {
	width: 240px;
	flex-shrink: 0;
	background: #f8fafc;
	border-right: 1px solid #e5e7eb;
	padding: 16px 12px;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
}
.techmarket-ai-new-chat {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	background: #2563eb;
	color: #fff !important;
	border: none;
	border-radius: 6px;
	padding: 10px 12px;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	margin-bottom: 18px;
}
.techmarket-ai-new-chat:hover { background: #1d4ed8; }
.techmarket-ai-history-label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #94a3b8;
	margin-bottom: 8px;
	padding: 0 4px;
}
.techmarket-ai-history-list { list-style: none; margin: 0; padding: 0; flex: 1; }
.techmarket-ai-history-item {
	padding: 9px 10px;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 400;
	color: #334155;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-bottom: 2px;
}
.techmarket-ai-history-item:hover { background: #eef2f7; }
.techmarket-ai-history-item.is-active { background: #e0e7ff; color: #1e3a8a; font-weight: 500; }
.techmarket-ai-history-empty { padding: 9px 10px; font-size: 12px; font-weight: 400; color: #94a3b8; }

.techmarket-ai-main {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.techmarket-ai-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 20px;
	border-bottom: 1px solid #e5e7eb;
	font-size: 15px;
	font-weight: 600;
	color: #0f172a;
}
.techmarket-ai-header-title { flex: 1; }
.techmarket-ai-history-toggle,
.techmarket-ai-close {
	background: none;
	border: none;
	line-height: 1;
	cursor: pointer;
	color: #64748b;
	padding: 6px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
}
.techmarket-ai-history-toggle:hover,
.techmarket-ai-close:hover { color: #0f172a; background: #f1f5f9; }
.techmarket-ai-history-toggle.is-active { color: #2563eb; background: #eff6ff; }
.techmarket-ai-close { font-size: 22px; font-weight: 400; }

.techmarket-ai-thread {
	flex: 1;
	overflow-y: auto;
	padding: 24px;
	display: flex;
	flex-direction: column;
	gap: 18px;
}
.techmarket-ai-message { display: flex; flex-direction: column; max-width: 100%; }
.techmarket-ai-message--user { align-items: flex-end; }
.techmarket-ai-message--assistant { align-items: flex-start; }
.techmarket-ai-bubble {
	max-width: 75%;
	padding: 11px 15px;
	border-radius: 12px;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.55;
	white-space: pre-wrap;
}
.techmarket-ai-message--user .techmarket-ai-bubble {
	background: #2563eb;
	color: #fff;
	border-bottom-right-radius: 4px;
}
.techmarket-ai-message--assistant .techmarket-ai-bubble {
	background: #f1f5f9;
	color: #0f172a;
	border-bottom-left-radius: 4px;
}

/* Thinking / loading indicator: three bouncing dots instead of static text */
.techmarket-ai-message.is-thinking .techmarket-ai-bubble {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 14px 16px;
}
.techmarket-ai-thinking-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #94a3b8;
	animation: techmarket-ai-bounce 1.2s infinite ease-in-out both;
}
.techmarket-ai-thinking-dot:nth-child(1) { animation-delay: -0.28s; }
.techmarket-ai-thinking-dot:nth-child(2) { animation-delay: -0.14s; }
@keyframes techmarket-ai-bounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
	40% { transform: scale(1); opacity: 1; }
}

.techmarket-ai-product-slider {
	display: flex;
	gap: 14px;
	overflow-x: auto;
	margin-top: 12px;
	padding-bottom: 8px;
	max-width: 100%;
}
.techmarket-ai-product-card {
	flex: 0 0 180px;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 12px;
	display: flex;
	flex-direction: column;
	background: #fff;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.techmarket-ai-product-card:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1); transform: translateY(-2px); }
.techmarket-ai-product-image {
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1;
	border-radius: 8px;
	overflow: hidden;
	background: #f8fafc;
	margin-bottom: 10px;
}
.techmarket-ai-product-image img { width: 100%; height: 100%; object-fit: cover; }
.techmarket-ai-product-title {
	font-size: 13px;
	font-weight: 600;
	color: #0f172a !important;
	text-decoration: none;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-bottom: 4px;
	line-height: 1.35;
}
.techmarket-ai-product-title:hover { color: #2563eb !important; }
.techmarket-ai-product-summary {
	font-size: 11.5px;
	font-weight: 400;
	color: #64748b;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	line-height: 1.4;
	margin-bottom: 8px;
	min-height: 32px;
}
.techmarket-ai-product-price {
	font-size: 15px;
	font-weight: 700;
	color: #2563eb;
	margin-bottom: 10px;
}
.techmarket-ai-product-cta {
	display: block;
	text-align: center;
	background: #2563eb;
	color: #fff !important;
	text-decoration: none;
	font-size: 12px;
	font-weight: 500;
	padding: 8px 10px;
	border-radius: 6px;
	margin-top: auto;
}
.techmarket-ai-product-cta:hover { background: #1d4ed8; color: #fff !important; }

/*
 * Quick-reply badges: clickable pills offering direct answers to the AI's
 * question. Rendered inside the assistant's own message wrapper, directly
 * under its bubble, so they stay visually attached to the question that
 * prompted them as the thread scrolls - not in a separate fixed strip
 * near the composer, disconnected from the question above.
 */
.techmarket-ai-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
	max-width: 80%;
}
.techmarket-ai-quick-reply {
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	color: #1d4ed8 !important;
	font-size: 13px;
	font-weight: 500;
	padding: 7px 14px;
	border-radius: 20px;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s ease;
}
.techmarket-ai-quick-reply:hover { background: #dbeafe; }
.techmarket-ai-quick-reply:disabled {
	background: #f1f5f9;
	border-color: #e2e8f0;
	color: #94a3b8 !important;
	cursor: default;
}

.techmarket-ai-starter-prompts {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 24px 16px;
}
.techmarket-ai-starter-prompt {
	background: #fff;
	border: 1px solid #d1d5db;
	color: #334155 !important;
	font-size: 13px;
	font-weight: 500;
	padding: 7px 14px;
	border-radius: 20px;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s ease, border-color 0.15s ease;
}
.techmarket-ai-starter-prompt:hover { background: #f8fafc; border-color: #2563eb; color: #2563eb !important; }

.techmarket-ai-composer {
	display: flex;
	gap: 10px;
	padding: 16px 24px;
	border-top: 1px solid #e5e7eb;
}
.techmarket-ai-input {
	flex: 1;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	padding: 12px 15px;
	font-size: 14px;
	font-weight: 400;
	color: #1e293b;
	background: #fff;
	outline: none;
}
.techmarket-ai-input:focus { border-color: #2563eb; }
.techmarket-ai-input::placeholder {
	color: #94a3b8;
	opacity: 1;
	font-weight: 400;
}
.techmarket-ai-send {
	background: #2563eb;
	color: #fff;
	border: none;
	border-radius: 8px;
	width: 46px;
	flex-shrink: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}
.techmarket-ai-send svg { display: block; pointer-events: none; }
.techmarket-ai-send:hover { background: #1d4ed8; }
.techmarket-ai-send:disabled { opacity: 0.6; cursor: default; }

@media (max-width: 767px) {
	#techmarket-ai-page { width: 100%; position: relative; }
	/*
	 * On mobile there's no room for a permanent side-by-side sidebar, so
	 * when toggled open it overlays the chat as a full-width panel
	 * instead (positioned absolutely within #techmarket-ai-page, which
	 * needs position:relative above for this to anchor correctly) rather
	 * than being disabled outright - the toggle button must still work.
	 */
	.techmarket-ai-sidebar:not([hidden]) {
		position: absolute;
		inset: 0;
		z-index: 5;
		width: 100%;
	}
}

/*
 * Icon-only trigger for the handheld/mobile header - styled to match the
 * theme's own handheld-header-cart-link icon button (same size, centered,
 * no background) since it sits in that same icon-link row.
 */
.techmarket-ai-trigger-handheld {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent !important;
	border: none !important;
	box-shadow: none !important;
	padding: 0 !important;
	margin: 0;
	color: inherit;
	cursor: pointer;
	text-align: center;
}
.techmarket-ai-trigger-handheld svg { display: block; }
