/* Bauzinsrechner-Modal — Layout im Original-Stil von drklein.de
 * (Kachel-Grid + Nebenkosten-Sidebar + Feinabstimmung-Zeile).
 * Eigene bz-* Klassen, kollidieren nicht mit bestehenden modals.css. */

:root {
	--bz-gold: #ca9c51;
	--bz-gold-soft: #e6c178;
	--bz-gold-dark: #a4763a;
	--bz-teal: #244046;
	--bz-teal-soft: #2e5660;
	--bz-ink: #1b1b1c;
	--bz-ink-soft: #2d2d2f;
	--bz-line: rgba(255, 255, 255, 0.12);
	--bz-line-light: #e6dfcf;
	--bz-paper: #f1ecde;
	--bz-paper-2: #faf6ec;
	--bz-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.bz-modal {
	position: fixed;
	inset: 0;
	z-index: 10010;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: radial-gradient(
		120% 100% at 50% 0%,
		rgba(0, 0, 0, 0.55) 0%,
		rgba(0, 0, 0, 0.78) 100%
	);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	opacity: 0;
	animation: bzFadeIn 0.28s ease-out forwards;
	font-family:
		'Inter', system-ui, -apple-system, 'Segoe UI', Roboto,
		'Helvetica Neue', Arial, sans-serif;
}

.bz-modal.is-open {
	display: flex;
}

/* Host-Seite-Scroll sperren wenn Modal offen ist. Wir setzen
 * overflow:hidden auf <html> UND <body> (manche Browser scrollen
 * den html-Knoten, andere body — beides muss zu). Zusätzlich kommt
 * via JS eine padding-right-Kompensation auf <body>, damit das
 * Verschwinden der vertikalen Scrollbar keinen 17px-Sprung erzeugt. */
html.bz-modal-open,
body.bz-modal-open {
	overflow: hidden !important;
	touch-action: none;
}
body.bz-modal-open {
	padding-right: var(--bz-scrollbar-comp, 0px);
}

.bz-modal__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(1180px, 100%);
	max-height: 95vh;
	background: var(--bz-paper);
	border-radius: 20px;
	box-shadow: var(--bz-shadow);
	overflow: hidden;
	transform: translateY(12px) scale(0.985);
	animation: bzPopIn 0.32s cubic-bezier(0.2, 0.85, 0.25, 1) 0.04s forwards;
}

/* ── Floating Close (kein Header) ───────────────────────────────────────── */

.bz-modal__close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 36px;
	height: 36px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--bz-line-light);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	color: var(--bz-ink);
	cursor: pointer;
	transition: all 0.18s ease;
	font-family: inherit;
	z-index: 2;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.bz-modal__close:hover {
	background: #fff;
	border-color: var(--bz-gold);
	color: var(--bz-gold-dark);
	transform: rotate(90deg);
}

.bz-modal__close svg {
	width: 16px;
	height: 16px;
}

/* ── Schritte: Rechner / Anfrage ────────────────────────────────────────── */

.bz-modal__step {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
}

.bz-modal__step[hidden] {
	display: none;
}

/* Anfrage-Step: schrumpft auf Inhalt (iframe-Höhe + Back-Button), damit
 * der Dialog keine leere Fläche unter dem Wizard zeigt. Wird der Wizard
 * höher als der Dialog (z. B. PersönlicheDaten), greift overflow-y. */
.bz-modal__step--anfrage {
	flex-grow: 0 !important;
	flex-shrink: 1;
	flex-basis: auto;
	overflow-y: auto;
	/* Scrollbalken visuell ausblenden — der Step ist normalerweise
	 * genau so groß wie sein Inhalt (back-button + iframe). Sub-Pixel-
	 * Mismatches dürfen keinen sichtbaren Balken rechts erzeugen.
	 * Bei sehr großen Wizard-Schritten (höher als 95vh) ist Scrollen
	 * via Wheel/Tastatur trotzdem möglich. */
	scrollbar-width: none;
	-ms-overflow-style: none;
}
.bz-modal__step--anfrage::-webkit-scrollbar {
	width: 0;
	height: 0;
	display: none;
}

