/**
 * BP Filter Engine — structure / behavior only.
 * Visual skin (colors, logo frames, chip pills) lives in
 * mu-plugins/buenpique-ui/assets/category-cro.css (bp-category-cro-style).
 */

/* Brand archives: Filtrar trigger when Blocksy omits .woo-listing-top */
.bpfe-listing-top {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: 0 0 1rem;
}
.bpfe-listing-top .ct-toggle-filter-panel {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}
@media (min-width: 1000px) {
	.bpfe-listing-top .ct-hidden-lg {
		display: none !important;
	}
}

.bpfe-filters {
	font-size: 0.875rem;
	margin-bottom: 1rem;
}

.bpfe-filters__title {
	margin: 0 0 0.5rem;
	font-size: 1rem;
}

.bpfe-filters__status {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.4rem;
	margin-bottom: 0.5rem;
	font-size: 0.8rem;
	min-height: 0;
}

.bpfe-filters__status:has(> .bpfe-filters__reset[hidden]:only-child) {
	display: none;
	margin: 0;
}

.bpfe-filters__reset {
	appearance: none;
	background: transparent;
	border: 0;
	padding: 0.15rem 0;
	text-decoration: underline;
	cursor: pointer;
	min-height: 32px;
	font-size: inherit;
}

.bpfe-filters__reset[hidden] {
	display: none !important;
}

.bpfe-filters__footer {
	display: none;
}

.bpfe-filters__apply {
	appearance: none;
	width: 100%;
	border: 0;
	border-radius: 2px;
	padding: 0.75rem 1rem;
	min-height: 48px;
	font-size: 0.95rem;
	font-weight: 600;
	cursor: pointer;
}

/* Offcanvas / mobile: sticky Apply + 44px taps */
.ct-panel .bpfe-filters__footer {
	display: block;
	position: sticky;
	bottom: 0;
	z-index: 5;
	margin: 0.75rem -0.25rem 0;
	padding: 0.65rem 0.25rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
	box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.06);
}

.ct-panel .bpfe-filters__list label {
	min-height: 40px;
	padding: 0.3rem 0;
}

.ct-panel .bpfe-filters__section summary {
	min-height: 32px;
}

.ct-panel .bpfe-size-chip {
	min-height: 40px;
	min-width: 40px;
	padding: 0.4rem 0.55rem;
}

@media (max-width: 999px) {
	.bpfe-filters__footer {
		display: block;
		position: sticky;
		bottom: 0;
		z-index: 5;
		margin-top: 0.75rem;
		padding: 0.65rem 0 calc(0.65rem + env(safe-area-inset-bottom, 0px));
	}

	.bpfe-filters__list label {
		min-height: 40px;
		padding: 0.3rem 0;
	}

	.bpfe-filters__section summary {
		min-height: 32px;
	}
}

/* Desktop page sidebar only: hide Apply (live updates).
 * IMPORTANT: Blocksy offcanvas content also has .ct-sidebar — must NOT hide Apply there. */
#sidebar .bpfe-filters__footer {
	display: none;
}

/* Offcanvas / filters panel: always show sticky Apply (wins over any .ct-sidebar rule) */
.ct-panel .bpfe-filters__footer,
#woo-filters-panel .bpfe-filters__footer,
#bp-filter-drawer .bpfe-filters__footer {
	display: block !important;
}

.bpfe-filters__loading {
	margin-bottom: 0.5rem;
	font-size: 0.8rem;
	opacity: 0.8;
}

.bpfe-filters__loading.is-error {
	opacity: 1;
}

.bpfe-filters__empty-index {
	margin-bottom: 0.65rem;
	padding: 0.5rem 0.6rem;
	font-size: 0.8rem;
	line-height: 1.35;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 2px;
	background: rgba(0, 0, 0, 0.03);
}

.bpfe-filters.is-loading {
	opacity: 0.65;
	/* Never lock the open offcanvas — pointer-events:none freezes mobile taps. */
	pointer-events: auto;
}
.bpfe-filters.is-loading .bpfe-filters__loading {
	pointer-events: none;
}
/* Desktop sidebar only: soft-lock while grid refreshes (panel stays visible). */
#sidebar .bpfe-filters.is-loading {
	pointer-events: none;
}

