/* ==========================================================================
   BUHA — Kostenrechner-UI (Designsystem 10) & mehrstufiges Angebotsformular
   (Designsystem 11.4). Zentrale Conversion-Elemente.
   ========================================================================== */

/* ==========================================================================
   Kostenrechner — Layout (Designsystem 10.1)
   ========================================================================== */
.calc {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .calc-grid {
    grid-template-columns: 58fr 42fr;
  }
}

/* Grid-Spalten duerfen nicht auf ihre Min-Content-Breite aufgehen: das
   Zahlenfeld (intrinsische Eingabebreite) und die umbruchfreien Betraege in
   der Ergebnisspalte wuerden die Karte sonst auf schmalen Screens ueber den
   Viewport hinausschieben (gemessen: 417px Inhalt bei 390px Viewport). */
.calc-grid > * {
  min-width: 0;
}

/* --- Eingabe-Spalte ------------------------------------------------------- */
.calc-input {
  padding: var(--s-5);
}

@media (min-width: 1024px) {
  .calc-input {
    padding: var(--s-7);
  }
}

.calc-step {
  margin-bottom: var(--s-6);
}

.calc-step:last-child {
  margin-bottom: 0;
}

.calc-step-label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--c-navy-700);
  margin-bottom: var(--s-3);
}

.calc-step-num {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--c-navy-100);
  color: var(--c-navy-700);
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* --- ① Leistungsbausteine: Karten-Checkboxen (Designsystem 10.2) --------- */
.calc-modules {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .calc-modules {
    grid-template-columns: repeat(2, 1fr);
  }
}

.calc-module {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--c-surface);
  border: 2px solid var(--c-line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}

.calc-module:hover {
  border-color: var(--c-navy-100);
}

.calc-module input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.calc-module .cm-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--c-navy-100);
  border-radius: var(--r-sm);
  color: var(--c-navy-700);
}

.calc-module .cm-icon .icon {
  width: 22px;
  height: 22px;
}

.calc-step-label .icon,
.calc-step-num + .icon {
  width: 1.125rem;
  height: 1.125rem;
}

.calc-module .cm-label {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--c-navy-700);
  line-height: 1.3;
}

/* Häkchen-Badge oben rechts */
.calc-module .cm-check {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c-navy-700);
  color: #fff;
  display: none;
  place-items: center;
}

.calc-module .cm-check .icon {
  width: 14px;
  height: 14px;
}

/* ausgewählt */
.calc-module input:checked ~ .cm-check {
  display: grid;
}

.calc-module:has(input:checked) {
  border-color: var(--c-navy-700);
  background: var(--c-navy-050);
}

/* Tastatur-Fokus auf der Karte sichtbar machen */
.calc-module input:focus-visible ~ .cm-label,
.calc-module:focus-within {
  outline: 2px solid var(--c-navy-600);
  outline-offset: 2px;
  border-radius: var(--r-md);
}

/* --- Jahresumsatz-Eingabe (V3) — nutzt die Formularbausteine des
   Designsystems (.form-field/.form-input/.form-help/.form-error). */
.calc-step .form-field {
  margin-bottom: 0;
}

.calc-step .form-input[type="number"] {
  width: 100%;
  min-width: 0;
  max-width: 22rem;
}

/* --- Fieldset-Reset (ersetzt frühere Inline-Styles im injizierten Markup) */
.calc-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

/* --- ① Jahresumsatz / Segmented Control --------------------------------- */
.seg-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-2);
}

@media (min-width: 480px) {
  .seg-control {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Umsatzstaffel (V2 5.1) — sechs Stufen: 2 Spalten mobil, 3 ab 480px.
   Vier nebeneinander wären für die längeren Beträge zu schmal. */
.seg-control--six {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 480px) {
  .seg-control--six {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Rechtsform / Abrechnungszeitraum (V3) — drei Optionen: eine Spalte mobil
   (die Beschriftungen sind lang), drei nebeneinander ab 480px. */
.seg-control--three {
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .seg-control--three {
    grid-template-columns: repeat(3, 1fr);
  }
}

.seg-option {
  position: relative;
}

.seg-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.seg-option label {
  display: block;
  text-align: center;
  padding: var(--s-3) var(--s-2);
  border: 2px solid var(--c-line);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-ink-700);
  cursor: pointer;
  transition: all 150ms ease-out;
}

.seg-option label:hover {
  border-color: var(--c-navy-100);
}

.seg-option input:checked + label {
  border-color: var(--c-navy-700);
  background: var(--c-navy-700);
  color: #fff;
}

.seg-option input:focus-visible + label {
  outline: 2px solid var(--c-navy-600);
  outline-offset: 2px;
}

/* --- Belegmengen-Schalter (V2 5.2) -------------------------------------- *
   Beleganzahl ist kein Preistreiber mehr, sondern ein optionaler Aufschlag
   von 2–5 % ab ca. 1.000 Belegen pro Jahr.                                  */
.calc-belege-toggle {
  border: 2px solid var(--c-line);
  border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4);
  align-items: center;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}

.calc-belege-toggle:hover {
  border-color: var(--c-navy-100);
}

.calc-belege-toggle:has(input:checked) {
  border-color: var(--c-amber-500);
  background: var(--c-amber-100);
}

.calc-belege-toggle:focus-within {
  outline: 2px solid var(--c-navy-600);
  outline-offset: 2px;
}

.calc-belege-toggle input {
  accent-color: var(--c-amber-600);
}

.calc-belege-toggle span {
  font-weight: 600;
  color: var(--c-ink-900);
}

/* --- ③ Stepper (Mitarbeitende) ------------------------------------------ */
.calc-step--conditional {
  transition: opacity 200ms ease-out, max-height 200ms ease-out;
}

.calc-step--conditional[hidden] {
  display: none;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.stepper button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--c-navy-050);
  color: var(--c-navy-700);
  font-size: 1.25rem;
  font-weight: 600;
}

.stepper button:hover {
  background: var(--c-navy-100);
}

.stepper button:disabled {
  color: var(--c-ink-300);
  cursor: not-allowed;
}

.stepper input {
  width: 64px;
  height: 48px;
  text-align: center;
  border: none;
  border-inline: 1px solid var(--c-line);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1.0625rem;
  color: var(--c-navy-700);
  -moz-appearance: textfield;
}

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

/* --- ④ Radio-Gruppe (Buchführungsart) ----------------------------------- */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
}

