/*!
 * Listing toolbar (Comp-food-filter-sort): quick chips, sort menu, filter panel
 * (bottom sheet on phones), active-filter pills, empty state.
 * Markup: includes/vendor-filter.php. Script: asset/js/vendor-filter.js.
 * Handle: bfw-vendor-filter (depends on bch-ui: .bsy-chip, .bsy-btn, .bsy-link).
 */
.bfw-tools { display: flex; flex-direction: column; gap: var(--bsy-space-3); min-width: 0; }
.bfw-tools[aria-busy="true"] { cursor: progress; }
.bfw-tools__row { display: flex; flex-direction: column; gap: var(--bsy-space-3); min-width: 0; }
.bfw-tools__chips { min-width: 0; }
/* «بَلي برو» chip: the decorative Pro mark + the word. On the selected (blue)
   chip the red pill turns into a quiet white tint. */
.bfw-tools__chip, .bfw-vpage__chips .bsy-chip { gap: 6px; }
.bfw-chip-pro { pointer-events: none; height: 20px; padding: 0 6px; }
.bfw-chip-pro .bsy-pro__mark { height: 12px; }
:is([aria-pressed="true"], [aria-current="true"], [aria-current="page"]) > .bfw-chip-pro { background: rgba(255, 255, 255, .2); }
/* Scroll cue on chip strips that really overflow (.is-overflowing, set by the
   listing scripts): the inline END fades (a mask, not a background) so the
   first chip «الكل» stays crisp; the strip pads its end so the last chip clears it. */