/* Soft busy state for mobile preview — panel stays tappable */
.bpfe-filters.is-previewing .bpfe-filters__loading {
	display: block;
}

.bpfe-filters__section {
	border-top: 1px solid rgba(0, 0, 0, 0.12);
	padding: 0.2rem 0;
}

.bpfe-filters__section summary {
	cursor: pointer;
	font-weight: 600;
	list-style: none;
	min-height: 28px;
	display: flex;
	align-items: center;
	font-size: 0.84rem;
}

.bpfe-filters__section summary::-webkit-details-marker {
	display: none;
}

.bpfe-filters__list {
	list-style: none;
	margin: 0.1rem 0 0;
	padding: 0;
	max-height: 220px;
	overflow: auto;
}

.bpfe-filters__list li {
	margin: 0;
	line-height: 1.15;
}

.bpfe-filters__list label {
	display: flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.02rem 0;
	cursor: pointer;
	min-height: 0;
}

.bpfe-filters__list input {
	margin: 0;
	flex: 0 0 auto;
}

.bpfe-filters__label {
	flex: 1 1 auto;
	line-height: 1.2;
	font-size: 0.84rem;
}

.bpfe-filters__count {
	opacity: 0.65;
	font-size: 0.8em;
	flex: 0 0 auto;
}

/* Price slider — layout/mechanics (thumb colors from CRO) */
.bpfe-filters__price {
	margin-top: 0.35rem;
}

.bpfe-filters__price-display {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.5rem;
	margin-bottom: 0.55rem;
}

.bpfe-filters__price-edit {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.2rem;
	min-width: 0;
	font-weight: 500;
}

.bpfe-filters__price-caption {
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	opacity: 0.7;
}

.bpfe-filters__price-field {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	min-height: 32px;
	padding: 0 0.45rem;
	border: 1px solid rgba(0, 0, 0, 0.18);
	border-radius: 4px;
}

.bpfe-filters__price-edit input[type="text"],
.bpfe-filters__price-edit input[type="number"] {
	width: 100%;
	min-width: 0;
	min-height: 30px;
	height: 30px;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.2;
	appearance: textfield;
	-moz-appearance: textfield;
}

.bpfe-filters__price-edit input[type="number"]::-webkit-outer-spin-button,
.bpfe-filters__price-edit input[type="number"]::-webkit-inner-spin-button {
	appearance: none;
	margin: 0;
}

.bpfe-filters__currency {
	opacity: 0.7;
	font-size: 0.85em;
	flex: 0 0 auto;
	font-weight: 600;
}

.bpfe-filters__price-sep {
	display: none;
}

.bpfe-filters__price-slider {
	position: relative;
	height: 40px;
	margin: 0.15rem 0 0.1rem;
	overflow: visible;
	--bpfe-range-left: 0%;
	--bpfe-range-right: 100%;
}

.bpfe-filters__price-slider::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 6px;
	transform: translateY(-50%);
	border-radius: 3px;
	background: rgba(0, 0, 0, 0.15);
	z-index: 0;
}

.bpfe-filters__price-slider::after {
	content: "";
	position: absolute;
	left: var(--bpfe-range-left);
	width: calc(var(--bpfe-range-right) - var(--bpfe-range-left));
	top: 50%;
	height: 6px;
	transform: translateY(-50%);
	border-radius: 3px;
	background: currentColor;
	pointer-events: none;
	z-index: 1;
}

.bpfe-filters__price-slider input[type="range"] {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 40px;
	margin: 0;
	padding: 0;
	background: transparent;
	pointer-events: none;
	appearance: none;
	-webkit-appearance: none;
	z-index: 2;
}

.bpfe-filters__price-slider input[type="range"].bpfe-filter-price-range-max {
	z-index: 3;
}

.bpfe-filters__price-slider input[type="range"]::-webkit-slider-thumb {
	appearance: none;
	-webkit-appearance: none;
	width: 20px;
	height: 20px;
	margin-top: -7px;
	border-radius: 50%;
	border: 2px solid #333;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	pointer-events: auto;
	position: relative;
	z-index: 4;
}

.bpfe-filters__price-slider input[type="range"]::-moz-range-thumb {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	border: 2px solid #333;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	pointer-events: auto;
}

