/* Payment Estimator dialog ------------------------------------------------- */
/* Brand: Dream Nissan red #c3002f used as the single accent (values, active
   states, sliders, primary action). Everything else stays quiet neutral.
   Money figures use tabular-nums so digits don't jiggle as sliders move. */

#payment-estimator-dialog.pe-dialog {
	border: none;
	border-radius: 16px;
	padding: 0;
	width: min(900px, 95vw);
	max-width: 900px;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
	background: #fff;
	color: #111827;
	font-family: inherit;
}

#payment-estimator-dialog.pe-dialog::backdrop {
	background: rgba(17, 24, 39, 0.55);
}

.pe-dialog .pe-close-form {
	position: absolute;
	top: 10px;
	right: 12px;
	margin: 0;
}

.pe-dialog .pe-close {
	background: transparent;
	border: none;
	font-size: 26px;
	line-height: 1;
	color: #9ca3af;
	cursor: pointer;
	padding: 2px 8px;
	border-radius: 6px;
}

.pe-dialog .pe-close:hover {
	color: #4b5563;
}

.pe-dialog .pe-close:focus {
	outline: none;
}

.pe-dialog .pe-wrap {
	padding: 34px 38px 24px;
}

.pe-dialog .pe-wrap:focus {
	outline: none;
}

.pe-dialog .pe-title {
	text-align: center;
	font-size: 1.6rem;
	font-weight: 800;
	letter-spacing: -0.01em;
	margin: 0 0 4px;
	color: #0f172a;
}

.pe-dialog .pe-subtitle {
	text-align: center;
	color: #6b7280;
	font-size: 0.88rem;
	margin: 0 auto 26px;
	max-width: 430px;
	line-height: 1.45;
}

.pe-dialog .pe-card {
	background: transparent;
	border-radius: 0;
	padding: 0;
	box-shadow: none;
}

/* Tabs */
.pe-dialog .pe-tabs {
	display: flex;
	background: #f1f2f4;
	border-radius: 10px;
	padding: 4px;
	max-width: 360px;
	margin: 0 auto 24px;
}

.pe-dialog .pe-tab {
	flex: 1;
	background: transparent;
	border: none;
	padding: 0.7em 0;
	font-weight: 700;
	font-size: 0.95rem;
	color: #6b7280;
	cursor: pointer;
	border-radius: 7px;
}