/* Wenn der Anfrage-Step aktiv ist, soll auch der Dialog selbst auf die
 * Höhe des Steps zusammenschrumpfen statt 95vh hoch zu bleiben. Wir
 * markieren das per JS via [data-anfrage-fit]. */
.bz-modal__dialog[data-anfrage-fit] {
	height: fit-content;
	max-height: 95vh;
}

/* ── Inline-Sektion (Wrapper auf der Seite) ─────────────────────────────── */
.bauzins-section {
	padding: 96px 24px;
	background: linear-gradient(180deg, transparent 0%, rgba(202, 156, 81, 0.05) 100%);
}
.bauzins-section .container {
	max-width: 1280px;
	margin: 0 auto;
}
.bauzins-section .section-header {
	text-align: center;
	margin-bottom: 40px;
}
.bauzins-section .section-header h2 {
	margin: 0 0 12px;
	font-size: 2rem;
	letter-spacing: 0.05em;
	color: var(--bz-ink);
	font-weight: 700;
}
.bauzins-section__intro {
	max-width: 720px;
	margin: 0 auto;
	color: var(--bz-ink-soft);
	font-size: 1rem;
	line-height: 1.6;
}
.bauzins-section__intro a {
	color: var(--bz-gold-dark);
	text-decoration: none;
	font-weight: 600;
}
.bauzins-section__intro a:hover {
	text-decoration: underline;
}
@media (max-width: 640px) {
	.bauzins-section { padding: 56px 16px; }
	.bauzins-section .section-header h2 { font-size: 1.5rem; }
}

/* ── Inline-Modus: Calc-Step lebt als Sektion auf der Seite ─────────────── */
.bz-inline-host {
	display: block;
	width: 100%;
	max-width: 1180px;
	margin: 0 auto;
	background: var(--bz-paper);
	border-radius: 24px;
	box-shadow: var(--bz-shadow);
	overflow: hidden;
	font-family:
		'Inter', system-ui, -apple-system, 'Segoe UI', Roboto,
		'Helvetica Neue', Arial, sans-serif;
}
.bz-inline-host .bz-modal__step {
	flex: 0 0 auto;
	display: block;
}
.bz-inline-host .bz-modal__content {
	padding: 40px 44px 36px;
	max-height: none;
	overflow: visible;
}
@media (max-width: 640px) {
	.bz-inline-host {
		border-radius: 16px;
	}
	.bz-inline-host .bz-modal__content {
		padding: 24px 18px 22px;
	}
}

/* ── Scrollbarer Hauptinhalt (Rechner) ──────────────────────────────────── */

.bz-modal__content {
	flex: 0 1 auto;
	overflow-y: auto;
	padding: 26px 28px 22px;
	background: var(--bz-paper);
}

/* ── Anfrage-Schritt: Back-Button + Iframe ──────────────────────────────── */

.bz-modal__back {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 14px 0 0 18px;
	padding: 8px 14px 8px 10px;
	border: 1px solid var(--bz-line-light);
	background: #fff;
	color: var(--bz-ink);
	border-radius: 999px;
	font-family: inherit;
	font-size: 0.85rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.18s ease;
	align-self: flex-start;
}

.bz-modal__back:hover {
	border-color: var(--bz-gold);
	color: var(--bz-gold-dark);
}

.bz-modal__back svg {
	width: 14px;
	height: 14px;
}

.bz-modal__anfrage-iframe {
	display: block;
	width: 100%;
	border: 0;
	margin-top: 12px;
	background: #fff;
	/* Höhe wird zur Laufzeit aus dem Wizard-Inhalt berechnet (siehe
	 * bauzins-modal.js → fitAnfrageIframe). Niedrige Mindesthöhe nur,
	 * damit beim Initial-Ladezustand etwas zu sehen ist; sobald die
	 * Messung läuft, wird sie via inline style.height überschrieben. */
	min-height: 200px;
}

.bz-section-title {
	text-align: center;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--bz-ink);
	margin: 0 0 16px;
	letter-spacing: -0.005em;
}

