/**
 * GenieBuilder — Results Grid.
 * Token-driven responsive matrix. Cards render via the shared card styles.
 */

.mlsg-gb-grid {
	display: grid;
	grid-template-columns: repeat(var(--gb-grid-cols, 3), minmax(0, 1fr));
	gap: var(--gb-grid-gap, 1.5rem);
	width: 100%;
}

.mlsg-gb-grid__item {
	display: flex;
	min-width: 0;
}

.mlsg-gb-grid__item > .mlsg-gb-card {
	width: 100%;
}

.mlsg-gb-grid__empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--gb-space-sm);
	padding: var(--gb-space-lg);
	color: var(--gb-color-muted);
	font-size: var(--gb-font-meta);
	text-align: center;
}

.mlsg-gb-grid__empty i {
	font-size: 2rem;
	color: var(--gb-color-muted);
}

/* ── Layout modes (Patch B) ───────────────────────────────────────────────── */
.mlsg-gb-grid--equal .mlsg-gb-grid__item > .mlsg-gb-card {
	height: 100%;
}

.mlsg-gb-grid--list {
	grid-template-columns: 1fr;
}

.mlsg-gb-grid--list .mlsg-gb-card {
	flex-direction: row;
	align-items: stretch;
}

.mlsg-gb-grid--list .mlsg-gb-card__media {
	flex: 0 0 40%;
	max-width: 40%;
	aspect-ratio: var(--gb-aspect, 4 / 3);
}

.mlsg-gb-grid--list .mlsg-gb-card__body {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

@media (max-width: 640px) {
	.mlsg-gb-grid--list .mlsg-gb-card {
		flex-direction: column;
	}
	.mlsg-gb-grid--list .mlsg-gb-card__media {
		flex-basis: auto;
		max-width: 100%;
	}
}

/* ── Visitor sort / filter toolbar (Patch E) ──────────────────────────────── */
.mlsg-gb-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: var(--gb-grid-gap, 1.5rem);
	padding: 12px 14px;
	background: var(--gb-color-surface, #fff);
	border: 1px solid var(--gb-color-border, #e5e7eb);
	border-radius: var(--gb-radius-card, 12px);
}

.mlsg-gb-toolbar__filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.mlsg-gb-toolbar__field {
	height: 40px;
	padding: 0 12px;
	font-size: 0.9375rem;
	color: var(--gb-color-text, #1f2733);
	background: #fff;
	border: 1px solid var(--gb-color-border, #e5e7eb);
	border-radius: 8px;
}

.mlsg-gb-toolbar__field--num {
	width: 96px;
}

.mlsg-gb-toolbar__field:focus-visible {
	outline: 2px solid var(--gb-color-primary, #2563eb);
	outline-offset: 1px;
}

.mlsg-gb-toolbar__sort {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	white-space: nowrap;
}

.mlsg-gb-toolbar__sort-label {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--gb-color-text-muted, #64748b);
}

.mlsg-gb-toolbar__apply {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

@media (max-width: 640px) {
	.mlsg-gb-toolbar,
	.mlsg-gb-toolbar__filters {
		width: 100%;
	}
	.mlsg-gb-toolbar__field { flex: 1 1 auto; }
}

/* AJAX in-place filtering: dim results while the new set loads. */
.mlsg-gb-wrap.is-loading .mlsg-gb-results {
	opacity: 0.5;
	transition: opacity 0.15s ease;
	pointer-events: none;
}
