/**
 * LDBY Product Filter - styles.
 *
 * Vans-style "Show Filters" slide-out panel + AJAX product grid.
 * Uses the FWW design tokens (Oswald / Open Sans, red accent) with fallbacks.
 *
 * Built by Loudbaby (https://loudbaby.com) for Frontline Workwear USA.
 */

.ldby-pf {
	/* Themed for the FWW dark navy shop background (white text, light hairlines,
	   red accent). Flip these tokens to light values if ever used on a light page. */
	--pf-ink: var(--fww-text, #ffffff);
	--pf-muted: var(--fww-text-muted, rgba(255, 255, 255, .65));
	--pf-line: var(--fww-border-med, rgba(255, 255, 255, .16));
	--pf-bg: var(--fww-navy, #152233);
	--pf-box-border: var(--fww-border-str, rgba(255, 255, 255, .42));
	--pf-accent: var(--fww-red, #c0392b);
	--pf-font-head: var(--fww-font-display, "Oswald", sans-serif);
	--pf-font-body: var(--fww-font-body, "Open Sans", sans-serif);
	--pf-panel-w: 290px;

	font-family: var(--pf-font-body);
	color: var(--pf-ink);
	max-width: var(--fww-max-w, 1280px);
	margin: 0 auto;
	padding: 0 20px 60px;
	box-sizing: border-box;
}

.ldby-pf *,
.ldby-pf *::before,
.ldby-pf *::after {
	box-sizing: border-box;
}

/* -------------------------------------------------- Head */
.ldby-pf-head {
	padding: 8px 0 14px;
}

.ldby-pf-crumb {
	font-size: 13px;
	color: var(--pf-muted);
	letter-spacing: .02em;
	margin-bottom: 10px;
}

.ldby-pf-crumb a {
	color: var(--pf-muted);
	text-decoration: none;
}

.ldby-pf-crumb a:hover {
	color: var(--pf-ink);
}

.ldby-pf-crumb__sep {
	margin: 0 6px;
	color: #b9b9b9;
}

.ldby-pf-title {
	font-family: var(--pf-font-head);
	font-weight: 600;
	font-size: clamp(26px, 4vw, 40px);
	line-height: 1.05;
	margin: 0 0 12px;
	text-transform: none;
}

.ldby-pf-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--pf-accent);
	border: 0;
	border-radius: 6px;
	padding: 10px 18px;
	font-family: var(--pf-font-body);
	font-size: 16px;
	font-weight: 600;
	color: #fff;
	cursor: pointer;
}

.ldby-pf-toggle svg {
	display: block;
}

.ldby-pf-toggle__hide {
	display: none;
}

.ldby-pf.is-filtering .ldby-pf-toggle__show {
	display: none;
}

.ldby-pf.is-filtering .ldby-pf-toggle__hide {
	display: inline;
}

/* -------------------------------------------------- Layout */
/* The product grid always spans the full content width. The filter panel is a
   slide-out drawer pinned to the LEFT EDGE of the viewport (all breakpoints),
   so opening it overlays the far-left strip instead of squeezing the grid. */
.ldby-pf-body {
	display: block;
}

.ldby-pf-main {
	width: 100%;
}

.ldby-pf-panel {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	z-index: 100000;
	width: var(--pf-panel-w);
	max-width: 90vw;
	background: var(--pf-bg);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform: translateX(-100%);
	transition: transform .3s ease;
	padding: 0;
	box-shadow: 2px 0 26px rgba(0, 0, 0, .38);
	overscroll-behavior: contain;
}

.ldby-pf.is-filtering .ldby-pf-panel {
	transform: translateX(0);
}

/* Sticky drawer header with close button (shown at all breakpoints). */
.ldby-pf-panel__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex: 0 0 auto;
	background: var(--pf-bg);
	padding: 18px 22px;
	border-bottom: 1px solid var(--pf-line);
	z-index: 1;
}

.ldby-pf-panel__heading {
	font-family: var(--pf-font-head);
	font-weight: 600;
	font-size: 20px;
}

.ldby-pf-panel__close {
	display: block;
	background: none;
	border: 0;
	font-size: 30px;
	line-height: 1;
	color: var(--pf-ink);
	cursor: pointer;
	padding: 0 4px;
}