.bz-section-title--small {
	font-size: 0.95rem;
	margin-top: 28px;
	margin-bottom: 12px;
}

/* ── Kachelgrid: 2×2 (Eingaben oben, Akzent-Kacheln unten) ──────────────── */
/* Visuelle Hierarchie: erste Zeile = Eingaben (Sanierungskosten + EK),
 * zweite Zeile = berechnete Werte (Darlehen + Monatsrate, beide gold).
 * Optionale Forward-Tiles (.bz-form__zweck) sind per default versteckt
 * und nehmen keinen Slot ein. */
.bz-tiles {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
	align-content: start;
	margin-bottom: 8px;
}

.bz-tile {
	position: relative;
	background: #fff;
	border: 1px solid var(--bz-line-light);
	border-radius: 12px;
	padding: 10px 38px 10px 14px;
	min-height: 64px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	transition:
		border-color 0.18s ease,
		box-shadow 0.18s ease;
}

.bz-tile:hover {
	border-color: rgba(202, 156, 81, 0.55);
}

.bz-tile:focus-within {
	border-color: var(--bz-gold);
	box-shadow: 0 0 0 3px rgba(202, 156, 81, 0.18);
}

.bz-tile__label {
	font-size: 0.78rem;
	font-weight: 500;
	color: #5a5346;
	letter-spacing: 0.01em;
}

.bz-tile__field {
	display: flex;
	align-items: baseline;
	gap: 6px;
}

.bz-tile__input,
.bz-tile__select {
	border: none;
	outline: none;
	background: transparent;
	color: var(--bz-ink);
	padding: 0;
	font-family: inherit;
	font-size: 1.18rem;
	font-weight: 600;
	width: 100%;
	font-variant-numeric: tabular-nums;
	min-width: 0;
}

.bz-tile__input::placeholder {
	color: #bdb6a6;
	font-weight: 500;
}

.bz-tile__select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	background-image:
		url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%231b1b1c' d='M3.5 6 8 10.5 12.5 6 14 7.5l-6 6-6-6z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0 center;
	background-size: 14px;
	padding-right: 22px;
	cursor: pointer;
}

.bz-tile__unit {
	font-size: 1.02rem;
	font-weight: 600;
	color: #585045;
	flex-shrink: 0;
}

/* Info-Icon (i) und Edit-Icon (pencil), nur visuell wie im Original */
.bz-tile__info,
.bz-tile__edit {
	position: absolute;
	right: 12px;
	width: 16px;
	height: 16px;
	color: #aaa195;
	pointer-events: none;
}

.bz-tile__info {
	top: 10px;
}

.bz-tile__edit {
	bottom: 10px;
}

/* Akzentkachel: Autom. Darlehensberechnung */
.bz-tile--accent {
	background: linear-gradient(
		135deg,
		rgba(202, 156, 81, 0.14) 0%,
		rgba(202, 156, 81, 0.04) 100%
	);
	border-color: rgba(202, 156, 81, 0.4);
}

.bz-tile--accent .bz-tile__field {
	color: var(--bz-gold-dark);
}

.bz-tile--accent .bz-tile__input {
	color: var(--bz-gold-dark);
	font-weight: 700;
}

/* Spinner für Werte, die noch berechnet werden (z. B. Monatsrate
 * während der Engine-iframe rechnet). Goldener Ring der sich
 * dreht — kompakt genug um in die Wert-Zeile der Akzentkachel
 * zu passen. */
.bz-loader {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(202, 156, 81, 0.25);
	border-top-color: var(--bz-gold-dark);
	border-radius: 50%;
	animation: bzSpin 0.7s linear infinite;
	vertical-align: -3px;
}
@keyframes bzSpin {
	to { transform: rotate(360deg); }
}

/* ── Feinabstimmung-Zeile ───────────────────────────────────────────────── */
/* Zwei Blöcke (Zinsbindung + Tilgung) als vollwertige Tiles — selber
 * Stil wie die Eingabe-Kacheln oben, damit die Hierarchie stimmt.
 * Aktives Chip wird groß angezeigt, Toggle öffnet den Pool darunter. */
