/* ==========================================================
   Live Product Search – Doofinder style
   Change the colours here:
   ========================================================== */
.lps-wrap,
.lps-layer {
	--lps-accent: #2d8cf0;        /* blue: border, button, prices */
	--lps-accent-dark: #1a73d1;
	--lps-text: #1f2937;
	--lps-muted: #6b7280;
	--lps-border: #e5e7eb;
	--lps-bg: #f5f7fa;            /* background behind product cards */
	--lps-radius: 8px;
	font-family: inherit;
}

/* ---------------- Search bar ---------------- */
.lps-wrap { position: relative; width: 100%; max-width: 640px; }

.lps-form {
	position: relative;
	display: flex;
	align-items: stretch;
	height: 48px;
	margin: 0;
	border: 2px solid var(--lps-accent);
	border-radius: 999px;
	background: #fff;
	overflow: hidden;
	transition: box-shadow .2s;
}
.lps-wrap.is-open .lps-form,
.lps-form:focus-within { box-shadow: 0 0 0 4px rgba(45, 140, 240, .15); }

.lps-input {
	flex: 1;
	min-width: 0;
	height: 100% !important;
	margin: 0 !important;
	padding: 0 44px 0 22px !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	outline: none !important;
	font-size: 16px;
	color: var(--lps-text);
}
.lps-input::-webkit-search-cancel-button { display: none; }

.lps-button {
	flex: 0 0 64px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: var(--lps-accent) !important;
	color: #fff !important;
	cursor: pointer;
	transition: background .2s;
}
.lps-button:hover { background: var(--lps-accent-dark) !important; }

.lps-spinner {
	position: absolute;
	right: 80px;
	top: 50%;
	width: 18px;
	height: 18px;
	margin-top: -9px;
	border: 2px solid #d6e6f8;
	border-top-color: var(--lps-accent);
	border-radius: 50%;
	opacity: 0;
	animation: lps-spin .7s linear infinite;
	pointer-events: none;
	transition: opacity .15s;
}
.lps-wrap.is-loading .lps-spinner { opacity: 1; }
@keyframes lps-spin { to { transform: rotate(360deg); } }

/* ---------------- Results layer ---------------- */
.lps-layer {
	position: fixed;
	top: var(--lps-top, 80px);
	left: 50%;
	transform: translateX(-50%);
	z-index: 999999;
	display: flex;
	width: min(1240px, calc(100vw - 24px));
	height: min(780px, calc(100vh - var(--lps-top, 80px) - 16px));
	background: #fff;
	border: 1px solid var(--lps-border);
	border-radius: var(--lps-radius);
	box-shadow: 0 24px 60px rgba(15, 23, 42, .22);
	overflow: hidden;
	color: var(--lps-text);
	font-size: 14px;
	line-height: 1.4;
	animation: lps-in .18s ease-out;
}
.lps-layer[hidden] { display: none !important; }
@keyframes lps-in { from { opacity: 0; margin-top: -6px; } to { opacity: 1; margin-top: 0; } }

.lps-layer button { font-family: inherit; }

/* ---------------- Sidebar / filters ---------------- */
.lps-sidebar {
	flex: 0 0 240px;
	overflow-y: auto;
	padding: 16px 20px 24px;
	border-right: 1px solid var(--lps-border);
	background: #fff;
}

