/*
 * JZ iMotor Stock – listing (templates/listing.php + assets/stock.js). Card styles are in card.css.
 * Layout from Figma "Frame 38" (1920px): 341px filter column, 64px gap, 3 columns of 399px cards.
 * Filter panels follow the dealer's iMotor site. Everything is scoped to .jz-stock.
 */

.jz-stock {
	--s-blue: var(--jz-blue, #1456ab);
	--s-ink: var(--jz-ink, #050b20);
	--s-text: #1d1d1f;
	--s-muted: #6b6b70;
	--s-line: #e3e3e8;
	--s-panel: rgba(0, 0, 0, 0.04);
	--s-ui: var(--jz-font-ui, "DM Sans", sans-serif);

	display: grid;
	grid-template-columns: 341px minmax(0, 1fr);
	gap: 64px;
	align-items: start;
	padding-block: 50px 40px;
	color: var(--s-text);
	font-size: 16px;
	line-height: 1.5;
}

.jz-stock *,
.jz-stock *::before,
.jz-stock *::after {
	box-sizing: border-box;
}

/* Undo WoodMart's global form/button/heading styles inside our scope. */
.jz-stock button,
.jz-stock input,
.jz-stock select {
	min-height: 0;
	margin: 0;
	box-shadow: none;
	color: inherit;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
}

.jz-stock button {
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	line-height: inherit;
	cursor: pointer;
}

.jz-stock button:hover,
.jz-stock button:focus {
	background: none;
	color: inherit;
}

.jz-stock :is(h2, h3) {
	margin: 0;
	color: inherit;
	font-family: inherit;
	font-weight: 400;
	letter-spacing: normal;
	text-transform: none;
}

.jz-stock p {
	margin: 0;
}

.jz-stock svg {
	width: 1em;
	height: 1em;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.6;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.jz-stock :is(a, button, input, select, label):focus-visible {
	outline: 2px solid var(--s-blue);
	outline-offset: 2px;
}

.jz-stock [hidden] {
	display: none !important;
}

/* ------------------------------------------------------------------ */
/* Filter column                                                       */
/* ------------------------------------------------------------------ */

.jz-filter {
	padding: 25px 24px 28px;
	border-radius: 11px;
	background: var(--s-panel);
	font-family: var(--s-ui);
}

.jz-filter__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 18px;
}

.jz-stock .jz-filter__head h2 {
	color: #000;
	font-family: var(--s-ui);
	font-size: 24px;
	font-weight: 500;
}

.jz-stock .jz-filter__clear {
	color: var(--s-blue);
	font-size: 14px;
	text-decoration: underline;
}

.jz-stock .jz-filter__clear:hover {
	color: var(--s-ink);
}

.jz-stock .jz-filter__close {
	display: none;
	font-size: 30px;
	line-height: 1;
}

/* Panel */
.jz-fpanel {
	margin-bottom: 12px;
	border: 1px solid var(--s-line);
	border-radius: 8px;
	background: #fff;
}

.jz-stock .jz-fpanel__heading {
	font-size: 16px;
}

.jz-stock .jz-fpanel__head {
	display: flex;
	width: 100%;
	align-items: center;
	gap: 12px;
	padding: 15px 16px;
	color: #000;
	font-family: var(--s-ui);
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	text-align: left;
}

.jz-fpanel__icon {
	display: inline-grid;
	color: #000;
	font-size: 21px;
}

.jz-fpanel__icon svg {
	stroke-width: 2.1;
}

.jz-fpanel__label {
	flex: 1;
}

.jz-fpanel__active {
	min-width: 22px;
	padding: 1px 7px;
	border-radius: 11px;
	background: var(--s-blue);
	color: #fff;
	font-size: 12px;
	line-height: 18px;
	text-align: center;
}

.jz-fpanel__chev {
	display: inline-grid;
	color: #555;
	font-size: 18px;
	transition: transform 0.2s;
}

.jz-fpanel.is-open .jz-fpanel__chev {
	transform: rotate(90deg);
}

.jz-fpanel__body {
	padding: 4px 16px 16px;
	border-top: 1px solid var(--s-line);
}

.jz-fsub + .jz-fsub {
	margin-top: 6px;
}

.jz-stock .jz-fsub__label {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 4px 10px;
	margin: 12px 0 8px;
	color: #000;
	font-size: 15px;
	font-weight: 500;
}

/* Keyword */
.jz-search {
	margin: 12px 0 0;
}

.jz-stock .jz-search input {
	box-sizing: border-box; /* normalize.css sets search inputs to content-box */
	width: 100%;
	height: 42px;
	-webkit-appearance: none;
	appearance: none;
	padding: 0 12px;
	border: 1px solid #cfcfd6;
	border-radius: 6px;
	background: #fff;
	font-size: 15px;
}

.jz-stock .jz-search input:focus {
	border-color: var(--s-blue);
	outline: none;
}

/* Checkbox lists */
.jz-options--list {
	display: grid;
	gap: 2px;
}

.jz-stock .jz-check {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 5px 0;
	color: #222;
	font-size: 15px;
	font-weight: 300;
	line-height: 1.3;
	cursor: pointer;
}

.jz-stock .jz-check input {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	accent-color: var(--s-blue);
	cursor: pointer;
}

.jz-check__label {
	flex: 1;
	min-width: 0;
}

.jz-check:hover .jz-check__label {
	color: var(--s-blue);
}

.jz-count {
	min-width: 26px;
	padding: 1px 7px;
	border-radius: 4px;
	background: #f0f0f3;
	color: #444;
	font-size: 12px;
	font-style: normal;
	font-weight: 400;
	line-height: 18px;
	text-align: center;
}

.jz-stock .jz-more {
	justify-self: start;
	margin-top: 6px;
	color: var(--s-blue);
	font-size: 14px;
	text-decoration: underline;
}

/* Chips (body type, seats) */
.jz-options--chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.jz-stock .jz-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 10px 7px 12px;
	border: 1px solid #c9c9cf;
	border-radius: 5px;
	background: #fff;
	font-size: 14px;
	line-height: 1.2;
	transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.jz-stock .jz-chip:hover {
	border-color: var(--s-blue);
	background: #fff;
	color: var(--s-blue);
}

.jz-stock .jz-chip.is-on,
.jz-stock .jz-chip.is-on:hover {
	border-color: var(--s-blue);
	background: var(--s-blue);
	color: #fff;
}

.jz-chip.is-on .jz-count {
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
}

/* Range sliders (two overlaid native inputs; keyboard and screen-reader friendly) */
.jz-range__value {
	color: var(--s-muted);
	font-size: 14px;
	font-weight: 400;
}

.jz-range__track {
	position: relative;
	height: 26px;
	margin: 2px 9px 8px;
}

.jz-range__track::before,
.jz-range__fill {
	content: "";
	position: absolute;
	top: 50%;
	height: 4px;
	margin-top: -2px;
	border-radius: 2px;
}

.jz-range__track::before {
	right: -9px;
	left: -9px;
	background: #dcdce1;
}

.jz-range__fill {
	background: var(--s-blue);
}

.jz-stock .jz-range input[type="range"] {
	position: absolute;
	top: 0;
	left: -9px;
	width: calc(100% + 18px);
	height: 26px;
	padding: 0;
	border: 0;
	background: none;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
}

.jz-range input[type="range"]::-webkit-slider-runnable-track {
	height: 4px;
	background: none;
}

.jz-range input[type="range"]::-moz-range-track {
	height: 4px;
	background: none;
}

.jz-range input[type="range"]::-webkit-slider-thumb {
	width: 18px;
	height: 18px;
	margin-top: -7px;
	border: 2px solid var(--s-blue);
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	pointer-events: auto;
	-webkit-appearance: none;
}

.jz-range input[type="range"]::-moz-range-thumb {
	width: 14px;
	height: 14px;
	border: 2px solid var(--s-blue);
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	pointer-events: auto;
}

.jz-range input[type="range"]:disabled {
	opacity: 0.5;
}

.jz-range input[type="range"]:focus-visible {
	outline: none;
}

.jz-range input[type="range"]:focus-visible::-webkit-slider-thumb {
	box-shadow: 0 0 0 4px rgba(20, 86, 171, 0.3);
}

/* Budget */
.jz-budget__row {
	display: grid;
	grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); /* room for "Deposit / Trade-in" on one line */
	gap: 10px;
}

.jz-budget__row .jz-budget__field > span:first-child {
	white-space: nowrap;
}

.jz-stock .jz-budget__field {
	display: grid;
	gap: 4px;
	margin: 0 0 10px;
	color: var(--s-muted);
	font-size: 13px;
	font-weight: 400;
}

.jz-budget__money {
	position: relative;
	display: block;
}

.jz-budget__money::before {
	content: "$";
	position: absolute;
	top: 50%;
	left: 11px;
	color: var(--s-muted);
	transform: translateY(-50%);
}

/* "I can afford $170" slider (one thumb on the range track above) */
.jz-stock .jz-budget__afford-label {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	margin: 0 0 2px;
	color: var(--s-muted);
	font-size: 13px;
}

.jz-stock .jz-budget__afford-label label {
	margin: 0;
	color: inherit;
	font-size: inherit;
	font-weight: 400;
}

.jz-budget__afford-label output {
	color: var(--s-blue);
	font-size: 18px;
	font-weight: 600;
}

.jz-budget__afford .jz-range__fill {
	left: 0;
}

.jz-stock .jz-budget__afford input[type="range"] {
	pointer-events: auto; /* one thumb: the whole track is clickable */
	cursor: pointer;
}

.jz-budget__afford {
	margin-bottom: 8px;
}

/* Dropdown filters: Body Type, Transmission */
.jz-stock .jz-fsub label.jz-fsub__label {
	display: block;
}

.jz-fselect {
	display: block;
}

.jz-stock .jz-budget input:not([type="range"]),
.jz-stock .jz-budget select,
.jz-stock .jz-fselect select {
	box-sizing: border-box;
	width: 100%;
	height: 40px;
	padding: 0 10px;
	border: 1px solid #cfcfd6;
	border-radius: 6px;
	background-color: #fff;
	color: #222;
	font-size: 15px;
}

.jz-stock .jz-budget__money input {
	padding-left: 24px;
}

.jz-budget__result {
	margin: 2px 0 10px !important;
	color: var(--s-blue);
	font-size: 14px;
}

.jz-budget__actions {
	display: flex;
	gap: 8px;
}

.jz-stock .jz-btn {
	flex: 1;
	padding: 10px 12px;
	border: 1px solid var(--s-blue);
	border-radius: 5px;
	background: var(--s-blue);
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.2;
	text-align: center;
}

.jz-stock .jz-btn:hover {
	border-color: #0f4288;
	background: #0f4288;
	color: #fff;
}

.jz-stock .jz-btn--ghost {
	flex: 0 0 auto;
	background: #fff;
	color: var(--s-blue);
}

.jz-stock .jz-btn--ghost:hover {
	background: #fff;
	color: var(--s-ink);
}

.jz-budget__note {
	margin-top: 10px !important;
	color: var(--s-muted);
	font-size: 12px;
	line-height: 1.5;
}

/* ------------------------------------------------------------------ */
/* Toolbar                                                             */
/* ------------------------------------------------------------------ */

.jz-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 24px;
	margin: 18px 0 34px;
}