.bpfe-filters__price-slider input[type="range"]::-webkit-slider-runnable-track {
	height: 6px;
	background: transparent;
	border: none;
}

.bpfe-filters__price-slider input[type="range"]::-moz-range-track {
	height: 6px;
	background: transparent;
	border: none;
}

/* Facet chips — layout only (skin in category-cro.css) */
.bpfe-filters__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.22rem;
	margin-top: 0.2rem;
	max-height: 220px;
	overflow: auto;
}

.bpfe-filter-chip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.25rem;
	margin: 0;
	cursor: pointer;
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
}

/* iOS/Safari: images/spans inside <label> steal taps; let the label own the hit target */
.bpfe-filter-chip > *:not(input) {
	pointer-events: none;
}

a.bpfe-filter-chip:hover,
a.bpfe-filter-chip:focus,
button.bpfe-filter-chip:hover,
button.bpfe-filter-chip:focus {
	text-decoration: none;
}

button.bpfe-filter-chip {
	font: inherit;
	cursor: pointer;
	background: transparent;
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	padding: 0;
}

.bpfe-filter-chip--logo {
	position: relative;
	box-sizing: border-box;
	overflow: hidden;
}

.bpfe-filter-chip--swatch {
	gap: 0.3rem;
}

.ct-panel .bpfe-filters__section summary {
	min-height: 36px;
}

ul.products.bpfe-grid-loading {
	opacity: 0.55;
	transition: opacity 0.2s ease;
}

.bpfe-no-results {
	margin: 1rem 0;
}

.bpfe-size-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
	margin-top: 0.4rem;
	min-height: 1.4rem;
	position: relative;
	z-index: 2;
}

.bpfe-size-chip {
	appearance: none;
	border: 1px solid rgba(0, 0, 0, 0.18);
	background: transparent;
	font-size: 0.75rem;
	line-height: 1;
	padding: 0.35rem 0.45rem;
	min-height: 28px;
	cursor: pointer;
	border-radius: 2px;
}

/* Beat Blocksy/Woo display:!important when filtered results fit on one page. */
.ct-pagination.bpfe-pagination-hidden,
.woocommerce-pagination.bpfe-pagination-hidden {
	display: none !important;
}

.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

/* -------------------------------------------------------------------------- */
/* Mobile — drawer AISLADO #bp-filter-drawer (sin #woo-filters-panel / Blocksy) */
/* -------------------------------------------------------------------------- */

.bp-filter-drawer {
	position: fixed;
	inset: 0;
	z-index: 1000000;
	display: none;
	pointer-events: none;
}

.bp-filter-drawer.bp-drawer--open {
	display: block;
	pointer-events: auto;
}

.bp-filter-drawer__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 0;
	border: 0;
	padding: 0;
	cursor: pointer;
}

.bp-filter-drawer__panel {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(100%, 360px);
	z-index: 1;
	display: flex;
	flex-direction: column;
	background: #fff;
	color: inherit;
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.18);
	pointer-events: auto;
	transform: translateX(100%);
	transition: transform 0.2s ease;
}

.bp-filter-drawer.bp-drawer--open .bp-filter-drawer__panel {
	transform: translateX(0);
}

.bp-filter-drawer__head {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	min-height: 52px;
	padding: 0.5rem 0.75rem;
	border-bottom: 1px solid rgba(0, 0, 0, 0.12);
	background: #fff;
}

.bp-filter-drawer__title {
	font-weight: 700;
	font-size: 1rem;
	color: inherit;
}

.bp-filter-drawer__close {
	flex: 0 0 auto;
	min-width: 44px;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.bp-filter-drawer__body {
	flex: 1 1 auto;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	padding: 0.75rem 0.85rem 1.5rem;
	overscroll-behavior: contain;
	color: inherit;
	background: #fff;
}

html.bp-filter-drawer-open {
	overflow: hidden;
}

.bp-filter-trigger {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	border: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	cursor: pointer;
	min-height: 44px;
	padding: 0.35rem 0.5rem;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

#bp-filter-drawer .bpfe-filters__section summary {
	min-height: 36px;
}

/* Legacy Blocksy filter panel stays inert / unreachable while BP owns the UX. */
#woo-filters-panel[inert] {
	pointer-events: none !important;
	visibility: hidden !important;
}