.lps-sidebar-top { margin-bottom: 6px; }
.lps-clear {
	padding: 0 !important;
	border: 0 !important;
	background: none !important;
	color: var(--lps-accent) !important;
	font-size: 13px;
	cursor: pointer;
}
.lps-clear:disabled { color: #c3c8d0 !important; cursor: default; }

.lps-facet { border-bottom: 1px solid #f0f1f3; padding: 14px 0; }
.lps-facet[hidden] { display: none; }

.lps-facet-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 0 !important;
	border: 0 !important;
	background: none !important;
	color: var(--lps-text) !important;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
}

.lps-chev {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translateY(-3px);
	transition: transform .2s;
}
.lps-facet.is-collapsed .lps-facet-head .lps-chev { transform: rotate(-135deg) translateY(-2px); }
.lps-facet.is-collapsed .lps-facet-body { display: none; }

.lps-facet-body { padding-top: 12px; }

.lps-terms { list-style: none; margin: 0; padding: 0; }
.lps-terms li { margin: 0 0 9px; }
.lps-terms li.lps-extra { display: none; }
.lps-facet.is-expanded .lps-terms li.lps-extra { display: block; }

.lps-terms label {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	cursor: pointer;
	font-size: 13px;
	font-weight: 400;
	color: #4b5563;
}
.lps-terms input { position: absolute; opacity: 0; pointer-events: none; }
.lps-check {
	flex: 0 0 16px;
	height: 16px;
	border: 1.5px solid #c7ccd4;
	border-radius: 4px;
	background: #fff;
	transition: all .15s;
	position: relative;
}
.lps-terms input:checked + .lps-check { background: var(--lps-accent); border-color: var(--lps-accent); }
.lps-terms input:checked + .lps-check::after {
	content: '';
	position: absolute;
	left: 4px; top: 1px;
	width: 5px; height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}
.lps-terms input:focus-visible + .lps-check { box-shadow: 0 0 0 3px rgba(45, 140, 240, .25); }
.lps-term-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lps-term-count { color: var(--lps-accent); font-size: 12px; font-weight: 600; }
.lps-terms label:hover .lps-term-name { color: var(--lps-text); }

.lps-more {
	display: flex !important;
	align-items: center;
	gap: 6px;
	margin: 6px auto 0 !important;
	padding: 0 !important;
	border: 0 !important;
	background: none !important;
	color: var(--lps-muted) !important;
	font-size: 12px;
	cursor: pointer;
}
.lps-more[hidden] { display: none !important; }
.lps-more .lps-chev { width: 6px; height: 6px; border-width: 0 1.5px 1.5px 0; }
.lps-facet.is-expanded .lps-more .lps-chev { transform: rotate(-135deg) translateY(-1px); }

/* Price slider */
.lps-range { position: relative; height: 22px; margin: 4px 4px 0; }
.lps-range-track {
	position: absolute;
	left: 0; right: 0; top: 50%;
	height: 4px;
	margin-top: -2px;
	border-radius: 4px;
	background: #e3e6ea;
}
.lps-range-fill { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--lps-accent); }
.lps-range input[type=range] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 22px;
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
}
.lps-range input[type=range]::-webkit-slider-runnable-track { background: none; border: 0; }
.lps-range input[type=range]::-moz-range-track { background: none; border: 0; }
.lps-range input[type=range]::-webkit-slider-thumb {
	-webkit-appearance: none;
	pointer-events: auto;
	width: 18px; height: 18px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--lps-accent);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
	cursor: grab;
}
.lps-range input[type=range]::-moz-range-thumb {
	pointer-events: auto;
	width: 14px; height: 14px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--lps-accent);
	cursor: grab;
}
.lps-range-values { display: flex; justify-content: space-between; margin-top: 10px; }
.lps-range-values span {
	padding: 3px 8px;
	border-radius: 4px;
	background: var(--lps-accent);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
}

.lps-done { display: none; }

/* ---------------- Main / results ---------------- */
.lps-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--lps-bg); }