.bz-fein {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
	align-items: stretch;
	margin-top: 4px;
	margin-bottom: 18px;
}

.bz-fein__block {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 6px;
	background: #fff;
	border: 1px solid var(--bz-line-light);
	border-radius: 12px;
	padding: 10px 14px 12px;
	min-height: 64px;
	transition:
		border-color 0.18s ease,
		box-shadow 0.18s ease;
}

.bz-fein__block:hover {
	border-color: rgba(202, 156, 81, 0.55);
}

.bz-fein__block:focus-within {
	border-color: var(--bz-gold);
	box-shadow: 0 0 0 3px rgba(202, 156, 81, 0.18);
}

.bz-fein__label {
	font-size: 0.78rem;
	font-weight: 500;
	color: #5a5346;
	letter-spacing: 0.01em;
}

.bz-fein__chips-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	justify-content: flex-start;
}

/* „Selected pill" oben wird nicht mehr verwendet — wir zeigen
 * stets ALLE Optionen im Pool an und markieren den aktiven Chip
 * direkt dort per .is-active. */
.bz-fein__selected {
	display: none !important;
}

/* Aktives Chip in der Feinabstimmung deutlich größer — soll wie der
 * Tile-Wert wirken (1.18rem in den Eingabe-Kacheln). */
.bz-fein .bz-chip {
	padding: 8px 16px;
	font-size: 1rem;
	border-radius: 999px;
}

.bz-fein__selected .bz-chip {
	font-size: 1.05rem;
	padding: 9px 18px;
	font-weight: 700;
}

/* Alle Optionen sind permanent sichtbar — keine Toggle-Logik mehr. */
.bz-fein__pool {
	display: flex;
	margin-top: 8px;
	flex-wrap: wrap;
	gap: 8px;
}

/* Basis-Styles für .bz-fein__block / __label / __chips-row / __selected
 * sind oben im „Feinabstimmung-Zeile"-Abschnitt definiert (Tile-Look).
 * Hier nur noch das gemeinsame Chip-Styling. */

/* Chip — wie im Original: dunkles Teal wenn ausgewählt */
.bz-chip {
	appearance: none;
	border: 1px solid var(--bz-line-light);
	background: #fff;
	color: var(--bz-ink);
	padding: 5px 10px 5px 12px;
	border-radius: 999px;
	font-family: inherit;
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.15s ease;
	font-variant-numeric: tabular-nums;
	display: inline-flex;
	align-items: center;
	gap: 5px;
}

.bz-chip:hover {
	border-color: var(--bz-gold);
}

.bz-chip.is-active {
	background: linear-gradient(135deg, var(--bz-gold) 0%, var(--bz-gold-dark) 100%);
	color: #fff;
	border-color: var(--bz-gold-dark);
	box-shadow: 0 2px 6px rgba(164, 118, 58, 0.25);
}

.bz-chip.is-disabled {
	color: #aba49a;
	background: rgba(0, 0, 0, 0.03);
	border-color: rgba(0, 0, 0, 0.06);
	cursor: not-allowed;
	box-shadow: none;
}

.bz-chip.is-disabled:hover {
	border-color: rgba(0, 0, 0, 0.06);
}

.bz-chip__icon {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 1px solid currentColor;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	opacity: 0.7;
	flex-shrink: 0;
}

.bz-chip__icon svg {
	width: 8px;
	height: 8px;
}

/* Toggle wird nicht mehr benötigt — alle Optionen sind permanent
 * sichtbar. Versteckt halten, damit existierende HTML-Strukturen
 * (auch SSR/Cache) sauber bleiben. */
.bz-fein__toggle {
	display: none !important;
}

/* Sortierung & Wunschrate als kleine Tiles innerhalb Feinabstimmung */
.bz-fein .bz-tile {
	min-height: 60px;
	padding: 8px 14px;
}

.bz-fein .bz-tile__input {
	font-size: 1rem;
}

/* ── CTA: Jetzt anfragen ────────────────────────────────────────────────── */