.pe-dialog .pe-tab.is-active {
	background: #fff;
	color: #c3002f;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* Body layout */
.pe-dialog .pe-body {
	display: grid;
	grid-template-columns: 1fr 310px;
	gap: 30px;
}

.pe-dialog .pe-inputs {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.pe-dialog .pe-field {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.pe-dialog .pe-label-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.pe-dialog .pe-label {
	font-weight: 600;
	font-size: 0.92rem;
	color: #1f2937;
	/* The theme puts margin-bottom:-10px on labels, which throws off the flex
	   centering of the residual "?" next to the label text. Zero it out. */
	margin: 0;
}

.pe-dialog .pe-num {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	background: #f3f4f6;
	border: 1px solid #e5e7eb;
	border-radius: 7px;
	padding: 4px 8px;
	font-weight: 700;
	font-size: 0.92rem;
	min-width: 86px;
	justify-content: flex-end;
}

.pe-dialog .pe-num input {
	border: none;
	background: transparent;
	width: 70px;
	text-align: right;
	font-weight: 700;
	font-size: 0.92rem;
	padding: 0;
	color: #111827;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
	-moz-appearance: textfield;
}

.pe-dialog .pe-num input::-webkit-outer-spin-button,
.pe-dialog .pe-num input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* Internet Price: a fixed anchor stat, not an editable field */
.pe-dialog .pe-field--static {
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	background: #fafafa;
	border: 1px solid #eef0f2;
	border-radius: 10px;
	padding: 14px 16px;
}

.pe-dialog .pe-field--static .pe-label {
	margin: 0;
	color: #6b7280;
}

.pe-dialog .pe-price-display {
	background: transparent;
	border: none;
	padding: 0;
	text-align: right;
}

.pe-dialog .pe-price-value {
	font-weight: 800;
	font-size: 1.4rem;
	color: #c3002f;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}

/* Range sliders - minimalist iOS-style. The input gets a tall hit area so the
   knob is never clipped (a short 4px-tall input cropped the round thumb to a
   sliver). The thin visible track lives on the runnable-track pseudo and is
   filled with brand red up to --pe-fill (a 0-100% length set by fillRange in
   the JS). The white knob is lifted by a hairline ring + soft shadow so it
   reads as a handle on top of the track. */
.pe-dialog input[type="range"] {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 20px;
	margin: 0;
	background: transparent;
	outline: none;
	cursor: pointer;
}

.pe-dialog input[type="range"]::-webkit-slider-runnable-track {
	height: 4px;
	border-radius: 999px;
	background: linear-gradient(90deg, #c3002f 0%, #c3002f var(--pe-fill, 0%), #e5e7eb var(--pe-fill, 0%), #e5e7eb 100%);
}

.pe-dialog input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	width: 16px;
	height: 16px;
	margin-top: -6px;
	border-radius: 50%;
	background: #fff;
	cursor: pointer;
	border: none;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.3);
}

.pe-dialog input[type="range"]::-moz-range-track {
	height: 4px;
	border-radius: 999px;
	background: linear-gradient(90deg, #c3002f 0%, #c3002f var(--pe-fill, 0%), #e5e7eb var(--pe-fill, 0%), #e5e7eb 100%);
}

.pe-dialog input[type="range"]::-moz-range-thumb {
	box-sizing: border-box;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	cursor: pointer;
	border: none;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Term chips */
.pe-dialog .pe-terms {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.pe-dialog .pe-term-chip {
	flex: 1 1 auto;
	min-width: 58px;
	background: #fff;
	border: 1px solid #d1d5db;
	border-radius: 22px;
	padding: 0.5em 0.6em;
	font-weight: 600;
	font-size: 0.85rem;
	color: #374151;
	cursor: pointer;
	transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.pe-dialog .pe-term-chip:hover {
	border-color: #c3002f;
	color: #c3002f;
}

.pe-dialog .pe-term-chip.is-active {
	background: #c3002f;
	border-color: #c3002f;
	color: #fff;
}

.pe-dialog .pe-term-chip.is-active:hover {
	color: #fff;
}

.pe-dialog .pe-term-display {
	font-weight: 700;
	color: #1f2937;
	font-size: 0.9rem;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}

.pe-dialog .pe-label-with-help {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

/* Tighten the label line box to the glyphs so the "?" centers on the visible
   text, not on the taller line-height:normal box. */
.pe-dialog .pe-label-with-help .pe-label {
	line-height: 1;
}

.pe-dialog .pe-help-wrap {
	position: relative;
	display: inline-flex;
}

.pe-dialog .pe-help {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: #9ca3af;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
}

.pe-dialog .pe-help:hover,
.pe-dialog .pe-help:focus-visible {
	background: #c3002f;
}

/* Explanation bubble - shows on hover and on focus/tap (button is focusable). */
.pe-dialog .pe-tip {
	position: absolute;
	bottom: calc(100% + 9px);
	left: -8px;
	width: 232px;
	max-width: 60vw;
	background: #0f172a;
	color: #fff;
	font-size: 0.72rem;
	font-weight: 500;
	line-height: 1.45;
	text-align: left;
	letter-spacing: 0;
	padding: 9px 11px;
	border-radius: 8px;
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
	opacity: 0;
	visibility: hidden;
	transform: translateY(3px);
	transition: opacity 0.15s ease, transform 0.15s ease;
	z-index: 5;
	pointer-events: none;
}

.pe-dialog .pe-tip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 13px;
	border: 6px solid transparent;
	border-top-color: #0f172a;
}

.pe-dialog .pe-help-wrap:hover .pe-tip,
.pe-dialog .pe-help-wrap:focus-within .pe-tip {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* Output panel - light, with the monthly payment as the hero */
.pe-dialog .pe-output {
	background: #f8f9fb;
	border: 1px solid #eceef2;
	border-radius: 12px;
	padding: 24px;
	display: flex;
	flex-direction: column;
}

.pe-dialog .pe-out-label {
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	color: #6b7280;
	margin-bottom: 4px;
}

.pe-dialog .pe-monthly {
	font-weight: 800;
	color: #0f172a;
	line-height: 1;
	margin-bottom: 14px;
}

.pe-dialog .pe-monthly .pe-dollar {
	font-size: 1.25rem;
	color: #c3002f;
	vertical-align: top;
}

.pe-dialog .pe-monthly #pe-monthly {
	font-size: 2.3rem;
	letter-spacing: -0.01em;
	color: #0f172a;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}

.pe-dialog .pe-monthly .pe-per {
	font-size: 0.9rem;
	color: #6b7280;
	font-weight: 600;
}

.pe-dialog .pe-breakdown {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px 10px;
	margin: 0 0 16px;
	padding: 14px 0 0;
	border-top: 1px solid #e5e7eb;
}

.pe-dialog .pe-breakdown dt {
	color: #6b7280;
	font-size: 0.85rem;
}

.pe-dialog .pe-breakdown dd {
	margin: 0;
	text-align: right;
	font-weight: 700;
	font-size: 0.88rem;
	color: #111827;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}

.pe-dialog .pe-breakdown dt:last-of-type,
.pe-dialog .pe-breakdown dd:last-of-type {
	font-weight: 800;
}

.pe-dialog .pe-approve {
	margin-top: auto;
	display: block;
	text-align: center;
	background: #c3002f;
	color: #fff;
	font-weight: 700;
	text-decoration: none;
	padding: 0.9em 1em;
	border-radius: 10px;
	transition: background 0.15s ease, transform 0.12s ease;
}

.pe-dialog .pe-approve:hover {
	background: #a30028;
	transform: translateY(-1px);
}

.pe-dialog .pe-disclaimer {
	text-align: center;
	color: #9ca3af;
	font-size: 0.72rem;
	line-height: 1.4;
	margin: 14px auto 0;
	max-width: 560px;
}

/* Keyboard focus (quality floor) */
.pe-dialog .pe-tab:focus-visible,
.pe-dialog .pe-term-chip:focus-visible,
.pe-dialog .pe-approve:focus-visible,
.pe-dialog .pe-close:focus-visible,
.pe-dialog input:focus-visible {
	outline: 2px solid #c3002f;
	outline-offset: 2px;
}

/* Lease-only fields hidden in finance mode */
.pe-dialog .pe-lease-only {
	display: none;
}

.pe-dialog.pe-is-lease .pe-lease-only {
	display: flex;
}

@media (max-width: 640px) {
	.pe-dialog .pe-wrap {
		padding: 24px 20px 16px;
	}
	.pe-dialog .pe-body {
		grid-template-columns: 1fr;
	}
	.pe-dialog .pe-title {
		font-size: 1.3rem;
	}
	.pe-dialog .pe-subtitle {
		font-size: 0.84rem;
		margin-bottom: 18px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pe-dialog .pe-term-chip,
	.pe-dialog .pe-approve {
		transition: none;
	}
}
