/**
 * MemberPress admin lists — query-builder filter card.
 *
 * The card is printed into a hidden pool in the footer and moved above
 * `div.tablenav.top` by JS, so it needs no positioning of its own.
 */

/* Staging area for card markup before JS moves it (see Meprmf_Plugin::print_deferred_floating_filter_panels). */
.meprmf-floating-panels-pool {
	position: absolute;
	width: 0;
	height: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
	padding: 0;
	margin: 0;
}

/* --- card --- */

.meprmf-qb {
	box-sizing: border-box;
	width: 100%;
	margin: 0 0 16px;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	background: #fff;
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
	font-size: 13px;
	line-height: 1.5;
	color: #1d2327;
}

.meprmf-qb *,
.meprmf-qb *::before,
.meprmf-qb *::after {
	box-sizing: border-box;
}

/* --- toolbar band --- */

.meprmf-qb__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	border-bottom: 1px solid #dcdcde;
	position: relative;
}

.meprmf-qb--collapsed .meprmf-qb__toolbar {
	border-bottom: 0;
}

.meprmf-qb__disclosure {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border: 1px solid #8c8f94;
	border-radius: 3px;
	background: #f6f7f7;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.5;
	color: #1d2327;
	cursor: pointer;
}

.meprmf-qb__disclosure:hover,
.meprmf-qb__disclosure:focus {
	background: #f0f0f1;
	border-color: #787c82;
	color: #1d2327;
}

.meprmf-qb__caret {
	font-size: 11px;
	line-height: 1;
	color: #646970;
}

.meprmf-qb__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: #2271b1;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
}

.meprmf-qb__add-wrap {
	position: relative;
	display: inline-flex;
}

.meprmf-qb__add {
	padding: 4px 10px;
	border: 1px solid #2271b1;
	border-radius: 3px;
	background: #f6f7f7;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.5;
	color: #2271b1;
	cursor: pointer;
}

.meprmf-qb__add:hover,
.meprmf-qb__add:focus {
	background: #f0f6fc;
	color: #135e96;
	border-color: #135e96;
}

.meprmf-qb__divider {
	flex: 0 0 auto;
	width: 1px;
	height: 22px;
	background: #dcdcde;
}

.meprmf-qb__views {
	max-width: 190px;
	padding: 4px 6px;
	border: 1px solid #8c8f94;
	border-radius: 3px;
	background: #fff;
	font-size: 13px;
	line-height: 1.5;
	color: #1d2327;
}

.meprmf-qb__spacer {
	flex: 1;
}

/* Chips only surface while the rows are collapsed, so they take their own line. */
.meprmf-qb__chips {
	flex: 0 0 100%;
	min-width: 0;
}

.meprmf-qb__chips .meprmf-active-filters {
	margin: 0;
}

/* --- add-filter popover --- */

.meprmf-qb__popover {
	position: absolute;
	top: 32px;
	left: 0;
	z-index: 30;
	width: 300px;
	max-height: 380px;
	overflow: auto;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	background: #fff;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
	text-align: start;
}

.meprmf-qb__popover-search {
	position: sticky;
	top: 0;
	padding: 8px;
	border-bottom: 1px solid #f0f0f1;
	background: #fff;
}

.meprmf-qb__search {
	width: 100%;
	padding: 4px 8px;
	border: 1px solid #8c8f94;
	border-radius: 3px;
	background: #fff;
	font-size: 13px;
	line-height: 1.5;
}

.meprmf-qb__opt-group {
	padding: 8px 10px 2px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #787c82;
}

.meprmf-qb__opt {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	padding: 6px 10px;
	border: 0;
	background: transparent;
	font-size: 13px;
	line-height: 1.5;
	color: #1d2327;
	text-align: start;
	cursor: pointer;
}

.meprmf-qb__opt:hover,
.meprmf-qb__opt:focus {
	background: #f0f6fc;
	color: #1d2327;
	outline: none;
}

.meprmf-qb__opt-label {
	min-width: 0;
}

.meprmf-qb__opt-kind {
	flex: 0 0 auto;
	font-size: 11px;
	color: #a7aaad;
}

.meprmf-qb__popover-empty {
	margin: 0;
	padding: 10px;
	font-size: 13px;
	color: #646970;
}

/* --- body band --- */

.meprmf-qb__body {
	padding: 6px 12px 12px;
}

.meprmf-qb__match {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 0;
}

.meprmf-qb__match-label {
	font-size: 12px;
	color: #646970;
}

.meprmf-qb__segments {
	display: inline-flex;
	border: 1px solid #8c8f94;
	border-radius: 3px;
	overflow: hidden;
}

.meprmf-qb__segment {
	padding: 3px 10px;
	border: 0;
	background: #fff;
	font-size: 12px;
	line-height: 1.5;
	color: #1d2327;
	cursor: pointer;
}

.meprmf-qb__segment + .meprmf-qb__segment {
	border-left: 1px solid #8c8f94;
}

.meprmf-qb__segment.is-selected {
	background: #2271b1;
	color: #fff;
}

/* --- filter row --- */

.meprmf-qb__row {
	display: grid;
	grid-template-columns: 180px 160px minmax(0, 1fr) 28px;
	gap: 8px;
	align-items: center;
	padding: 6px 0;
	border-top: 1px solid #f0f0f1;
}

.meprmf-qb__row-field {
	min-width: 0;
	font-size: 13px;
	font-weight: 600;
	color: #1d2327;
	overflow-wrap: break-word;
}

