/**
 * پنلِ فیلترهای فروشگاه.
 *
 * روی دسکتاپ یک ستونِ ثابت کنارِ شبکه است؛ روی موبایل همان الگوی کشوی
 * سبد و منوی حساب — از راست می‌آید، پرده پشتش، اسکرولِ صفحه قفل.
 */

.nb-sf {
	position: relative;
	padding: 4px 0 0;
}

.nb-sf__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
}

.nb-sf__title {
	margin: 0;
	font-size: 15px;
	font-weight: 800;
	color: var( --nb-text, #ededed );
}

/* دکمه‌ی بستن فقط داخل کشوی موبایل معنی دارد. */
.nb-sf__close,
.nb-sf__open,
.nb-sf__veil {
	display: none;
}

/* ------------------------------------------------ جعبه‌ی هر فیلتر */

.nb-sf__box {
	margin-bottom: 12px;
	padding: 14px 16px;
	border: 1px solid var( --nb-border, #242c42 );
	border-radius: var( --nb-radius, 14px );
	background: var( --nb-surface-alt, #1a2033 );
}

.nb-sf__label {
	margin: 0 0 10px;
	font-size: 13px;
	font-weight: 700;
	color: var( --nb-text, #ededed );
}

/* ---------------------------------------------- فیلترهای فعال */

.nb-sf__chips {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-bottom: 12px;
}

.nb-sf__chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;

	padding: 5px 10px;
	border-radius: 999px;
	background: var( --nb-accent-20, rgba( 114, 14, 236, 0.18 ) );
	color: var( --nb-link, #a78bfa );

	font-size: 11.5px;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}

.nb-sf__chip:hover {
	background: var( --nb-accent, #720eec );
	color: var( --nb-acc-fg, #fff );
}

/* ضربدرِ کوچک — با دو خط، بدون تصویر. */
.nb-sf__chip-x {
	position: relative;
	width: 9px;
	height: 9px;
	flex: 0 0 auto;
}

.nb-sf__chip-x::before,
.nb-sf__chip-x::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 0;
	width: 100%;
	height: 1.4px;
	background: currentColor;
}

.nb-sf__chip-x::before {
	transform: translateY( -50% ) rotate( 45deg );
}

.nb-sf__chip-x::after {
	transform: translateY( -50% ) rotate( -45deg );
}

.nb-sf__clear {
	font-size: 11.5px;
	font-weight: 600;
	color: var( --nb-text-muted, #98a2b3 );
	text-decoration: none;
}

.nb-sf__clear:hover {
	color: var( --nb-danger, #e5484d );
}

/* -------------------------------------------------- فهرست‌ها */

.nb-sf__list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 2px;

	/*
	 * دسته‌ها می‌توانند زیاد باشند. سقفِ ارتفاع با اسکرولِ داخلی، ستون
	 * را کوتاه نگه می‌دارد تا قیمت و وضعیت زیرِ خطِ دید نیفتند.
	 */
	max-height: 260px;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
}

.nb-sf__item,
.nb-sf__toggle {
	display: flex;
	align-items: center;
	gap: 8px;

	padding: 8px 10px;
	border-radius: var( --nb-radius-sm, 8px );

	color: var( --nb-text-muted, #98a2b3 );
	font-size: 12.5px;
	font-weight: 600;
	text-decoration: none;

	transition: background 0.15s ease, color 0.15s ease;
}

.nb-sf__item:hover,
.nb-sf__toggle:hover {
	background: var( --nb-surface, #131829 );
	color: var( --nb-text, #ededed );
}

.nb-sf__item.is-on,
.nb-sf__toggle.is-on {
	background: var( --nb-accent-20, rgba( 114, 14, 236, 0.18 ) );
	color: var( --nb-link, #a78bfa );
}

.nb-sf__count {
	margin-inline-start: auto;
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	opacity: 0.75;
}

/* مربعِ تیک برای کلیدهای وضعیت. */
.nb-sf__tick {
	position: relative;
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	border: 1.5px solid var( --nb-border, #242c42 );
	border-radius: 5px;
}

.nb-sf__toggle.is-on .nb-sf__tick {
	border-color: currentColor;
	background: currentColor;
}

.nb-sf__toggle.is-on .nb-sf__tick::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 4.5px;
	width: 4px;
	height: 8px;
	border: solid var( --nb-surface-alt, #1a2033 );
	border-width: 0 2px 2px 0;
	transform: rotate( 45deg );
}

/* ---------------------------------------------------- فرم‌ها */

.nb-sf__form--search {
	display: flex;
	gap: 6px;
}

.nb-sf__input,
.nb-sf__num {
	width: 100%;
	min-width: 0;
	height: 38px;
	padding: 0 10px;

	border: 1px solid var( --nb-border, #242c42 );
	border-radius: var( --nb-radius-sm, 8px );
	background: var( --nb-surface, #131829 );
	color: var( --nb-text, #ededed );

	/* ۱۶ پیکسل تا سافاری هنگام فوکوس زوم نکند. */
	font-size: 16px;
	font-family: inherit;
}

.nb-sf__input:focus,
.nb-sf__num:focus {
	outline: none;
	border-color: var( --nb-accent, #720eec );
}

.nb-sf__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.nb-sf__go {
	flex: 0 0 auto;
	width: 38px;
	height: 38px;
	border: 0;
	border-radius: var( --nb-radius-sm, 8px );
	background: var( --nb-accent, #720eec );
	cursor: pointer;
}

.nb-sf__go::before {
	content: "";
	display: block;
	width: 16px;
	height: 16px;
	margin: 0 auto;
	background: var( --nb-acc-fg, #fff );

	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-size: contain;
	mask-size: contain;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m16 16 4 4'/%3E%3C/svg%3E" );
	mask-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m16 16 4 4'/%3E%3C/svg%3E" );
}

.nb-sf__range {
	display: flex;
	align-items: center;
	gap: 8px;
}

.nb-sf__dash {
	flex: 0 0 auto;
	width: 10px;
	height: 1.5px;
	background: var( --nb-text-muted, #98a2b3 );
}

.nb-sf__apply {
	width: 100%;
	margin-top: 10px;
	padding: 9px;

	border: 0;
	border-radius: var( --nb-radius-sm, 8px );
	background: var( --nb-accent, #720eec );
	color: var( --nb-acc-fg, #fff );

	font-size: 12.5px;
	font-weight: 700;
	font-family: inherit;
	cursor: pointer;
}

.nb-sf__apply:hover {
	filter: brightness( 1.1 );
}

/* ==========================================================================
   موبایل — پنل به کشو تبدیل می‌شود
   ========================================================================== */

@media ( max-width: 991px ) {

	/* دکمه‌ی بازکردن، بالای شبکه کنارِ مرتب‌سازی. */
	.nb-sf__open {
		display: inline-flex;
		align-items: center;
		gap: 7px;

		padding: 9px 14px;
		border: 1px solid var( --nb-border, #242c42 );
		border-radius: var( --nb-radius-sm, 10px );
		background: var( --nb-surface-alt, #1a2033 );
		color: var( --nb-text, #ededed );

		font-size: 12.5px;
		font-weight: 700;
		font-family: inherit;
		cursor: pointer;
	}

	.nb-sf__open-icon {
		width: 15px;
		height: 15px;
		background: currentColor;

		-webkit-mask-position: center;
		mask-position: center;
		-webkit-mask-size: contain;
		mask-size: contain;
		-webkit-mask-repeat: no-repeat;
		mask-repeat: no-repeat;
		-webkit-mask-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M6 12h12'/%3E%3Cpath d='M10 18h4'/%3E%3C/svg%3E" );
		mask-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M6 12h12'/%3E%3Cpath d='M10 18h4'/%3E%3C/svg%3E" );
	}

	.nb-sf__open-count {
		min-width: 18px;
		height: 18px;
		padding: 0 5px;
		border-radius: 9px;
		background: var( --nb-accent, #720eec );
		color: var( --nb-acc-fg, #fff );
		font-size: 10.5px;
		line-height: 18px;
		text-align: center;
	}

	.nb-sf__veil {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 9998;
		background: rgba( 0, 0, 0, 0.55 );
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.25s ease, visibility 0.25s ease;
	}

	.nb-sf-open .nb-sf__veil {
		opacity: 1;
		visibility: visible;
	}

	/* ستون از جریانِ صفحه بیرون می‌رود و کشو می‌شود. */
	.nb-shop__side {
		position: fixed;
		top: 0;
		bottom: 0;
		right: 0;
		z-index: 9999;

		width: min( 320px, 88vw );
		margin: 0;
		padding: 16px;

		border-inline-start: 1px solid var( --nb-border, #242c42 );
		background: var( --nb-surface, #131829 );

		overflow-y: auto;
		overscroll-behavior: contain;

		transform: translateX( 100% );
		transition: transform 0.28s cubic-bezier( 0.22, 0.61, 0.36, 1 );
	}

	.nb-sf-open .nb-shop__side {
		transform: translateX( 0 );
	}

	.nb-sf-open,
	.nb-sf-open body {
		overflow: hidden;
	}

	.nb-sf__close {
		display: block;
		position: relative;
		width: 30px;
		height: 30px;
		border: 1px solid var( --nb-border, #242c42 );
		border-radius: var( --nb-radius-sm, 8px );
		background: var( --nb-surface-alt, #1a2033 );
		color: var( --nb-text-muted, #98a2b3 );
		cursor: pointer;
	}

	.nb-sf__close::before,
	.nb-sf__close::after {
		content: "";
		position: absolute;
		top: 50%;
		left: 50%;
		width: 13px;
		height: 1.6px;
		background: currentColor;
	}

	.nb-sf__close::before {
		transform: translate( -50%, -50% ) rotate( 45deg );
	}

	.nb-sf__close::after {
		transform: translate( -50%, -50% ) rotate( -45deg );
	}
}

@media ( prefers-reduced-motion: reduce ) {

	.nb-shop__side,
	.nb-sf__veil,
	.nb-sf__item,
	.nb-sf__toggle {
		transition: none;
	}
}

/* ==========================================================================
   نوارِ بالای شبکه
   ==========================================================================
   تعدادِ نتیجه، دکمه‌ی فیلتر و مرتب‌سازی سه عنصرِ جدا بودند که ووکامرس و
   این ماژول پشتِ سرِ هم چاپ می‌کنند. بدونِ ظرف، روی گوشی روی هم
   می‌افتادند — «فیلترها» وسطِ متنِ «نمایش ۱-۲۰ از ۱۲۹ نتیجه» نشسته بود.
   ========================================================================== */

.nb-shop__bar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 16px;
}

/* تعدادِ نتیجه فضای میانی را می‌گیرد تا بقیه به لبه بچسبند. */
.nb-shop__bar .woocommerce-result-count {
	margin: 0;
	margin-inline-end: auto;
	font-size: 12.5px;
	color: var( --nb-text-muted, #98a2b3 );
}

.nb-shop__bar .woocommerce-ordering {
	margin: 0;
}

@media ( max-width: 991px ) {

	/*
	 * روی گوشی تعدادِ نتیجه یک خطِ کاملِ خودش می‌گیرد و دکمه و
	 * مرتب‌سازی خطِ دوم را نصف‌نصف. سه چیز در یک خطِ ۳۷۵ پیکسلی یعنی
	 * همان درهم‌رفتگی که بود.
	 */
	.nb-shop__bar .woocommerce-result-count {
		flex: 1 1 100%;
		margin-inline-end: 0;
	}

	.nb-shop__bar .nb-sf__open,
	.nb-shop__bar .woocommerce-ordering {
		flex: 1 1 0;
		min-width: 0;
	}

	.nb-shop__bar .nb-sf__open {
		justify-content: center;
	}

	.nb-shop__bar .woocommerce-ordering select {
		width: 100%;
	}
}

/*
 * روی گوشی، مرتب‌سازی پهن‌تر از دکمه‌ی فیلتر است.
 *
 * نصف‌نصف که بود، «مرتب‌سازی پیشفرض» در ۱۵۶ پیکسل جا نمی‌شد و به
 * «مرتب‌سازی پیش» بریده می‌شد (اندازه‌گیری: scrollWidth > clientWidth).
 * کوچک‌کردنِ قلم راه‌حل نبود — زیرِ ۱۶ پیکسل، سافاری موقع باز کردنِ
 * فهرست صفحه را زوم می‌کند.
 */
@media ( max-width: 991px ) {

	.nb-shop__bar .nb-sf__open {
		flex: 0 0 auto;
	}

	/*
	 * پایه‌ی صفر، نه auto.
	 *
	 * با basis: auto عرضِ ذاتیِ <select> (طولانی‌ترین گزینه) مبنا
	 * می‌شد و از فضای باقی‌مانده بیشتر درمی‌آمد، پس فرم به خطِ بعد
	 * می‌پرید و دکمه تنها می‌ماند.
	 */
	.nb-shop__bar .woocommerce-ordering {
		flex: 1 1 0;
		min-width: 0;
	}
}


/* ==========================================================================
   زیردسته‌ها در فیلترِ دسته‌بندی
   ========================================================================== */

.nb-sf__row {
	display: flex;
	align-items: center;
	gap: 4px;
}

.nb-sf__row .nb-sf__item {
	flex: 1 1 auto;
	min-width: 0;
}

/* دکمه‌ی «+» که با باز شدن به «−» تبدیل می‌شود. */
.nb-sf__more {
	position: relative;
	flex: 0 0 auto;

	width: 28px;
	height: 28px;
	padding: 0;

	border: 1px solid var( --nb-border, #242c42 );
	border-radius: var( --nb-radius-sm, 8px );
	background: none;
	color: var( --nb-text-muted, #98a2b3 );
	cursor: pointer;

	transition: color 0.15s ease, border-color 0.15s ease;
}

.nb-sf__more:hover {
	border-color: var( --nb-accent, #720eec );
	color: var( --nb-text, #ededed );
}

.nb-sf__more::before,
.nb-sf__more::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	background: currentColor;
	transition: opacity 0.15s ease;
}

/* خطِ افقی همیشه هست؛ عمودی با باز شدن ناپدید می‌شود. */
.nb-sf__more::before {
	width: 11px;
	height: 1.6px;
	transform: translate( -50%, -50% );
}

.nb-sf__more::after {
	width: 1.6px;
	height: 11px;
	transform: translate( -50%, -50% );
}

.nb-sf__branch.is-open .nb-sf__more::after {
	opacity: 0;
}

.nb-sf__branch.is-open .nb-sf__more {
	border-color: var( --nb-accent, #720eec );
	color: var( --nb-link, #a78bfa );
}

/*
 * زیرفهرست بسته است مگر شاخه باز باشد.
 *
 * display: none و نه ارتفاعِ صفر — انیمیشنِ ارتفاع روی فهرستی که
 * تعدادش را نمی‌دانیم یا max-height دلبخواهی می‌خواهد یا JS، و هیچ‌کدام
 * ارزشش را ندارد.
 */
.nb-sf__sub {
	display: none;
	margin: 2px 0 6px;
	padding: 0;
	list-style: none;

	/* تورفتگی از سمتِ شروع، تا تودرتویی دیده شود. */
	padding-inline-start: 12px;
	border-inline-start: 1px solid var( --nb-border, #242c42 );
	margin-inline-start: 10px;
}

.nb-sf__branch.is-open .nb-sf__sub {
	display: block;
}

.nb-sf__item--sub {
	padding: 6px 8px;
	font-size: 12px;
	font-weight: 500;
}
