/*
 * NextSearch frontend. Themed entirely via CSS custom properties so it
 * inherits any theme — override --nxs-* on .nxs or :root.
 */
.nxs,
.nxs-results {
	--nxs-accent: #2271b1;
	--nxs-bg: #ffffff;
	--nxs-fg: #1d2327;
	--nxs-muted: #646970;
	--nxs-border: #e2e4e7;
	--nxs-radius: 8px;
	--nxs-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
	--nxs-mark: #fff3c4;
}

/* ---------------------------------------------------------- search bar */

.nxs {
	position: relative;
	max-width: 100%;
	box-sizing: border-box;
	font-size: 15px;
	color: var(--nxs-fg);
}

.nxs *,
.nxs-results * {
	box-sizing: border-box;
}

.nxs-form {
	display: flex;
	align-items: center;
	background: var(--nxs-bg);
	border: 1px solid var(--nxs-border);
	border-radius: var(--nxs-radius);
	overflow: hidden;
	padding: .25rem;
}

.nxs-input {
	flex: 1;
	min-width: 0;
	border: 0;
	outline: 0;
	padding: .75rem 1.5rem;
	font-size: inherit;
	background: transparent;
	color: inherit;
}

.nxs-submit {
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: transparent;
	color: var(--nxs-muted);
	padding: 0 1rem;
	cursor: pointer;
	align-self: stretch;
}

.nxs-submit:hover,
.nxs-submit:focus-visible {
	color: var(--nxs-accent);
}

.nxs-icon {
	width: 20px;
	height: 20px;
	fill: currentColor;
}

.nxs-close {
	display: none;
}

/* ---------------------------------------------------------- results panel */

.nxs-panel {
	position: absolute;
	z-index: 9999;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	max-height: 70vh;
	overflow-y: auto;
	background: var(--nxs-bg);
	border: 1px solid var(--nxs-border);
	border-radius: var(--nxs-radius);
	box-shadow: var(--nxs-shadow);
	padding: 6px;
}

.nxs-panel[hidden] {
	display: none;
}

/* Loading: keep the results in place, overlay a spinner, dim the old
   list — the panel only changes height, never collapses to a line. */
.nxs-spinner {
	position: absolute;
	top: 50%;
	right: 50%;
	display: none;
	z-index: 1;
}

.nxs-panel.is-loading .nxs-spinner {
	display: flex;
}

.nxs-panel.is-loading .nxs-list {
	opacity: 0.55;
	transition: opacity 0.15s ease;
}

.nxs-spin {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid var(--nxs-border);
	border-top-color: var(--nxs-accent);
	border-radius: 50%;
	animation: nxs-rotate 0.6s linear infinite;
}

@keyframes nxs-rotate {
	to { transform: rotate(360deg); }
}

.nxs-group-label {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--nxs-muted);
	padding: 8px 10px 4px;
}

.nxs-item {
	display: flex;
	gap: 10px;
	align-items: center;
	padding: 8px 10px;
	border-top: 1px solid #f0f0f0;
	border-radius: calc(var(--nxs-radius) - 2px);
	text-decoration: none;
	color: inherit;
}

.nxs-item:hover,
.nxs-item[aria-selected="true"] {
	background: color-mix(in srgb, var(--nxs-accent) 10%, transparent);
}

.nxs-thumb img {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 4px;
	display: block;
}

.nxs-body {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}

.nxs-title {
	font-weight: 600;
	line-height: 1.3;
}

.nxs-excerpt {
	font-size: 12px;
	color: var(--nxs-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.nxs-meta {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-top: 2px;
}

.nxs-price {
	font-weight: 600;
	color: var(--nxs-accent);
}

.nxs-sku {
	font-size: 11px;
	color: var(--nxs-muted);
}

.nxs-stock {
	font-size: 11px;
	padding: 1px 6px;
	border-radius: 10px;
	background: #edf7ed;
	color: #1e7a34;
}

.nxs-stock-outofstock {
	background: #fdecea;
	color: #b32d2e;
}

.nxs mark,
.nxs-results mark {
	background: var(--nxs-mark);
	color: inherit;
	padding: 0 1px;
	border-radius: 2px;
}

.nxs-loading,
.nxs-empty {
	padding: 14px;
	color: var(--nxs-muted);
	text-align: center;
}

.nxs-footer {
	display: block;
	text-align: center;
	padding: 10px;
	font-weight: 600;
	color: var(--nxs-accent);
	text-decoration: none;
	border-top: 1px solid var(--nxs-border);
	margin-top: 4px;
}

.nxs-dym {
	color: var(--nxs-accent);
	text-decoration: none;
}

/* ------------------------------------------------------------- drawer mode */

body.nxs-lock {
	overflow: hidden;
}

.nxs[data-active="drawer"].is-drawer-open {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: var(--nxs-bg);
	padding: 14px;
	display: flex;
	flex-direction: column;
	animation: nxs-slide 0.18s ease;
}

@keyframes nxs-slide {
	from { transform: translateY(-8px); opacity: 0.6; }
	to   { transform: translateY(0); opacity: 1; }
}

.nxs[data-active="drawer"].is-drawer-open .nxs-form {
	order: 1;
	font-size: 18px;
}

.nxs[data-active="drawer"].is-drawer-open .nxs-close {
	display: block;
	order: 0;
	align-self: flex-end;
	border: 0;
	background: transparent;
	font-size: 28px;
	line-height: 1;
	color: var(--nxs-muted);
	cursor: pointer;
	margin-bottom: 8px;
}

.nxs[data-active="drawer"].is-drawer-open .nxs-panel {
	position: relative; /* anchor the spinner */
	order: 2;
	box-shadow: none;
	border: 0;
	max-height: none;
	flex: 1;
	margin-top: 10px;
	padding: 0;
	overflow-y: auto;
}

/* ------------------------------------------------------------ results page */

.nxs-results-title {
	margin: 0 0 16px;
}

.nxs-grid {
	display: grid;
	gap: 16px;
	margin-bottom: 28px;
}

.nxs-grid-grid {
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.nxs-grid-list {
	grid-template-columns: 1fr;
}

.nxs-card {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 12px;
	border: 1px solid var(--nxs-border);
	border-radius: var(--nxs-radius);
	text-decoration: none;
	color: inherit;
	transition: box-shadow 0.15s ease;
}

.nxs-card:hover {
	box-shadow: var(--nxs-shadow);
}

.nxs-grid-list .nxs-card {
	flex-direction: row;
	align-items: center;
}

.nxs-card-thumb img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	border-radius: calc(var(--nxs-radius) - 2px);
	display: block;
}

.nxs-grid-list .nxs-card-thumb img {
	width: 64px;
	height: 64px;
}

.nxs-card-title {
	font-weight: 600;
	line-height: 1.3;
}