.meprmf-qb__op {
	width: 100%;
	min-width: 0;
	padding: 4px 6px;
	border: 1px solid #8c8f94;
	border-radius: 3px;
	background: #fff;
	font-size: 13px;
	line-height: 1.5;
	color: #1d2327;
}

.meprmf-qb__op-static {
	font-size: 13px;
	color: #646970;
}

.meprmf-qb__row-value {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.meprmf-qb__remove {
	padding: 4px;
	border: 0;
	border-radius: 3px;
	background: transparent;
	font-size: 16px;
	line-height: 1;
	color: #787c82;
	cursor: pointer;
}

.meprmf-qb__remove:hover,
.meprmf-qb__remove:focus {
	background: #f6f7f7;
	color: #d63638;
}

/* --- value controls --- */

.meprmf-qb__input {
	min-width: 0;
	margin: 0;
	padding: 4px 6px;
	border: 1px solid #8c8f94;
	border-radius: 3px;
	background: #fff;
	font-size: 13px;
	line-height: 1.5;
	color: #1d2327;
}

.meprmf-qb__input--choice {
	min-width: 200px;
	max-width: 100%;
}

.meprmf-qb__input--text {
	width: 240px;
	max-width: 100%;
	padding: 4px 8px;
}

.meprmf-qb__input--date,
.meprmf-qb__input--bound[type="date"] {
	width: auto;
	padding: 3px 6px;
}

.meprmf-qb__input--number {
	width: 110px;
}

.meprmf-qb__input--bound[type="number"] {
	width: 96px;
}

.meprmf-qb__input--n {
	width: 76px;
}

.meprmf-qb__unit,
.meprmf-qb__joiner {
	font-size: 13px;
	color: #646970;
}

.meprmf-qb__no-value {
	font-size: 13px;
	font-style: italic;
	color: #787c82;
}

.meprmf-qb__input:focus,
.meprmf-qb__op:focus,
.meprmf-qb__search:focus,
.meprmf-qb__views:focus {
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
	outline: none;
}

/* --- empty state --- */

.meprmf-qb__empty {
	padding: 22px 12px 24px;
	text-align: center;
}

.meprmf-qb__empty-text {
	margin: 0;
	font-size: 13px;
	color: #646970;
}

.meprmf-qb__pills {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-top: 12px;
}

.meprmf-qb__pill {
	padding: 4px 12px;
	border: 1px solid #c3c4c7;
	border-radius: 14px;
	background: #f6f7f7;
	font-size: 12px;
	line-height: 1.5;
	color: #2271b1;
	cursor: pointer;
}

.meprmf-qb__pill:hover,
.meprmf-qb__pill:focus {
	background: #f0f6fc;
	border-color: #2271b1;
	color: #135e96;
}

/* --- footer band --- */

.meprmf-qb__footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border-top: 1px solid #dcdcde;
	border-radius: 0 0 4px 4px;
	background: #f6f7f7;
}

.meprmf-qb__apply.button {
	flex: 0 0 auto;
}

.meprmf-qb__clear,
.meprmf-qb__save-view,
.meprmf-qb__delete-view {
	font-size: 13px;
}

.meprmf-qb__delete-view {
	color: #b32d2e;
}

.meprmf-qb__status {
	margin-inline-start: auto;
	font-size: 13px;
	color: #646970;
}

/* --- active filter chips --- */

.meprmf-active-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin: 8px 0;
}

.meprmf-active-filters__label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	color: #50575e;
}

.meprmf-active-filters__chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 6px 3px 9px;
	border: 1px solid #b9d3e8;
	border-radius: 3px;
	background: #f0f6fc;
	color: #0a4b78;
	font-size: 12px;
	line-height: 1.6;
	text-decoration: none;
}

.meprmf-active-filters__chip:hover,
.meprmf-active-filters__chip:focus {
	background: #dcecf9;
	border-color: #7fa9cd;
	color: #0a4b78;
}

.meprmf-active-filters__chip-x {
	font-size: 14px;
	line-height: 1;
	color: #0a4b78;
}

.meprmf-active-filters__chip:hover .meprmf-active-filters__chip-x,
.meprmf-active-filters__chip:focus .meprmf-active-filters__chip-x {
	color: #d63638;
}

.meprmf-active-filters__clear {
	margin-left: 4px;
	font-size: 12px;
	text-decoration: underline;
}

/*
 * Several parts of the card are display:flex, which outranks the UA
 * `[hidden] { display: none }` rule — restate it with enough specificity.
 */
.meprmf-qb[hidden],
.meprmf-qb [hidden] {
	display: none;
}

/* --- narrow screens --- */

@media screen and (max-width: 782px) {
	.meprmf-qb__row {
		grid-template-columns: 140px minmax(0, 1fr) 28px;
		grid-template-areas:
			"field field remove"
			"op    value value";
	}

	.meprmf-qb__row-field {
		grid-area: field;
	}

	.meprmf-qb__op,
	.meprmf-qb__op-static {
		grid-area: op;
	}

	.meprmf-qb__row-value {
		grid-area: value;
	}

	.meprmf-qb__remove {
		grid-area: remove;
		justify-self: end;
		align-self: start;
	}

	/* Span the toolbar band instead of the "+ Add filter" button. */
	.meprmf-qb__add-wrap {
		position: static;
	}

	.meprmf-qb__popover {
		top: 100%;
		left: 0;
		right: 0;
		width: auto;
	}

	.meprmf-qb__input--text,
	.meprmf-qb__input--choice {
		width: 100%;
		min-width: 0;
	}
}