/* Scrollable facet list (keeps header + mobile foot pinned). */
.ldby-pf-panel__inner {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 6px 22px 48px;
}

/* No dimming backdrop on desktop (products stay visible while filtering). */
.ldby-pf-overlay {
	display: none;
}

/* -------------------------------------------------- Sections / accordions */
.ldby-pf-section {
	border-top: 1px solid var(--pf-line);
}

.ldby-pf-section:first-of-type {
	border-top: 0;
}

.ldby-pf-section__head {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: none;
	border: 0;
	padding: 16px 2px;
	cursor: pointer;
	font-family: var(--pf-font-head);
	font-weight: 600;
	font-size: 17px;
	color: var(--pf-ink);
	text-align: left;
}

.ldby-pf-chevron {
	transition: transform .2s ease;
	color: var(--pf-muted);
	flex: 0 0 auto;
}

.ldby-pf-section.is-open .ldby-pf-chevron {
	transform: rotate(180deg);
}

.ldby-pf-section__body {
	display: none;
	padding: 0 2px 18px;
}

.ldby-pf-section.is-open .ldby-pf-section__body {
	display: block;
}

/* -------------------------------------------------- Options */
.ldby-pf-options {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 280px;
	overflow-y: auto;
}

.ldby-pf-opt {
	margin: 0;
}

.ldby-pf-opt label {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 7px 0;
	cursor: pointer;
	font-size: 15px;
	line-height: 1.3;
}

.ldby-pf-opt input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

/* Checkbox box */
.ldby-pf-opt__box {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	border: 1.5px solid var(--pf-box-border);
	border-radius: 3px;
	position: relative;
	transition: border-color .15s ease, background .15s ease;
}

.ldby-pf-opt input:checked + .ldby-pf-opt__box {
	background: var(--pf-accent);
	border-color: var(--pf-accent);
}

.ldby-pf-opt input:checked + .ldby-pf-opt__box::after {
	content: "";
	position: absolute;
	left: 5px;
	top: 1px;
	width: 5px;
	height: 10px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.ldby-pf-opt input:focus-visible + .ldby-pf-opt__box {
	outline: 2px solid var(--pf-accent);
	outline-offset: 2px;
}

/* Radio mark (sort) */
.ldby-pf-opt--radio .ldby-pf-opt__mark {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	border: 1.5px solid var(--pf-box-border);
	border-radius: 50%;
	position: relative;
}

.ldby-pf-opt--radio input:checked + .ldby-pf-opt__mark {
	border-color: var(--pf-accent);
}

.ldby-pf-opt--radio input:checked + .ldby-pf-opt__mark::after {
	content: "";
	position: absolute;
	inset: 3px;
	border-radius: 50%;
	background: var(--pf-accent);
}

.ldby-pf-opt__label {
	flex: 1 1 auto;
}

.ldby-pf-opt__count {
	color: var(--pf-muted);
	font-size: 14px;
	flex: 0 0 auto;
}

.ldby-pf-opt--empty {
	opacity: .4;
}

.ldby-pf-opt--empty label {
	cursor: default;
}

/* -------------------------------------------------- Panel footer (mobile) */
.ldby-pf-panel__foot {
	display: none;
}

.ldby-pf-clear {
	background: none;
	border: 0;
	padding: 14px 2px 0;
	font-size: 14px;
	font-weight: 600;
	text-decoration: underline;
	color: var(--pf-ink);
	cursor: pointer;
}

/* -------------------------------------------------- Result bar + grid */
.ldby-pf-resultbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 44px;
	margin-bottom: 16px;
}

.ldby-pf-count {
	font-size: 14px;
	color: var(--pf-muted);
	font-weight: 600;
}

.ldby-pf-grid {
	position: relative;
	transition: opacity .2s ease;
}

.ldby-pf.is-loading .ldby-pf-grid {
	opacity: .45;
	pointer-events: none;
}

/* Responsive product grid (overrides WC float layout). */
.ldby-pf-products {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 26px 22px;
}

.ldby-pf-products::before,
.ldby-pf-products::after {
	display: none !important;
}

.ldby-pf-products li.product {
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
	clear: none !important;
}

/* Uniform white image tile. The child theme's white-tile rule is scoped to a
   ".woocommerce ul.products" ancestor that this shortcode grid doesn't have, so
   without this the transparent product PNGs fall back to the navy page color.
   A white tile + contained fit makes every thumbnail consistent (matches the
   brand/category cards). */