@media (max-width: 1100px) {
	:is(.bfw-tools__chips, .bfw-vpage__chips).bsy-chips--scroll.is-overflowing {
		-webkit-mask-image: linear-gradient(to right, transparent 0, #000 24px);
		mask-image: linear-gradient(to right, transparent 0, #000 24px);
		padding-inline-end: var(--bsy-space-6);
	}
	[dir="ltr"] :is(.bfw-tools__chips, .bfw-vpage__chips).bsy-chips--scroll.is-overflowing {
		-webkit-mask-image: linear-gradient(to left, transparent 0, #000 24px);
		mask-image: linear-gradient(to left, transparent 0, #000 24px);
	}
}
.bfw-tools__menus {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--bsy-space-2);
}
.bfw-menu { position: relative; min-width: 0; }

/* Sort + filter triggers: 44 pills (40 ≥641), 14/500. */
.bfw-tool {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	box-sizing: border-box;
	width: 100%;
	min-height: 44px;
	padding: 0 var(--bsy-space-4);
	border: 1px solid var(--bsy-line-strong);
	border-radius: var(--bsy-radius-pill);
	background: var(--bsy-white);
	color: var(--bsy-ink);
	font-family: var(--bsy-font);
	font-size: var(--bsy-text-sm);
	font-weight: var(--bsy-fw-medium);
	line-height: 1;
	white-space: nowrap;
	cursor: pointer;
}
.bfw-tool svg { flex: none; width: 16px; height: 16px; }
.bfw-tool__v { font-weight: var(--bsy-fw-semibold); }
.bfw-tool[aria-expanded="true"] { border-color: var(--bsy-ink); }
@media (hover: hover) { .bfw-tool:hover { background: var(--bsy-grey-50); } }
.bfw-tool__n {
	display: inline-grid; place-items: center;
	min-width: 24px; height: 24px;
	padding: 0 6px;
	border-radius: var(--bsy-radius-pill);
	background: var(--bsy-brand);
	color: var(--bsy-white);
	font-size: var(--bsy-text-xs);
	font-weight: var(--bsy-fw-bold);
	font-variant-numeric: tabular-nums;
}
.bfw-tool__n[hidden] { display: none; }

/* Popovers. */
.bfw-pop {
	position: absolute;
	inset-block-start: calc(100% + 8px);
	inset-inline-end: 0;
	z-index: 30;
	box-sizing: border-box;
	margin: 0;
	padding: var(--bsy-space-2) 0;
	list-style: none;
	background: var(--bsy-white);
	border: 1px solid var(--bsy-line);
	border-radius: var(--bsy-radius-card);
	box-shadow: var(--bsy-shadow-2, 0 8px 24px rgba(10, 10, 10, .08));
}
.bfw-pop[hidden] { display: none; }
.bfw-pop--sort { width: 260px; max-height: min(70vh, 520px); overflow-y: auto; overscroll-behavior: contain; }
.bfw-pop__opt {
	display: flex; align-items: center; justify-content: space-between; gap: var(--bsy-space-2);
	min-height: 44px;
	padding: 0 var(--bsy-space-4);
	font-size: var(--bsy-text-base);
	color: var(--bsy-ink);
	cursor: pointer;
}
.bfw-pop__opt:hover, .bfw-pop__opt:focus-visible { background: var(--bsy-grey-50); }
.bfw-pop__opt[aria-selected="true"] { font-weight: var(--bsy-fw-semibold); color: var(--bsy-brand); }
.bfw-pop__opt[aria-selected="true"]::after {
	content: "";
	width: 6px; height: 11px;
	border: solid currentColor;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg) translate(-2px, -2px);
}
.bfw-pop--filters { width: 380px; padding: 0; max-height: min(70vh, 520px); overflow-y: auto; overscroll-behavior: contain; }
/* Desktop: open upwards when there is no room below (vendor-filter.js). */
.bfw-pop--up { inset-block-start: auto; inset-block-end: calc(100% + 8px); }
.bfw-pop__head {
	display: flex; align-items: center; justify-content: space-between; gap: var(--bsy-space-3);
	padding-block: var(--bsy-space-2);
	padding-inline: var(--bsy-space-5) var(--bsy-space-2);
}
.bfw-pop__t { margin: 0; font-size: var(--bsy-text-md); font-weight: var(--bsy-fw-bold); color: var(--bsy-ink); }
.bfw-pop__grp { margin: 0; padding: var(--bsy-space-4) var(--bsy-space-5); border: 0; border-block-start: 1px solid var(--bsy-line); min-width: 0; }
.bfw-pop__legend {
	/* Floated, so the label sits INSIDE its group (8px above its chips) instead
	   of on the group's top border, where it read as part of the group above. */
	float: inline-start; width: 100%;
	padding: 0; margin: 0 0 var(--bsy-space-2);
	font-size: var(--bsy-text-sm); font-weight: var(--bsy-fw-semibold); color: var(--bsy-ink);
}
.bfw-pop__legend + * { clear: both; }
.bfw-pop__chips { display: flex; flex-wrap: wrap; gap: var(--bsy-space-2); }
.bfw-pop__chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.bfw-pop__foot {
	position: sticky; inset-block-end: 0;
	display: flex; align-items: center; justify-content: space-between; gap: var(--bsy-space-2);
	padding: var(--bsy-space-4) var(--bsy-space-5);
	border-block-start: 1px solid var(--bsy-line);
	background: var(--bsy-white);
}

/* Phone: BOTH menus are bottom sheets over a scrim (never under the app bar,
   which hides while a sheet is open — see bulk/vendor-list.css). */
@media (max-width: 640px) {
	.bfw-pop--sort, .bfw-pop--filters {
		position: fixed;
		inset: auto 0 0 0;
		width: auto;
		max-height: 85vh;
		overflow-y: auto;
		border-radius: var(--bsy-radius-xl) var(--bsy-radius-xl) 0 0;
		padding-block-end: env(safe-area-inset-bottom);
		z-index: 60;
	}
	.bfw-pop--sort { padding-block: var(--bsy-space-3) calc(var(--bsy-space-3) + env(safe-area-inset-bottom)); }
	.bfw-pop--sort .bfw-pop__opt { min-height: 52px; padding-inline: var(--bsy-space-5); }
	.bfw-pop--filters .bfw-pop__foot { padding-block-end: calc(var(--bsy-space-4) + env(safe-area-inset-bottom)); }
	.bfw-pop--filters .bfw-pop__foot [data-apply] { flex: 1; }
	.bfw-sheet-open body::after {
		content: "";
		position: fixed; inset: 0;
		z-index: 55;
		background: rgba(10, 10, 10, .4);
	}
}

/* Active filters. */
.bfw-tools__active { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bsy-space-2); }
.bfw-tools__active[hidden] { display: none; }
.bfw-tools__active-k { font-size: var(--bsy-text-sm); color: var(--bsy-muted); }
.bfw-tools__pills { display: contents; list-style: none; margin: 0; padding: 0; }
.bfw-tools__pill {
	display: inline-flex; align-items: center; gap: 6px;
	min-height: 32px;
	padding: 0 var(--bsy-space-3);
	border: 0;
	border-radius: var(--bsy-radius-pill);
	background: var(--bsy-grey-100);
	color: var(--bsy-ink);
	font-family: var(--bsy-font);
	font-size: var(--bsy-text-sm);
	cursor: pointer;
}
.bfw-tools__pill::after { content: "×"; font-size: var(--bsy-text-base); line-height: 1; color: var(--bsy-fg2); }

.bfw-empty[hidden] { display: none; }

/* Tablet: chips get their own full row; sort + filter below, start-aligned. */
@media (min-width: 641px) {
	.bfw-tools__menus { display: flex; align-items: center; flex: none; }
	.bfw-tool { width: auto; min-height: var(--bsy-size-chip); }
}
/* Desktop: one row — chips, then the two menus at the end. */
/* 641–1100: the menus sit at the start of their own row, so popovers anchor to
   the trigger's start edge and grow toward the end — never off screen. */
@media (min-width: 641px) and (max-width: 1100px) {
	:is(.bfw-tools, .bfw-vpage__tools) .bfw-pop { inset-inline-start: 0; inset-inline-end: auto; max-width: calc(100vw - 2 * var(--bsy-gutter)); }
}
@media (min-width: 1101px) {
	.bfw-tools__row { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--bsy-space-4); }
}
