/**
 * Live header search dropdown.
 *
 * The panel is absolutely positioned under the search input. The header form
 * itself sets `overflow: hidden` (to clip its pill corners), so we re-enable
 * positioning here and let the panel escape via `position: absolute` on a
 * relatively-positioned form. Up to five rows show; the list scrolls beyond.
 */

/* Make the form a positioning context and stop it clipping the dropdown.
   `overflow: visible` is safe because the pill's rounded corners come from the
   border-radius on the form's own background, not from clipped children. */
.nik-header__search {
	position: relative;
	overflow: visible;
}

/* With the form no longer clipping (overflow:visible), the stretched submit
   button's outer corners would poke past the pill. Round them back to match. */
.nik-header__search-btn {
	border-start-end-radius: 999px;
	border-end-end-radius: 999px;
}

.nik-search__panel {
	position: absolute;
	inset-block-start: calc(100% + 8px);
	inset-inline: 0;
	z-index: 60;
	background: var(--nik-bg);
	border: 1px solid var(--nik-border);
	border-radius: var(--nik-radius);
	box-shadow: 0 16px 44px -12px rgba(11, 28, 69, .28);
	overflow: hidden;
	text-align: start;
}

.nik-search__list {
	list-style: none;
	margin: 0;
	padding: 6px;
	/* Five rows ≈ 5 × 64px + paddings; the rest scrolls inside the panel. */
	max-height: 340px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.nik-search__item {
	border-radius: var(--nik-radius-sm);
}

.nik-search__item.is-active,
.nik-search__item:hover {
	background: var(--nik-bg-soft);
}

.nik-search__link {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 10px;
	color: inherit;
}

.nik-search__link:hover {
	color: inherit;
}

.nik-search__thumb {
	flex-shrink: 0;
	width: 56px;
	height: 56px;
	border-radius: var(--nik-radius-sm);
	background: var(--nik-bg-muted);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.nik-search__thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

.nik-search__info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.nik-search__name {
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.5;
	color: var(--nik-text);
	/* Keep names to two lines so rows stay even. */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.nik-search__price {
	flex-shrink: 0;
	margin-inline-start: auto;
	padding-inline-start: 8px;
	text-align: end;
	font-size: 13px;
	font-weight: 700;
	color: var(--nik-primary);
	white-space: nowrap;
}

/* WooCommerce's price markup ships its own font-size/colour; normalise it so it
   sits cleanly in the row (the WC stylesheet isn't loaded on every page). */
.nik-search__price .woocommerce-Price-amount,
.nik-search__price bdi {
	font-size: inherit;
	color: inherit;
}

.nik-search__price .woocommerce-Price-currencySymbol {
	font-size: .85em;
	font-weight: 600;
	margin-inline-start: 2px;
}

.nik-search__price .nik-search__price-call {
	color: var(--nik-text-soft);
	font-weight: 600;
}

/* WooCommerce wraps the sale layout in <del>/<ins>; tame it to fit one line. */
.nik-search__price del {
	color: var(--nik-text-faint);
	font-weight: 500;
	font-size: 12px;
	margin-inline-end: 6px;
}

.nik-search__price ins {
	text-decoration: none;
	color: var(--nik-primary);
}


/* Out-of-stock rows: dim the row and badge the price column. */
.nik-search__item.is-out .nik-search__thumb,
.nik-search__item.is-out .nik-search__name {
	opacity: .65;
}

.nik-search__price-out {
	color: var(--nik-danger, #c0392b);
	font-weight: 700;
	font-size: 12.5px;
}

/* In-panel «در حال جستجو…» row shown the moment a request fires. */
.nik-search__loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 18px 16px;
	font-size: 13px;
	color: var(--nik-text-soft);
}

.nik-search__spinner {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	border: 2px solid var(--nik-border);
	border-block-start-color: var(--nik-accent);
	animation: nik-search-spin .7s linear infinite;
}

@keyframes nik-search-spin {
	to { transform: rotate(360deg); }
}

.nik-search__empty {
	padding: 18px 16px;
	font-size: 13px;
	color: var(--nik-text-soft);
	text-align: center;
}

.nik-search__all {
	display: block;
	padding: 11px 16px;
	font-size: 13px;
	font-weight: 700;
	text-align: center;
	color: var(--nik-accent-600);
	border-block-start: 1px solid var(--nik-border);
	background: var(--nik-bg-soft);
}

.nik-search__all:hover {
	color: var(--nik-accent);
	background: var(--nik-bg-muted);
}

/* While a request is in flight, swap the static magnifier for a spinner ring so
   it's obvious the box is searching. The SVG icon hides (CSS pseudo-elements
   don't render on SVG, so the spinner lives on the form, drawn over the icon's
   slot at the inline-start padding). */
.nik-header__search.is-loading .nik-header__search-icon {
	visibility: hidden;
}

.nik-header__search.is-loading::before {
	content: '';
	position: absolute;
	inset-block-start: 50%;
	/* The form has padding-inline-start:16px; centre the 17px ring within it. */
	inset-inline-start: 16px;
	width: 17px;
	height: 17px;
	margin-block-start: -9px;
	border-radius: 50%;
	border: 2px solid var(--nik-border);
	border-block-start-color: var(--nik-accent);
	animation: nik-search-spin .7s linear infinite;
	pointer-events: none;
	z-index: 2;
}

@media (prefers-reduced-motion: reduce) {
	.nik-header__search.is-loading::before { animation: none; }
}