/* --- Ergebnis-Spalte (Designsystem 10.3) -------------------------------- */
.calc-result {
  background: var(--c-navy-800);
  color: rgba(255, 255, 255, 0.85);
  padding: var(--s-6);
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .calc-result {
    padding: var(--s-7);
  }
}

.calc-result-head {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: var(--s-4);
}

.calc-price {
  font-family: var(--font-mono);
  font-weight: 500;
  /* V2: Die Umsatzstaffel erzeugt dreistellige Beträge auf beiden Seiten der
     Spanne — auf schmalen Screens skaliert die Zahl mit, damit das "€" nicht
     als Waise in die zweite Zeile rutscht. */
  font-size: clamp(1.75rem, 6.4vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: #fff;
}

@media (min-width: 1024px) {
  .calc-price {
    /* Die Ergebnisspalte ist nur ~42 % breit — die Spanne aus zwei
       dreistelligen Beträgen muss darin ohne Zeilenumbruch stehen. */
    font-size: clamp(2rem, 3.2vw, 2.75rem);
  }
}

.calc-price-unit {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: rgba(255, 255, 255, 0.72);
  margin-top: var(--s-1);
}

/* Aufschlüsselung */
.calc-breakdown {
  margin-top: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: var(--s-4);
}

.calc-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  font-size: 0.9375rem;
}

.calc-breakdown-row .cb-label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: rgba(255, 255, 255, 0.85);
}

.calc-breakdown-row .cb-label::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--c-amber-400);
  flex-shrink: 0;
}

.calc-breakdown-row .cb-value {
  font-family: var(--font-mono);
  color: #fff;
  white-space: nowrap;
}

/* Zeilen mit Textwert (z. B. „Einzelunternehmen (6/10)") statt Betrag:
   hier ist der umbruchfreie Satz aus .cb-value nicht sinnvoll, sonst laeuft
   der Wert auf schmalen Screens aus der Karte. */
.calc-breakdown-row--wrap .cb-value {
  white-space: normal;
  text-align: right;
}

/* Summenzeilen der Aufschlüsselung (Brutto, Jahreswert) — abgesetzt, ohne
   den Bernstein-Punkt der normalen Zeilen. */
.calc-breakdown-row--total {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: var(--s-2);
  font-weight: 600;
}

.calc-breakdown-row--total .cb-label {
  color: #fff;
}

.calc-breakdown-row--total .cb-label::before {
  background: transparent;
}

/* Rechenweg im Klartext (V3) — zeigt dieselbe Formel, die gerechnet wurde. */
.calc-formel {
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.82);
}

.calc-formel strong {
  color: #fff;
}

.calc-formel code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #fff;
  overflow-wrap: anywhere;
}

/* Ausgabebereich (aria-live) — Preis, Leerzustand, Individual-Hinweis
   und Aufschlüsselung wechseln hier je nach Auswahl (V2 5.3). */
.calc-result-body {
  display: block;
}

/* Stufe 6 „über 500.000 €" — kein Listenpreis, sondern Angebots-Hinweis
   (V2 5.1). Bernstein-Akzentlinie statt Preiszahl. */
.calc-individuell {
  border-left: 3px solid var(--c-amber-500);
  padding-left: var(--s-4);
}

.calc-individuell-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.75rem;
  line-height: 1.15;
  color: #fff;
  margin-bottom: var(--s-2);
}

@media (min-width: 1024px) {
  .calc-individuell-title {
    font-size: 2.125rem;
  }
}

.calc-individuell-text {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.78);
}

/* Leerzustand */
.calc-empty {
  font-size: 0.9375rem;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.6;
}

/* Disclaimer */
.calc-disclaimer {
  margin-top: var(--s-5);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.72);
}

/* Ergebnis-Aktionen */
.calc-actions {
  margin-top: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

/* Wert-Wechsel-Fade beim Update */
.calc-price.is-updating {
  animation: calc-fade 300ms ease-out;
}

@keyframes calc-fade {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .calc-price.is-updating {
    animation: none;
  }
}

/* Mobile Sticky-Ergebnisstreifen */
.calc-sticky {
  position: sticky;
  bottom: 64px;
  z-index: 5;
  background: var(--c-navy-800);
  color: #fff;
  padding: var(--s-3) var(--s-4);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  box-shadow: 0 -6px 20px rgba(11, 27, 51, 0.2);
  border-radius: var(--r-md) var(--r-md) 0 0;
}

.calc-sticky .cs-price {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1.25rem;
}

@media (max-width: 1023px) {
  .calc-sticky.is-active {
    display: flex;
  }
}
/* Hinweis: Die Regeln für mehrstufige Formulare (.form-steps, .stepper-bar,
   .form-step-panel, .form-step-nav, .form-trust-aside, .prefill-note) liegen
   seit 2026-09-06 in components.css — sie werden auf jeder Seite gebraucht,
   auch ohne Kostenrechner (z. B. angebot-anfragen.html). */
