/**
 * WLRE Theme — Mobile Search Filters Bottom-Sheet.
 *
 * Figma: 6113-117552 (initial), 6113-117705 (dirty state), 6113-118158,
 * 6113-118312.
 *
 * Custom-built sheet (not a native <dialog>) because we need fine control
 * over scroll lock, focus handling, and a scrim that stays below the sheet
 * while taps on the scrim dismiss it.
 */

.wlre-search-sheet {
	position: fixed;
	inset: 0;
	z-index: 1100; /* above header (100), bottom nav (90), FAB (80). */
	display: none;
}

.wlre-search-sheet[aria-hidden="false"] {
	display: block;
}

.wlre-search-sheet__scrim {
	position: absolute;
	inset: 0;
	/* Figma 6113-117556 — very dark navy overlay at 96% opacity. */
	background: rgba(10, 36, 56, 0.96);
	opacity: 0;
	transition: opacity 0.22s ease;
	cursor: pointer;
}

.wlre-search-sheet[aria-hidden="false"] .wlre-search-sheet__scrim {
	opacity: 1;
}

.wlre-search-sheet__panel {
	position: absolute;
	inset-inline: 0;
	inset-block-end: 0;
	max-height: 82vh;
	background: var(--wlre-color-white);
	border-top-left-radius: var(--wlre-radius-20);
	border-top-right-radius: var(--wlre-radius-20);
	box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
	display: flex;
	flex-direction: column;
	outline: none;
	transform: translateY(100%);
	transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.wlre-search-sheet[aria-hidden="false"] .wlre-search-sheet__panel {
	transform: translateY(0);
}

.wlre-search-sheet__grabber {
	flex-shrink: 0;
	align-self: center;
	width: 60px;
	height: 6px;
	margin: var(--wlre-space-12) 0;
	background: var(--wlre-color-neutral-400);
	border: 0;
	border-radius: 20px;
	padding: 0;
	cursor: pointer;
}

.wlre-search-sheet__header {
	flex-shrink: 0;
	padding: var(--wlre-space-4) var(--wlre-space-16) var(--wlre-space-16);
}

.wlre-search-sheet__title {
	margin: 0;
	color: var(--wlre-color-text-900);
	font-size: 20px;
	text-align: center;
}

.wlre-search-sheet__form {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: var(--wlre-space-16) var(--wlre-space-16) var(--wlre-space-24);
	display: flex;
	flex-direction: column;
	gap: var(--wlre-space-24);
}

/* === Buy/Rent toggle — Figma 6717:436928 ================================= */
.wlre-search-sheet__toggle {
	display: flex;
	gap: 2px;
	background: #f5f5f5;
	border: 0.5px solid var(--wlre-color-neutral-400);
	border-radius: 48px;
	padding: var(--wlre-space-4);
	width: 100%;
	box-sizing: border-box;
}

.wlre-search-sheet__toggle-btn {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 32px;
	border: 1.5px solid transparent;
	border-radius: 32px;
	background: transparent;
	color: var(--wlre-color-text-900);
	font-family: var(--wlre-font-body);
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	outline: none;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wlre-search-sheet__toggle-btn.is-active {
	border-color: var(--wlre-color-teal-700);
	background: #f3faf4;
}

/* === Filter groups =================================================== */
.wlre-search-sheet__group {
	display: flex;
	flex-direction: column;
	gap: var(--wlre-space-12);
	padding-block: var(--wlre-space-12);
}

.wlre-search-sheet__group + .wlre-search-sheet__group {
	border-block-start: 0.5px solid var(--wlre-color-neutral-400);
}

.wlre-search-sheet__group-title {
	margin: 0;
	font-family: var(--wlre-font-body);
	font-weight: 700;
	font-size: var(--wlre-font-size-m); /* 14px — Figma 6717:436932 Label M Bold */
	color: var(--wlre-color-text-900);
}

.wlre-search-sheet__group-unit {
	color: var(--wlre-color-neutral-600);
	font-weight: 400;
}

/* === Chip rows ======================================================= */
.wlre-search-sheet__chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wlre-space-12);
}

/* Restore [hidden] behaviour — display:flex above overrides the UA stylesheet. */
.wlre-search-sheet__chips[hidden] {
	display: none;
}