.lps-topbar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 20px;
	background: #fff;
	border-bottom: 1px solid var(--lps-border);
}
.lps-count { font-size: 13px; color: #4b5563; }
.lps-count strong { color: var(--lps-text); }
.lps-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.lps-sort-wrap { position: relative; }
.lps-sort-wrap::after {
	content: '';
	position: absolute;
	right: 14px; top: 50%;
	width: 6px; height: 6px;
	margin-top: -5px;
	border-right: 1.5px solid var(--lps-text);
	border-bottom: 1.5px solid var(--lps-text);
	transform: rotate(45deg);
	pointer-events: none;
}
.lps-sort {
	height: 32px !important;
	margin: 0 !important;
	padding: 0 34px 0 16px !important;
	border: 1px solid var(--lps-border) !important;
	border-radius: 999px !important;
	background: #fff !important;
	font-size: 12px;
	color: var(--lps-text);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	box-shadow: none !important;
}

.lps-close {
	width: 32px; height: 32px;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: #f1f3f6 !important;
	color: var(--lps-text) !important;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
.lps-close:hover { background: #e5e8ec !important; }

.lps-filters-toggle {
	display: none;
	align-items: center;
	gap: 6px;
	height: 32px;
	padding: 0 14px !important;
	border: 1px solid var(--lps-border) !important;
	border-radius: 999px !important;
	background: #fff !important;
	color: var(--lps-text) !important;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
}

.lps-scroll { flex: 1; overflow-y: auto; padding: 16px; }

.lps-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
	gap: 10px;
	transition: opacity .15s;
}
.lps-layer.is-loading .lps-grid { opacity: .45; }

/* Product card */
.lps-card {
	position: relative;
	display: flex;
	flex-direction: column;
	padding: 14px;
	background: #fff;
	border-radius: 6px;
	text-decoration: none !important;
	color: var(--lps-text) !important;
	transition: box-shadow .2s, transform .2s;
}
.lps-card:hover { box-shadow: 0 6px 20px rgba(15, 23, 42, .1); transform: translateY(-2px); }

.lps-card-img {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1;
	margin-bottom: 12px;
}
.lps-card-img img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	margin: 0;
}
.lps-badge {
	position: absolute;
	top: 0; left: 0;
	padding: 2px 8px;
	border-radius: 4px;
	background: #ef4444;
	color: #fff;
	font-size: 11px;
	font-style: normal;
	font-weight: 700;
}

.lps-card-title {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: 3.9em;
	margin-bottom: 10px;
	font-size: 12px;
	font-weight: 700;
	line-height: 1.3;
}

.lps-card-price { margin-top: auto; font-size: 13px; color: var(--lps-muted); }
.lps-card-price .amount,
.lps-card-price ins { color: var(--lps-accent); font-weight: 700; text-decoration: none; background: none; }
.lps-card-price del,
.lps-card-price del .amount { color: #9ca3af; font-weight: 400; margin-right: 4px; }
.lps-card-price small,
.lps-card-price .woocommerce-price-suffix { font-size: 11px; color: var(--lps-muted); }

.lps-card-stock { margin-top: 4px; font-size: 11px; color: #ef4444; font-weight: 600; }
.lps-card.is-oos .lps-card-img img { opacity: .5; }

.lps-empty {
	grid-column: 1 / -1;
	padding: 60px 20px;
	text-align: center;
	font-size: 15px;
	color: var(--lps-muted);
}
.lps-empty strong { color: var(--lps-text); }

.lps-loader { display: none; justify-content: center; padding: 20px 0 6px; }
.lps-loader span {
	width: 24px; height: 24px;
	border: 3px solid #d6e6f8;
	border-top-color: var(--lps-accent);
	border-radius: 50%;
	animation: lps-spin .7s linear infinite;
}
.lps-layer.is-appending .lps-loader { display: flex; }

/* ---------------- Mobile ---------------- */
@media (max-width: 768px) {
	.lps-layer {
		width: 100vw;
		height: calc(100vh - var(--lps-top, 80px));
		border-radius: 0;
		border-left: 0;
		border-right: 0;
	}
	.lps-sidebar {
		position: absolute;
		inset: 0;
		z-index: 2;
		transform: translateX(-100%);
		transition: transform .25s ease;
		border-right: 0;
		padding-bottom: 80px;
	}
	.lps-layer.show-filters .lps-sidebar { transform: translateX(0); }
	.lps-done {
		display: block;
		position: sticky;
		bottom: 0;
		width: 100%;
		margin-top: 20px;
		padding: 12px !important;
		border: 0 !important;
		border-radius: var(--lps-radius) !important;
		background: var(--lps-accent) !important;
		color: #fff !important;
		font-size: 14px;
		font-weight: 700;
		cursor: pointer;
	}
	.lps-filters-toggle { display: inline-flex; }
	.lps-topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
	.lps-count { order: 3; width: 100%; }
	.lps-scroll { padding: 10px; }
	.lps-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
	.lps-card { padding: 10px; }
}
