/**
 * WCPC Core — the shared filter bar (filter bar spec v1).
 *
 * Rendered by wcpc_filterbar() (includes/class-wcpc-core-filterbar.php),
 * enhanced by assets/js/filterbar.js. Styled against --wcpc-* only.
 *
 *   .wcpc-filterbar                card: white, hairline border, r16, shadow-1, 24px
 *     __search                     magnifier + full-width input
 *     __fields                     grid, repeat(--wcpc-filterbar-cols, minmax(0, 1fr))  ← the 1/N rule
 *       __field > __label + (__control > __select + .wcpc-dropdown) | __field-input
 *     __foot                       hairline top; __chips left, __count right
 *
 * Breakpoints: ≤1024px fields go 2-up (an odd last field spans the row);
 * ≤640px everything stacks and the foot wraps.
 *
 * Specificity note: the Elementor kit styles bare <button> at (0,1,1)
 * (`.elementor-kit-NN button`). Every rule on the popover trigger is doubled
 * (`.wcpc-dropdown__trigger.wcpc-dropdown__trigger`, (0,2,0)) and restates
 * background / color / border / radius / padding so the kit can't recolor it.
 */

.wcpc-filterbar {
	--wcpc-filterbar-cols: 1;
	--wcpc-filterbar-control-h: 46px;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: var(--wcpc-space-md, 16px);
	margin: 0 0 var(--wcpc-space-xl, 32px);
	padding: var(--wcpc-space-lg, 24px);
	background: var(--wcpc-color-bg, #fff);
	border: 1px solid var(--wcpc-color-border, #D5DEE5);
	border-radius: var(--wcpc-radius-lg, 16px);
	box-shadow: var(--wcpc-shadow-1, 0 1px 2px rgba(0, 59, 92, 0.06), 0 1px 3px rgba(0, 59, 92, 0.08));
	font-family: var(--wcpc-font-sans, "Open Sans", sans-serif);
	color: var(--wcpc-color-text, #1F2933);
}
.wcpc-filterbar *,
.wcpc-filterbar *::before,
.wcpc-filterbar *::after {
	box-sizing: border-box;
}

/* ---- one control skin for the search input, triggers and inputs ---------- */
.wcpc-filterbar .wcpc-filterbar__input,
.wcpc-filterbar .wcpc-filterbar__field-input,
.wcpc-filterbar .wcpc-filterbar__select,
.wcpc-filterbar .wcpc-dropdown__trigger.wcpc-dropdown__trigger {
	display: block;
	width: 100%;
	min-height: var(--wcpc-filterbar-control-h);
	margin: 0;
	padding: 11px 14px;
	font-family: inherit;
	font-size: var(--wcpc-text-body, 16px);
	font-weight: 400;
	line-height: 1.3;
	color: var(--wcpc-color-text, #1F2933);
	background: var(--wcpc-color-bg, #fff);
	border: 1.5px solid var(--wcpc-color-border-strong, #B8C5CF);
	border-radius: var(--wcpc-radius-md, 10px);
	box-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	transition: border-color var(--wcpc-transition-fast, 120ms ease-out), box-shadow var(--wcpc-transition-fast, 120ms ease-out);
	-webkit-appearance: none;
	appearance: none;
}
.wcpc-filterbar .wcpc-filterbar__input:hover,
.wcpc-filterbar .wcpc-filterbar__field-input:hover,
.wcpc-filterbar .wcpc-filterbar__select:hover,
.wcpc-filterbar .wcpc-dropdown__trigger.wcpc-dropdown__trigger:hover {
	border-color: var(--wcpc-color-primary, #34657F);
	background: var(--wcpc-color-bg, #fff);
	color: var(--wcpc-color-text, #1F2933);
}
.wcpc-filterbar .wcpc-filterbar__input:focus,
.wcpc-filterbar .wcpc-filterbar__field-input:focus,
.wcpc-filterbar .wcpc-filterbar__select:focus,
.wcpc-filterbar .wcpc-dropdown__trigger.wcpc-dropdown__trigger:focus-visible {
	outline: none;
	border-color: var(--wcpc-color-primary, #34657F);
	box-shadow: var(--wcpc-focus-ring, 0 0 0 3px rgba(52, 101, 127, 0.35));
}
.wcpc-filterbar .wcpc-filterbar__input::placeholder,
.wcpc-filterbar .wcpc-filterbar__field-input::placeholder {
	color: var(--wcpc-color-text-placeholder, #9AA8B2);
	opacity: 1;
}
.wcpc-filterbar .wcpc-filterbar__input::-webkit-search-decoration,
.wcpc-filterbar .wcpc-filterbar__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

/* ---- search row ---------------------------------------------------------- */
.wcpc-filterbar__search {
	position: relative;
}
.wcpc-filterbar__search .wcpc-filterbar__icon {
	position: absolute;
	left: 14px;
	top: 50%;
	width: 20px;
	height: 20px;
	transform: translateY(-50%);
	color: var(--wcpc-color-primary, #34657F);
	pointer-events: none;
}
.wcpc-filterbar .wcpc-filterbar__search .wcpc-filterbar__input {
	padding-left: 44px;
}

/* ---- fields row — the 1/N rule ------------------------------------------- */
.wcpc-filterbar__fields {
	display: grid;
	grid-template-columns: repeat(var(--wcpc-filterbar-cols, 1), minmax(0, 1fr));
	gap: var(--wcpc-space-md, 16px);
	align-items: start;
}
.wcpc-filterbar__field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}
.wcpc-filterbar .wcpc-filterbar__label {
	display: block;
	margin: 0;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.06em;
	line-height: 1.3;
	text-transform: uppercase;
	color: var(--wcpc-color-text-muted, #5B6B78);
}
.wcpc-filterbar__control {
	position: relative;
}

/* Native select: a styled select until JS enhances it, then hidden but kept
   in the accessibility tree + form so engines and no-JS submits keep working. */
.wcpc-filterbar .wcpc-filterbar__select {
	cursor: pointer;
	padding-right: 42px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2334657F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
}
.wcpc-filterbar .wcpc-filterbar__control.is-enhanced > .wcpc-filterbar__select {
	position: absolute !important;
	width: 1px;
	height: 1px;
	min-height: 0;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
	opacity: 0;
	pointer-events: none;
}
.wcpc-filterbar .wcpc-filterbar__field-input[type="date"] {
	min-height: var(--wcpc-filterbar-control-h);
}
.wcpc-filterbar .wcpc-filterbar__field-input[type="number"] {
	-moz-appearance: textfield;
}

/* ---- popover dropdown ---------------------------------------------------- */
.wcpc-filterbar .wcpc-dropdown {
	display: none;
	position: relative;
	width: 100%;
}
.wcpc-filterbar .wcpc-filterbar__control.is-enhanced > .wcpc-dropdown {
	display: block;
}
.wcpc-filterbar .wcpc-dropdown__trigger.wcpc-dropdown__trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--wcpc-space-sm, 8px);
	padding-right: 12px;
	text-align: left;
	cursor: pointer;
}
.wcpc-filterbar .wcpc-dropdown__value {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.wcpc-filterbar .wcpc-dropdown__chevron {
	display: inline-flex;
	flex: none;
	width: 20px;
	height: 20px;
	color: var(--wcpc-color-primary, #34657F);
	transition: transform var(--wcpc-transition-fast, 120ms ease-out);
}
.wcpc-filterbar .wcpc-dropdown__chevron svg {
	width: 100%;
	height: 100%;
}
.wcpc-filterbar .wcpc-dropdown.is-open .wcpc-dropdown__chevron {
	transform: rotate(180deg);
}
.wcpc-filterbar .wcpc-dropdown__panel {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	z-index: 1000;
	min-width: 100%;
	max-width: min(100vw - 32px, 480px);
	max-height: min(60vh, 360px);
	overflow-y: auto;
	margin: 0;
	padding: 6px;
	list-style: none;
	background: var(--wcpc-color-bg, #fff);
	border: 1px solid var(--wcpc-color-border, #D5DEE5);
	border-radius: var(--wcpc-radius-md, 10px);
	box-shadow: var(--wcpc-shadow-2, 0 4px 12px rgba(0, 59, 92, 0.10));
}
.wcpc-filterbar .wcpc-dropdown__panel[hidden] {
	display: none;
}
.wcpc-filterbar .wcpc-dropdown__option {
	display: flex;
	align-items: center;
	gap: var(--wcpc-space-sm, 8px);
	margin: 0;
	padding: 8px 10px;
	border-radius: var(--wcpc-radius-sm, 6px);
	font-size: 15px;
	line-height: 1.35;
	color: var(--wcpc-color-text, #1F2933);
	cursor: pointer;
}
.wcpc-filterbar .wcpc-dropdown__option:hover,
.wcpc-filterbar .wcpc-dropdown__option.is-active {
	background: var(--wcpc-tint-blue, #EDF4FA);
}
.wcpc-filterbar .wcpc-dropdown__option.is-selected {
	color: var(--wcpc-color-primary, #34657F);
	font-weight: 600;
}
.wcpc-filterbar .wcpc-dropdown__option-text {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-width: 0;
}
.wcpc-filterbar .wcpc-dropdown__option-meta {
	font-size: 12.5px;
	font-weight: 400;
	color: var(--wcpc-color-text-muted, #5B6B78);
}
.wcpc-filterbar .wcpc-dropdown__option-badge {
	flex: none;
	padding: 1px 8px;
	border-radius: var(--wcpc-radius-full, 9999px);
	background: var(--wcpc-tint-blue, #EDF4FA);
	color: var(--wcpc-text-on-blue, #003B5C);
	font-size: 11px;
	font-weight: 600;
	line-height: 1.5;
	white-space: nowrap;
}
.wcpc-filterbar .wcpc-dropdown__option-check {
	display: inline-flex;
	flex: none;
	width: 16px;
	height: 16px;
	color: var(--wcpc-color-primary, #34657F);
	visibility: hidden;
}
.wcpc-filterbar .wcpc-dropdown__option.is-selected .wcpc-dropdown__option-check {
	visibility: visible;
}
.wcpc-filterbar .wcpc-dropdown__divider {
	height: 1px;
	margin: 6px 4px;
	padding: 0;
	background: var(--wcpc-color-border, #D5DEE5);
	list-style: none;
}

/* ---- foot ---------------------------------------------------------------- */
.wcpc-filterbar__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--wcpc-space-md, 16px);
	flex-wrap: wrap;
	padding-top: var(--wcpc-space-sm, 8px);
	border-top: 1px solid var(--wcpc-color-border, #D5DEE5);
}
.wcpc-filterbar__chips {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wcpc-space-sm, 8px);
}
.wcpc-filterbar__chips:empty {
	display: none;
}
.wcpc-filterbar .wcpc-filterbar__chip.wcpc-filterbar__chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 4px 8px 4px 10px;
	border: 0;
	border-radius: var(--wcpc-radius-full, 9999px);
	background: var(--wcpc-tint-blue, #EDF4FA);
	color: var(--wcpc-text-on-blue, #003B5C);
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.5;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
}
.wcpc-filterbar .wcpc-filterbar__chip.wcpc-filterbar__chip:hover {
	background: var(--wcpc-color-surface-alt, #E8EEF3);
	color: var(--wcpc-text-on-blue, #003B5C);
}
.wcpc-filterbar .wcpc-filterbar__chip.wcpc-filterbar__chip:focus-visible {
	outline: none;
	box-shadow: var(--wcpc-focus-ring, 0 0 0 3px rgba(52, 101, 127, 0.35));
}
.wcpc-filterbar .wcpc-filterbar__chip-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	flex: none;
	border-radius: 50%;
	background: var(--wcpc-color-primary, #34657F);
}
.wcpc-filterbar .wcpc-filterbar__chip svg {
	width: 14px;
	height: 14px;
	flex: none;
}
.wcpc-filterbar .wcpc-filterbar__chip--clear.wcpc-filterbar__chip--clear {
	padding: 4px 6px;
	background: transparent;
	color: var(--wcpc-color-text-muted, #5B6B78);
	font-weight: 500;
	text-decoration: underline;
	text-underline-offset: 2px;
}
.wcpc-filterbar .wcpc-filterbar__chip--clear.wcpc-filterbar__chip--clear:hover {
	background: transparent;
	color: var(--wcpc-color-primary, #34657F);
}
.wcpc-filterbar .wcpc-filterbar__count {
	margin: 0 0 0 auto;
	font-size: var(--wcpc-text-body-sm, 14px);
	line-height: 1.5;
	color: var(--wcpc-color-text-muted, #5B6B78);
	font-variant-numeric: tabular-nums;
}
.wcpc-filterbar .wcpc-filterbar__count strong {
	color: var(--wcpc-color-primary-dark, #003B5C);
	font-weight: 700;
}

/* ---- bare variant: no card chrome (a single standalone dropdown) ---------- */
.wcpc-filterbar.wcpc-filterbar--bare {
	padding: 0;
	margin: 0;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}
.wcpc-filterbar.is-submitting {
	opacity: 0.6;
	pointer-events: none;
}

/* ---- breakpoints --------------------------------------------------------- */
@media (max-width: 1024px) {
	.wcpc-filterbar__fields {
		grid-template-columns: repeat(min(var(--wcpc-filterbar-cols, 1), 2), minmax(0, 1fr));
	}
	.wcpc-filterbar__field:last-child:nth-child(odd) {
		grid-column: 1 / -1;
	}
}
@media (max-width: 640px) {
	.wcpc-filterbar {
		padding: var(--wcpc-space-md, 16px);
		gap: 12px;
		margin-bottom: var(--wcpc-space-lg, 24px);
	}
	.wcpc-filterbar__fields {
		grid-template-columns: minmax(0, 1fr);
		gap: 12px;
	}
	.wcpc-filterbar__field:last-child:nth-child(odd) {
		grid-column: auto;
	}
	.wcpc-filterbar__foot {
		flex-direction: column;
		align-items: flex-start;
	}
	.wcpc-filterbar .wcpc-filterbar__count {
		margin-left: 0;
	}
}


/* 2.8.0 — a long placeholder ends in "…" instead of being cut mid-word
   ("Search messages by title, sci") on a phone. */
.wcpc-filterbar__input {
	text-overflow: ellipsis;
}