.bz-cta {
	display: flex;
	justify-content: center;
	margin-top: 6px;
}

.bz-cta__btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 13px 28px;
	background: linear-gradient(135deg, var(--bz-gold) 0%, var(--bz-gold-dark) 100%);
	color: #fff;
	border-radius: 10px;
	font-family: inherit;
	font-size: 0.98rem;
	font-weight: 700;
	text-decoration: none;
	border: 1px solid var(--bz-gold-dark);
	box-shadow: 0 6px 18px rgba(164, 118, 58, 0.28);
	transition: all 0.18s ease;
	letter-spacing: 0.005em;
}

.bz-cta__btn:hover {
	background: linear-gradient(135deg, var(--bz-gold-soft) 0%, var(--bz-gold) 100%);
	transform: translateY(-1px);
	box-shadow: 0 10px 22px rgba(164, 118, 58, 0.38);
}

.bz-cta__btn:active {
	transform: translateY(0);
}

.bz-cta__btn svg {
	flex-shrink: 0;
	color: #fff;
}

/* ── Danke-Screen (nach erfolgreichem Lead-Submit) ──────────────────────── */
/* Wird im Modal anstelle der drklein-„Wir freuen uns"-Seite gezeigt,
 * sobald der Anfrage-iframe ein admara-lead-form-submitted-Event sendet. */
.bz-modal__step--danke {
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 56px 32px;
}

.bz-modal__step--danke[hidden] {
	display: none;
}

.bz-danke {
	max-width: 520px;
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
}

.bz-danke__icon {
	width: 88px;
	height: 88px;
	color: var(--bz-gold-dark);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: rgba(202, 156, 81, 0.12);
	border-radius: 50%;
	margin-bottom: 6px;
}

.bz-danke__icon svg {
	width: 52px;
	height: 52px;
}

.bz-danke__title {
	margin: 0;
	font-size: 1.6rem;
	font-weight: 700;
	color: var(--bz-ink);
	letter-spacing: -0.005em;
}

.bz-danke__text {
	margin: 0 0 16px;
	color: var(--bz-ink-soft);
	font-size: 1rem;
	line-height: 1.55;
}

@media (max-width: 640px) {
	.bz-modal__step--danke { padding: 40px 18px; }
	.bz-danke__title { font-size: 1.3rem; }
	.bz-danke__icon { width: 72px; height: 72px; }
	.bz-danke__icon svg { width: 42px; height: 42px; }
}

/* ── Powered-by ─────────────────────────────────────────────────────────── */

.bz-modal__powered {
	margin: 10px 0 0;
	font-size: 0.72rem;
	color: #8c8473;
	text-align: right;
}

.bz-modal__powered a {
	color: #6c6453;
	text-decoration: underline;
}

/* Anschluss-Felder versteckt bis Vorhaben = FORWARD */
.bz-form__zweck {
	display: none;
}

/* ── Versteckter iframe-Engine ──────────────────────────────────────────── */

.bz-modal__engine {
	position: absolute;
	left: -10000px;
	top: 0;
	width: 1px;
	height: 1px;
	border: 0;
	opacity: 0;
	pointer-events: none;
	overflow: hidden;
}

/* ── Animationen ────────────────────────────────────────────────────────── */

@keyframes bzFadeIn {
	to {
		opacity: 1;
	}
}

@keyframes bzPopIn {
	to {
		transform: translateY(0) scale(1);
	}
}

@keyframes bzSpin {
	to {
		transform: rotate(360deg);
	}
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
	.bz-tiles {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
	.bz-fein {
		gap: 20px 36px;
	}
}

@media (max-width: 640px) {
	.bz-modal {
		padding: 0;
	}
	.bz-modal__dialog {
		width: 100%;
		height: 100%;
		border-radius: 0;
		transform: none;
		animation: none;
	}
	.bz-modal__content {
		padding: 20px 16px 16px;
	}
	.bz-tiles {
		grid-template-columns: 1fr;
	}
	.bz-fein {
		flex-direction: column;
		align-items: center;
		gap: 18px;
	}
}