.jz-stock .jz-toolbar__filters {
	display: none;
	padding: 9px 18px;
	border: 1px solid var(--s-line);
	border-radius: 6px;
	background: #fff;
	font-family: var(--s-ui);
	font-size: 15px;
	font-weight: 500;
}

.jz-stock .jz-sort {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	color: #000;
	font-size: 20px;
	font-weight: 400;
}

.jz-stock .jz-sort select {
	width: auto;
	min-width: 150px;
	height: auto;
	padding: 2px 22px 4px 2px;
	border: 0;
	border-bottom: 1px solid #000;
	border-radius: 0;
	background-color: transparent;
	color: #606060;
	font-size: 17px;
	cursor: pointer;
}

.jz-toolbar__count {
	color: var(--s-muted);
	font-size: 16px;
}

/* Styled dropdown lists for Sort by, budget "Per", Body Type and Transmission
   (customisable <select>; other browsers keep native). */
@supports (appearance: base-select) {
	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) select,
	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) select::picker(select) {
		appearance: base-select;
	}

	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) select {
		display: inline-flex;
		align-items: center;
		justify-content: space-between;
		gap: 10px;
		background-image: none; /* WoodMart's arrow; the picker icon below is the only arrow */
	}

	.jz-stock .jz-sort select {
		width: auto;
		min-width: 0;
		padding-right: 2px;
		field-sizing: content; /* as wide as the chosen option ("Newest listings"), plus the arrow */
	}

	.jz-stock :is(.jz-budget, .jz-fselect) select {
		width: 100%;
	}

	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) select::picker-icon {
		color: #888;
		transition: rotate 0.2s;
	}

	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) select:open::picker-icon {
		rotate: 180deg;
	}

	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) select::picker(select) {
		/* Below the field unless it doesn't fit (Chrome's default picks whichever side is bigger). */
		position-area: block-end span-inline-end;
		position-try-order: normal;
		position-try-fallbacks: flip-block;
		min-width: anchor-size(width);
		max-height: min(340px, 45vh);
		margin-top: 8px;
		padding: 6px;
		border: 1px solid var(--s-line);
		border-radius: 8px;
		background: #fff;
		box-shadow: 0 14px 34px rgba(5, 11, 32, 0.16);
	}

	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) option {
		padding: 9px 12px;
		border-radius: 5px;
		color: #000;
		font-family: var(--s-ui);
		font-size: 15px;
		cursor: pointer;
	}

	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) option::checkmark {
		display: none;
	}

	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) option:hover,
	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) option:focus-visible {
		outline: none;
		background: rgba(20, 86, 171, 0.08);
		color: var(--s-blue);
	}

	.jz-stock :is(.jz-sort, .jz-budget, .jz-fselect) option:checked {
		background: var(--s-blue);
		color: #fff;
	}
}