.ldby-pf-products li.product img.attachment-woocommerce_thumbnail,
.ldby-pf-products li.product img.wp-post-image,
.ldby-pf-products li.product .woocommerce-loop-product__link img,
.ldby-pf-products li.product a img {
	background-color: #fff !important;
	padding: 12px !important;
	width: 100% !important;
	height: auto !important;
	aspect-ratio: 1 / 1 !important;
	object-fit: contain !important;
	border-radius: 8px !important;
	margin-bottom: 10px !important;
}

/* Product card title. The child theme's loop-title rule is scoped to a
   ".woocommerce ul.products" ancestor that the shortcode wrapper doesn't have,
   so without this the title falls back to the theme's oversized heading style. */
.ldby-pf-products li.product .woocommerce-loop-product__title {
	font-family: var(--pf-font-head) !important;
	font-size: 16px !important;
	line-height: 1.2 !important;
	font-weight: 600 !important;
	color: var(--pf-ink) !important;
	text-transform: uppercase !important;
	letter-spacing: .01em !important;
	margin: 0 !important;
	padding: 12px 2px 4px !important;
}

/* -------------------------------------------------- Empty state */
.ldby-pf-empty {
	text-align: center;
	padding: 60px 20px;
}

.ldby-pf-empty__title {
	font-family: var(--pf-font-head);
	font-size: 20px;
	margin: 0 0 16px;
}

.ldby-pf-clear-empty {
	background: var(--pf-accent);
	color: #fff;
	border: 0;
	padding: 12px 26px;
	font-weight: 600;
	border-radius: 4px;
	cursor: pointer;
}

/* -------------------------------------------------- Pagination */
.ldby-pf-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin-top: 44px;
}

.ldby-pf-page {
	min-width: 40px;
	height: 40px;
	padding: 0 12px;
	border: 1px solid var(--pf-line);
	background: transparent;
	color: var(--pf-ink);
	font-weight: 600;
	font-size: 14px;
	border-radius: 4px;
	cursor: pointer;
}

.ldby-pf-page:hover {
	border-color: var(--pf-ink);
}

.ldby-pf-page.is-active {
	background: var(--pf-accent);
	color: #fff;
	border-color: var(--pf-accent);
}

.ldby-pf-page-dots {
	color: var(--pf-muted);
	padding: 0 4px;
}

/* -------------------------------------------------- Loading spinner */
.ldby-pf-loading {
	display: flex;
	justify-content: center;
	padding: 30px 0;
}

/* Honor the [hidden] attribute. Without this, the display:flex above overrides
   the UA "[hidden] { display:none }" and the spinner shows permanently. */
.ldby-pf-loading[hidden] {
	display: none;
}

.ldby-pf-spinner {
	width: 28px;
	height: 28px;
	border: 3px solid var(--pf-line);
	border-top-color: var(--pf-accent);
	border-radius: 50%;
	animation: ldby-pf-spin .7s linear infinite;
}

@keyframes ldby-pf-spin {
	to { transform: rotate(360deg); }
}

