/* ==========================================================================
   Angebots-Formular (Wizard) – v2: 4 Schritte, interaktive Auswahl
   ========================================================================== */

body.form-page { background: var(--light); }

.wizard-container {
    max-width: 1040px;
    margin: 0 auto;
    padding: calc(var(--header-h) + 40px) clamp(14px, 4vw, 40px) 60px;
    display: grid;
    grid-template-columns: 320px 1fr;
    align-items: stretch;
}

/* ---------- Sidebar ---------- */
.wizard-sidebar {
    background: radial-gradient(500px 300px at 100% 0%, rgba(185,138,62,.2), transparent 60%), linear-gradient(150deg, var(--navy) 0%, var(--navy-dark) 100%);
    color: #fff;
    padding: 40px 32px;
    border-radius: var(--radius) 0 0 var(--radius);
    display: flex; flex-direction: column; justify-content: space-between; gap: 30px;
}
.wizard-sidebar h1 { font-size: 1.4rem; line-height: 1.3; margin-bottom: 24px; }
.wizard-sidebar ul { display: grid; gap: 16px; }
.wizard-sidebar li {
    font-size: .95rem; color: rgba(255,255,255,.88); padding-left: 30px; position: relative;
}
.wizard-sidebar li::before {
    content: ""; position: absolute; left: 0; top: 3px; width: 20px; height: 20px; border-radius: 50%;
    background: rgba(227,196,138,.2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e3c48a' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='5 12.5 10 17.5 19 7'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.wizard-sidebar li strong { color: #fff; }
.wizard-sidebar-info { font-size: .88rem; line-height: 1.8; color: rgba(255,255,255,.75); border-top: 1px solid rgba(255,255,255,.15); padding-top: 22px; overflow-wrap: anywhere; }
.wizard-sidebar-info a:hover { color: var(--gold-light); }

/* ---------- Hauptkarte ---------- */
.wizard-main {
    background: #fff;
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: var(--shadow-md);
    padding: 36px clamp(20px, 4vw, 48px) 32px;
    min-width: 0;
}
.wizard-mobile-note { display: none; }

/* ---------- Fortschritt ---------- */
.wizard-progress { display: flex; align-items: flex-start; margin-bottom: 34px; counter-reset: none; }
.wizard-progress-step { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.wizard-progress-step::before {   /* Verbindungslinie */
    content: ""; position: absolute; top: 17px; right: 50%; width: 100%; height: 3px; background: var(--border); z-index: 0;
    transition: background .4s var(--ease);
}
.wizard-progress-step:first-child::before { display: none; }
.wizard-progress-step.is-active::before { background: var(--red); }
.wizard-progress-step .num {
    position: relative; z-index: 1; width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: .9rem;
    background: #fff; border: 3px solid var(--border); color: var(--grey);
    transition: all .4s var(--ease);
}
.wizard-progress-step.is-active .num { border-color: var(--red); background: var(--red); color: #fff; }
.wizard-progress-step.is-current .num { box-shadow: 0 0 0 6px rgba(212,42,30,.15); transform: scale(1.08); }
.wizard-progress-step .lbl { font-size: .78rem; font-weight: 600; color: var(--grey); }
.wizard-progress-step.is-current .lbl { color: var(--navy); font-weight: 700; }

/* ---------- Schritte ---------- */
fieldset.wizard-step { display: none; border: 0; min-width: 0; }
fieldset.wizard-step.active { display: block; animation: fadeStep .45s var(--ease); }
@keyframes fadeStep { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.wizard-step legend { padding: 0; margin-bottom: 18px; width: 100%; }
.wizard-step h2 { font-size: clamp(1.3rem, 3vw, 1.65rem); color: var(--navy); line-height: 1.25; }
.step-hint { color: var(--grey); font-size: .95rem; margin: -6px 0 22px; }

/* Leistungs-Karten (Schritt 1) */
.options-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.options-grid > .option-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
.option-card, .option-row {
    position: relative; border: 2px solid var(--border); border-radius: 12px; padding: 16px; min-height: 58px;
    cursor: pointer; display: flex; align-items: center; gap: 12px; font-weight: 600; color: var(--text); background: #fff;
    transition: border-color .25s, background .25s, transform .25s var(--ease), box-shadow .25s;
    -webkit-tap-highlight-color: transparent;
}
.option-row { justify-content: space-between; }
.option-card:hover, .option-row:hover { border-color: var(--navy); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.option-card:has(input:focus-visible), .option-row:has(input:focus-visible), .chip:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 2px; }
.radio-dot { width: 22px; height: 22px; border: 2px solid var(--border); border-radius: 50%; flex-shrink: 0; position: relative; transition: border-color .2s; }
.radio-dot::after { content: ""; position: absolute; inset: 3px; background: var(--red); border-radius: 50%; transform: scale(0); transition: transform .3s var(--ease); }
.option-card.selected, .option-row.selected { border-color: var(--red); background: #fff5f4; }
.option-card.selected .radio-dot, .option-row.selected .radio-dot { border-color: var(--red); }
.option-card.selected .radio-dot::after, .option-row.selected .radio-dot::after { transform: scale(1); }
.options-list { display: grid; gap: 12px; margin-bottom: 26px; }
.custom-service-group { margin-top: 18px; animation: fadeStep .35s var(--ease); }

/* Chips (Dachform, Gebäudeart, Anliegen, Kontakt) */
.field-block { margin-bottom: 26px; }
.field-label { display: block; font-weight: 700; color: var(--navy); margin-bottom: 12px; font-size: .98rem; font-family: var(--font-head); }
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.field-label-row .field-label { margin-bottom: 0; }
.chip-group { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
    position: relative; display: inline-flex; align-items: center; min-height: 46px; padding: 10px 18px;
    border: 2px solid var(--border); border-radius: 50px; background: #fff; cursor: pointer;
    font-weight: 600; font-size: .93rem; color: var(--text); user-select: none;
    transition: all .25s var(--ease); -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--navy); transform: translateY(-1px); }
.chip.selected { border-color: var(--navy); background: var(--navy); color: #fff; box-shadow: 0 6px 14px rgba(15,35,71,.22); }
.chip input[type="checkbox"] ~ span::before { content: "+"; display: inline-block; width: 1.1em; font-weight: 800; margin-right: 4px; transition: transform .3s var(--ease); }
.chip.selected input[type="checkbox"] ~ span::before { content: "✓"; transform: scale(1.1); }

/* Flächen-Regler */
.area-output { font-family: var(--font-head); font-weight: 800; color: var(--red); font-size: 1.15rem; white-space: nowrap; }
.range {
    --pct: 30%;
    -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 8px; outline: none; cursor: pointer; margin: 8px 0 4px;
    background: linear-gradient(to right, var(--red) 0%, var(--red) var(--pct), var(--border) var(--pct), var(--border) 100%);
}
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 4px solid var(--red); box-shadow: 0 3px 10px rgba(15,35,71,.3); transition: transform .2s var(--ease); }
.range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 4px solid var(--red); box-shadow: 0 3px 10px rgba(15,35,71,.3); }
.range:active::-webkit-slider-thumb { transform: scale(1.15); }
.range:focus-visible { outline: 3px solid var(--gold); outline-offset: 6px; }
.range:disabled { opacity: .35; cursor: not-allowed; }
.range-scale { display: flex; justify-content: space-between; font-size: .78rem; color: var(--grey); margin-bottom: 10px; }
.inline-check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 500; font-size: .93rem; color: var(--text); }
.inline-check input { width: 20px; height: 20px; accent-color: var(--red); }
.field-hint { font-size: .85rem; color: var(--grey); margin-top: 6px; }
.field-hint a { color: var(--red); font-weight: 600; text-decoration: underline; }

/* Formularfelder */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-group { margin-bottom: 20px; min-width: 0; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; color: var(--navy); font-size: .95rem; }
.form-group input, .form-group textarea {
    width: 100%; padding: 14px 16px; min-height: 52px; border: 2px solid var(--border); border-radius: 10px;
    font-family: inherit; font-size: 1rem; /* 16px verhindert Zoom auf iOS */ color: var(--text); background: #fff;
    transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 4px rgba(15,35,71,.1); }
.form-group input[aria-invalid="true"] { border-color: var(--red); background: #fff8f7; }
.form-group textarea { resize: vertical; min-height: 120px; }
.field-error { display: block; color: var(--red); font-size: .85rem; font-weight: 600; min-height: 0; margin-top: 6px; }
.field-error:empty { display: none; }

/* Datenschutz-Checkbox */
.privacy-check { display: flex; align-items: flex-start; gap: 12px; font-size: .92rem; color: var(--grey); cursor: pointer; margin-top: 8px; min-height: 44px; }
.privacy-check a { color: var(--red); text-decoration: underline; }
.checkbox-wrap { position: relative; width: 24px; height: 24px; margin-top: 1px; flex-shrink: 0; }
.checkbox-wrap input[type="checkbox"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 2; appearance: none; -webkit-appearance: none; }
.checkbox-svg {
    position: absolute; inset: 0; width: 100%; height: 100%; border: 2px solid var(--border); border-radius: 6px; background: #fff;
    pointer-events: none; transition: border-color .2s, background .2s, transform .15s var(--ease);
}
.checkbox-check-path { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 26; stroke-dashoffset: 26; transition: stroke-dashoffset .3s ease .05s; }
.checkbox-wrap input:checked ~ .checkbox-svg { background: var(--red); border-color: var(--red); animation: checkPop .3s var(--ease); }
.checkbox-wrap input:checked ~ .checkbox-svg .checkbox-check-path { stroke-dashoffset: 0; }
.checkbox-wrap input:focus-visible ~ .checkbox-svg { outline: 3px solid var(--gold); outline-offset: 2px; }
@keyframes checkPop { 0% { transform: scale(.75); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

.form-error {
    display: none; color: var(--red); background: #fff1f0; border: 1px solid #ffd0cc; border-radius: 10px;
    font-weight: 600; font-size: .92rem; padding: 12px 16px; margin-bottom: 18px;
}
.form-error.show { display: block; animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }

/* Zusammenfassung (Schritt 4) */
.wizard-summary { background: var(--light); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin: 4px 0 18px; font-size: .92rem; }
.wizard-summary h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--red); margin-bottom: 10px; }
.wizard-summary dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.wizard-summary dt { color: var(--grey); }
.wizard-summary dd { color: var(--navy); font-weight: 600; overflow-wrap: anywhere; }

/* Buttons */
.wizard-buttons { display: flex; justify-content: space-between; gap: 14px; margin-top: 30px; }
.wizard-buttons .btn-outline { color: var(--navy); border-color: var(--border); }
.wizard-buttons .btn-outline:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.wizard-buttons #btnNext, .wizard-buttons #btnSubmit { margin-left: auto; min-width: 160px; }

/* Erfolg */
.form-success { text-align: center; padding: 30px 6px 10px; }
.form-success .check-circle {
    width: 84px; height: 84px; background: var(--red); border-radius: 50%; display: grid; place-items: center;
    margin: 0 auto 24px; color: #fff; animation: popIn .5s var(--ease);
}
.form-success .check-circle svg { width: 42px; height: 42px; fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 30; stroke-dashoffset: 30; animation: drawCheck .6s .25s ease forwards; }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }
@keyframes popIn { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.form-success h2 { color: var(--navy); margin-bottom: 12px; }
.form-success p { color: var(--grey); margin-bottom: 24px; }
.form-success .success-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.form-success .btn-outline { color: var(--navy); border-color: var(--border); }
.form-success .btn-outline:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

.is-loading { opacity: .7; pointer-events: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .wizard-container { grid-template-columns: 1fr; padding-top: calc(var(--header-h) + 18px); }
    .wizard-sidebar { display: none; }
    .wizard-main { border-radius: var(--radius); }
    .wizard-mobile-note {
        display: block; background: var(--light); border: 1px solid var(--border); border-radius: 10px;
        padding: 10px 14px; margin-bottom: 22px; font-size: .88rem; color: var(--grey);
    }
    .wizard-mobile-note strong, .wizard-mobile-note span:first-child { font-weight: 700; color: var(--navy); }
}

@media (max-width: 560px) {
    .wizard-container { padding-left: 10px; padding-right: 10px; padding-bottom: 30px; }
    .wizard-main { padding: 22px 16px 20px; }
    .options-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .option-card { padding: 12px; gap: 8px; font-size: .88rem; align-items: flex-start; flex-direction: column; min-height: 84px; }
    .form-row { grid-template-columns: 1fr; }
    .wizard-progress-step .lbl { display: none; }
    .wizard-progress-step.is-current .lbl { display: block; position: absolute; top: 44px; white-space: nowrap; }
    .wizard-progress { margin-bottom: 44px; }
    .chip { min-height: 48px; }
    .wizard-summary dl { grid-template-columns: 1fr; gap: 0; }
    .wizard-summary dd { margin-bottom: 8px; }
    /* Buttons haften am unteren Bildschirmrand – Daumen-freundlich */
    .wizard-buttons {
        position: sticky; bottom: 0; margin: 24px -16px -20px; padding: 14px 16px max(14px, env(safe-area-inset-bottom));
        background: rgba(255,255,255,.96); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
        border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); z-index: 20;
    }
    .wizard-buttons .btn-primary, .wizard-buttons .btn-outline { width: auto; flex: 1; min-width: 0; }
    .wizard-buttons .btn-back { flex: 0 0 auto; padding-left: 22px; padding-right: 22px; }
    body.form-page .floating-actions { display: none; } /* kollidiert mit den Buttons */
}

@media (prefers-reduced-motion: reduce) {
    .form-error.show, fieldset.wizard-step.active { animation: none; }
}