.jz-view {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-left: auto;
	font-size: 21px;
}

.jz-stock .jz-view button {
	display: inline-grid;
	padding: 3px;
	color: #bbb;
}

.jz-stock .jz-view button:hover,
.jz-stock .jz-view button.is-active {
	color: #000;
}

.jz-view svg {
	width: 14px;
	height: 14px;
	fill: currentColor;
	stroke: none;
}

/* ------------------------------------------------------------------ */
/* Results grid                                                        */
/* ------------------------------------------------------------------ */

.jz-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 45px 22px;
	transition: opacity 0.2s;
}

/* Saved cars (?saved=1, the header "Wishlist" link): no filter column or sorting, 4 cards across */
.jz-stock.jz-stock--saved {
	grid-template-columns: minmax(0, 1fr);
}

.jz-stock--saved :is(.jz-filter, .jz-sort, .jz-toolbar__filters, .jz-view, .jz-filter__backdrop) {
	display: none !important;
}

.jz-stock--saved .jz-grid {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

.jz-stock .jz-saved-back {
	color: var(--s-blue);
	font-family: var(--s-ui);
	font-size: 16px;
	font-weight: 500;
	text-decoration: none;
}

.jz-stock .jz-saved-back:hover {
	text-decoration: underline;
}

@media (max-width: 1200px) {
	.jz-stock--saved .jz-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 900px) {
	.jz-stock--saved .jz-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.jz-stock--saved .jz-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

.jz-grid.is-loading {
	opacity: 0.45;
	pointer-events: none;
}

/* List view */
.jz-grid--list {
	grid-template-columns: minmax(0, 1fr);
	gap: 20px;
}

.jz-grid--list .jz-card {
	flex-direction: row;
}

.jz-grid--list .jz-card__media {
	width: 40%;
	max-width: 420px;
	flex-shrink: 0;
	aspect-ratio: auto;
	min-height: 240px;
}

.jz-grid--list .jz-card__badge {
	right: auto;
	left: 20px;
}

.jz-grid--list .jz-card .jz-card__fav {
	top: 20px;
	right: 20px;
}

.jz-grid--list .jz-card__body {
	padding: 26px 30px;
}

.jz-grid--list .jz-card__specs {
	max-width: 440px;
}

.jz-state {
	grid-column: 1 / -1;
	padding: 60px 16px;
	border-radius: 11px;
	background: var(--s-panel);
	color: var(--s-muted);
	font-size: 18px;
	text-align: center;
}

.jz-stock .jz-link {
	color: var(--s-blue);
	text-decoration: underline;
}

/* Pagination: 1 2 ③ 4 5 …… 15 */
.jz-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 60px;
	font-size: 16px;
}

.jz-stock .jz-pagination button {
	min-width: 28px;
	height: 28px;
	padding: 0 6px;
	border-radius: 14px;
	color: #000;
}

.jz-stock .jz-pagination button:hover {
	background: var(--s-panel);
	color: #000;
}

.jz-stock .jz-pagination button:disabled {
	color: #c4c4c4;
	cursor: default;
}

.jz-stock .jz-pagination button.is-current {
	background: #000;
	color: #fff;
}

.jz-gap {
	color: #000;
	letter-spacing: -1px;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 1440px) {
	.jz-stock {
		grid-template-columns: 300px minmax(0, 1fr);
		gap: 40px;
	}

	.jz-grid {
		gap: 32px 18px;
	}
}

@media (max-width: 1200px) {
	.jz-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Tablet and phone: filters become an off-canvas drawer. */
@media (max-width: 900px) {
	.jz-stock {
		grid-template-columns: minmax(0, 1fr);
		padding-top: 24px;
	}

	.jz-filter {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		z-index: 100000;
		width: min(360px, 88vw);
		overflow-y: auto;
		border-radius: 0;
		background: #f5f5f5;
		box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
		transform: translateX(-105%);
		transition: transform 0.25s;
	}

	.jz-filter.is-open {
		transform: none;
	}

	.jz-stock .jz-filter__close {
		display: block;
	}

	.jz-filter__backdrop {
		position: fixed;
		inset: 0;
		z-index: 99999;
		background: rgba(0, 0, 0, 0.4);
	}

	.jz-stock .jz-toolbar__filters {
		display: inline-block;
	}

	.jz-toolbar {
		margin-top: 0;
	}

	.jz-stock .jz-sort {
		font-size: 16px;
	}

	.jz-stock .jz-sort select {
		min-width: 0;
		font-size: 15px;
	}

	.jz-toolbar__count {
		order: 5;
		width: 100%;
		font-size: 14px;
	}

	.jz-grid--list .jz-card {
		flex-direction: column;
	}

	.jz-grid--list .jz-card__media {
		width: 100%;
		max-width: none;
		min-height: 0;
		aspect-ratio: 399 / 260;
	}

	.jz-grid--list .jz-card__badge {
		right: 30px;
		left: auto;
	}

	.jz-grid--list .jz-card .jz-card__fav {
		top: 21px;
		right: 30px;
	}
}

@media (max-width: 600px) {
	.jz-grid {
		grid-template-columns: minmax(0, 1fr);
		gap: 22px;
	}

	.jz-view {
		display: none;
	}
}

html.jz-no-scroll {
	overflow: hidden;
}