.wlre-search-sheet__chip {
	height: 28px;
	padding: var(--wlre-space-4) var(--wlre-space-20);
	background: transparent;
	color: var(--wlre-color-text-900);
	border: 0.5px solid var(--wlre-color-neutral-400);
	border-radius: 52px;
	font-family: var(--wlre-font-body);
	font-size: var(--wlre-font-size-s); /* 12px — Figma 6717:436933 Body S */
	font-weight: 400;
	cursor: pointer;
	outline: none;
	-webkit-tap-highlight-color: transparent;
	white-space: nowrap;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wlre-search-sheet__chip[aria-pressed="true"],
.wlre-search-sheet__chip.is-active {
	border: 1.5px solid var(--wlre-color-teal-700);
	background: linear-gradient(90deg, rgba(129, 216, 208, 0.12) 0%, rgba(129, 216, 208, 0.12) 100%), var(--wlre-color-white);
	font-weight: 700;
}

/* === Range (dual-knob) =============================================== */
.wlre-search-sheet__range {
	position: relative;
	height: 28px;
	padding: var(--wlre-space-12) 0;
	display: flex;
	align-items: center;
}

.wlre-search-sheet__range-track {
	position: absolute;
	inset-inline: 0;
	height: 2px;
	background: var(--wlre-color-neutral-400);
	border-radius: 2px;
}

.wlre-search-sheet__range-fill {
	position: absolute;
	height: 100%;
	background: var(--wlre-color-text-900);
	border-radius: 2px;
}

.wlre-search-sheet__range input[type="range"] {
	position: absolute;
	inset-inline: 0;
	width: 100%;
	height: 28px;
	background: transparent;
	pointer-events: none; /* individual thumbs get pointer events */
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
}

/* Thumbs — 28×28 white circles with 0.5px neutral-3 border. */
.wlre-search-sheet__range input[type="range"]::-webkit-slider-thumb {
	pointer-events: auto;
	-webkit-appearance: none;
	appearance: none;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--wlre-color-white);
	border: 0.5px solid var(--wlre-color-neutral-400);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.15);
	cursor: pointer;
}

.wlre-search-sheet__range input[type="range"]::-moz-range-thumb {
	pointer-events: auto;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--wlre-color-white);
	border: 0.5px solid var(--wlre-color-neutral-400);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.15);
	cursor: pointer;
}

.wlre-search-sheet__range input[type="range"]::-webkit-slider-runnable-track {
	background: transparent;
}

/* Min/max bound labels below the track — Figma 6717:436962. */
.wlre-search-sheet__range-bounds {
	display: flex;
	justify-content: space-between;
	margin-block-start: var(--wlre-space-4);
	font-family: var(--wlre-font-body);
	font-weight: 400;
	font-size: var(--wlre-font-size-s); /* 12px */
	line-height: 1.48;
	color: var(--wlre-color-text-900);
	white-space: nowrap;
}

.wlre-search-sheet__range-inputs {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--wlre-space-12);
	margin-block-start: var(--wlre-space-16);
}

.wlre-search-sheet__range-field {
	position: relative;
	display: block;
}

.wlre-search-sheet__range-field-label {
	position: absolute;
	top: -10.5px;
	inset-inline-start: 20px; /* Figma 6717:436966 — label sits 20px from left edge */
	background: var(--wlre-color-white);
	padding: 0 var(--wlre-space-4);
	font-family: var(--wlre-font-body);
	font-size: var(--wlre-font-size-s); /* 12px */
	color: var(--wlre-color-neutral-600);
	font-weight: 400;
}

.wlre-search-sheet__range-field .wlre-form__input {
	height: 52px;
	padding: 0 var(--wlre-space-24);
	border-radius: var(--wlre-radius-sm);
}

/* === Sticky footer =================================================== */
.wlre-search-sheet__footer {
	flex-shrink: 0;
	display: flex;
	gap: var(--wlre-space-12);
	padding: var(--wlre-space-8) var(--wlre-space-16) calc(var(--wlre-space-32) + env(safe-area-inset-bottom, 0));
	background: var(--wlre-color-white);
	box-shadow: 0 -4px 7px -1px rgba(99, 99, 99, 0.04);
}

.wlre-search-sheet__footer > .wlre-btn {
	flex: 1 1 0;
	min-width: 0;
	height: 56px;
}

/* Figma 6717:437009 — initial state shows only "Cerca" (Search) button;
 * Cancel is removed; Clear appears when filters are dirty. */
.wlre-search-sheet__cancel {
	display: none;
}

.wlre-search-sheet__clear {
	display: none;
}

.wlre-search-sheet.is-dirty .wlre-search-sheet__clear {
	display: inline-flex;
}

/* === Lock body scroll when sheet is open (set by JS on <html>). ==== */
/* === Full-screen panel — same UX as visit / mortgage form modals === */
.wlre-search-sheet__panel {
	max-height: 100dvh;
	border-top-left-radius: 0;
	border-top-right-radius: 0;
}

.wlre-search-sheet__grabber {
	display: none;
}

/* Header becomes a fixed 56px bar — title centered, X icon on the right.
 * A ::before pseudo-element mirrors the button width so the title stays
 * visually centered even with the button on only one side. */
.wlre-search-sheet__header {
	display: flex;
	align-items: center;
	height: 44px;
	padding: 0 var(--wlre-space-16);
	padding-block-start: 0;
	padding-block-end: 0;
	flex-shrink: 0;
}

.wlre-search-sheet__header::before {
	content: '';
	width: 36px;
	flex-shrink: 0;
}

.wlre-search-sheet__title {
	flex: 1;
	text-align: center;
}

.wlre-search-sheet__close {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: none;
	border: none;
	color: var(--wlre-color-text-900);
	cursor: pointer;
	padding: 0;
	font-family: var(--wlre-font-body);
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
}

.wlre-search-sheet__close svg {
	width: 24px;
	height: 24px;
}

html.wlre-search-sheet-open,
html.wlre-search-sheet-open body {
	overflow: hidden;
}