/* -------------------------------------------------- Tablet */
@media (max-width: 1024px) {
	.ldby-pf-products {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* -------------------------------------------------- Mobile drawer */
@media (max-width: 782px) {
	.ldby-pf-products {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 22px 14px;
	}

	/* Wider drawer. */
	.ldby-pf-panel {
		width: min(88vw, 360px);
		box-shadow: 2px 0 18px rgba(0, 0, 0, .28);
	}

	.ldby-pf-panel__bar {
		padding: 18px 18px;
	}

	.ldby-pf-panel__inner {
		padding: 6px 18px 24px;
	}

	/* Dimming backdrop on mobile (tap to close). */
	.ldby-pf-overlay {
		display: none;
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, .45);
		z-index: 99999;
	}

	.ldby-pf.is-filtering .ldby-pf-overlay {
		display: block;
	}

	/*
	 * Pin Clear / View results to the drawer footer via flex (not position:fixed).
	 * Fixed fails here: the panel uses transform for the slide-in, which makes
	 * fixed descendants position against the panel and scroll with its content
	 * on mobile Safari.
	 */
	.ldby-pf-panel__foot {
		display: flex;
		flex: 0 0 auto;
		gap: 12px;
		position: relative;
		left: auto;
		bottom: auto;
		width: auto;
		padding: 14px 18px;
		background: var(--pf-bg);
		border-top: 1px solid var(--pf-line);
		z-index: 1;
	}

	.ldby-pf-panel__foot .ldby-pf-clear {
		padding: 12px;
		flex: 1 1 40%;
		text-align: center;
	}

	.ldby-pf-apply {
		flex: 1 1 60%;
		background: var(--pf-accent);
		color: #fff;
		border: 0;
		border-radius: 4px;
		font-weight: 600;
		padding: 12px;
		cursor: pointer;
	}
}

/*
 * Hide the Loudbaby chat launcher while the mobile filter drawer is open so
 * it cannot cover Clear all / View results (chat uses a higher z-index).
 */
@media (max-width: 782px) {
	body.ldby-pf-drawer-open .lb-launcher,
	body.ldby-pf-drawer-open .lb-panel {
		opacity: 0 !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}
}

@media (min-width: 783px) {
	/* Desktop: hide the mobile footer bar (close via the X or the toggle). */
	.ldby-pf-panel__foot {
		display: none;
	}
}

/* ==================================================================
   Override the parent Hello Elementor reset.css, which styles EVERY
   <button> with a pink (#c36) border + pink hover/focus background.
   Without this, the panel buttons flash pink instead of brand red.
   ================================================================== */
.ldby-pf button {
	border: 0;
	border-radius: 0;
	background-color: transparent;
	color: inherit;
}

.ldby-pf button:hover,
.ldby-pf button:focus,
.ldby-pf button:focus:hover {
	background-color: transparent;
	color: inherit;
}

/* Toggle = brand-red pill (matches the nav cart) with side padding. */
.ldby-pf .ldby-pf-toggle,
.ldby-pf .ldby-pf-toggle:focus {
	background-color: var(--pf-accent);
	color: #fff;
	border-radius: 6px;
	padding: 10px 18px;
}

.ldby-pf .ldby-pf-toggle:hover {
	background-color: var(--fww-red-hover, #a93226);
	color: #fff;
}

/* Pagination keeps its hairline border; active page = brand red. */
.ldby-pf .ldby-pf-page {
	border: 1px solid var(--pf-line);
}

.ldby-pf .ldby-pf-page:hover {
	border-color: var(--pf-ink);
}

.ldby-pf .ldby-pf-page.is-active,
.ldby-pf .ldby-pf-page.is-active:hover {
	background-color: var(--pf-accent);
	border-color: var(--pf-accent);
	color: #fff;
}

/* Solid action buttons stay brand red on hover (not pink). */
.ldby-pf .ldby-pf-clear-empty,
.ldby-pf .ldby-pf-apply {
	background-color: var(--pf-accent);
	color: #fff;
}

.ldby-pf .ldby-pf-clear-empty:hover,
.ldby-pf .ldby-pf-apply:hover {
	background-color: var(--fww-red-hover, #a93226);
	color: #fff;
}

@media (max-width: 480px) {
	.ldby-pf-products,
	.ldby-pf.is-filtering .ldby-pf-products {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 18px 12px;
	}
}

/* -------------------------------------------------- Archive In Stock toggle */
/* Standalone tickbox on standard WooCommerce archives (category / tag / brand
   pages without the [ldby_shop] panel). Redeclares the panel tokens because
   there is no .ldby-pf ancestor here. */
.ldby-pf-archive-toggle {
	--pf-box-border: var(--fww-border-str, rgba(255, 255, 255, .42));
	--pf-accent: var(--fww-red, #c0392b);

	float: right;
	margin: 0 0 24px 16px;
	font-family: var(--fww-font-body, "Open Sans", sans-serif);
	color: var(--fww-text, #ffffff);
}

.ldby-pf-archive-toggle label {
	padding: 0;
	white-space: nowrap;
}

.ldby-pf-archive-toggle .ldby-pf-opt__label {
	font-size: 15px;
}

.ldby-pf-archive-toggle__apply {
	margin-left: 8px;
	background: var(--pf-accent);
	color: #fff;
	border: 0;
	border-radius: 4px;
	padding: 4px 12px;
	cursor: pointer;
}

@media (max-width: 480px) {
	.ldby-pf-archive-toggle {
		float: none;
		margin: 0 0 14px;
	}
}
