/*
 * Dokument Generator
 * Gestaltet nach dem Figma-Entwurf „AUSKUNFT – Formular Variante C“ (Desktop)
 * und „AUSKUNFT – Mobil“. Maße in px aus dem Entwurf. Die Schriftgrößen sind
 * mobil dieselben wie am Desktop (das Theme rechnet erst ab 992px mit 17px
 * Grundgröße, darunter mit 16px).
 */
.docgen-intro {
  margin-bottom: 1.5rem;
}

/* Formular als hellgraue Fläche, Radius wie die Buttons */
.docgen {
  display: flex;
  flex-direction: column;
  gap: 36px;
  padding: 28px 20px 32px;
  background: #f9f9f9;
  border-radius: var(--bs-border-radius);
}

@media (min-width: 768px) {
  .docgen {
    gap: 44px;
    padding: 40px;
  }
}

@media (min-width: 992px) {
  .docgen {
    padding: 51px;
  }
}

.docgen-section {
  margin: 0;
}

/* Abschnittsüberschrift in Rot mit kurzem Balken darunter */
.docgen-legend {
  margin: 0;
  padding: 0;
  font-family: "Open Sans Condensed", "Open Sans", Arial, sans-serif;
  font-size: 21.25px;
  font-weight: 700;
  line-height: 1.75;
  color: var(--bs-primary);
  text-transform: uppercase;
}

.docgen-legend::after {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  margin-top: 6px;
  background: currentColor;
}

/* legend floatet per Bootstrap-Reboot, der Abstand muss deshalb an ihr hängen */
legend.docgen-legend {
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  legend.docgen-legend {
    margin-bottom: 22px;
  }
}

/* --- Persönliche Angaben ------------------------------------------------- */
.docgen-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.docgen-row {
  display: flex;
  gap: 12px;
}

.docgen-row--stack {
  flex-direction: column;
  gap: 14px;
}

.docgen-field {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* Hausnummer und PLZ */
.docgen-field--short {
  flex: 0 0 112px;
}

@media (min-width: 768px) {
  .docgen-fields {
    gap: 18px;
  }

  .docgen-row,
  .docgen-row--stack {
    flex-direction: row;
    gap: 21px;
  }
}

@media (min-width: 992px) {
  .docgen-field--short {
    flex-basis: 190px;
  }
}

/* Labels über den Eingabefeldern */
.docgen .form-label {
  margin: 0;
  font-family: "Open Sans Condensed", "Open Sans", Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.75;
  letter-spacing: 1px;
  color: #737373;
  text-transform: uppercase;
}

/* Eingabefelder: weiß mit feiner grauer Kontur. Schrift über 16px, sonst
   zoomt iOS beim Antippen in das Feld. */
.docgen .form-control {
  height: 47px;
  padding: 0 14px;
  font-size: 16.2px;
  line-height: 1.5;
  color: #212121;
  background-color: #fff;
  border: 1px solid #767676;
  border-radius: var(--bs-border-radius);
}

.docgen .form-control:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

.docgen .form-control.is-invalid {
  padding-right: calc(1.5em + 0.75rem);
  border-color: var(--bs-form-invalid-border-color);
}

.docgen .form-control.is-invalid:focus {
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-danger-rgb), 0.2);
}

/* Geburtsdatum: Kalender-Symbol aus dem Entwurf, rechts mit 14px Abstand */
.docgen input[type="date"]::-webkit-calendar-picker-indicator {
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23212121' stroke-width='1.5'%3e%3crect x='3.33' y='4.17' width='13.33' height='12.5' rx='1.67'/%3e%3cpath stroke-linecap='round' d='M3.33 8.33h13.34M6.67 2.5v3.33M13.33 2.5v3.33'/%3e%3c/svg%3e") center / 20px no-repeat;
  opacity: 1;
  cursor: pointer;
}

/* Das Ausrufezeichen bei Fehlern hätte neben dem Kalender keinen Platz */
.docgen input[type="date"].is-invalid {
  padding-right: 14px;
  background-image: none;
}

/* iOS Safari zentriert das Datum sonst */
.docgen input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}

/* invalid-feedback zeigt Bootstrap nur nach .is-invalid; hier per hidden gesteuert */
.docgen .invalid-feedback {
  margin-top: 0;
}

.docgen .invalid-feedback:not([hidden]) {
  display: block;
}

.docgen [data-error="authorities"] {
  margin-top: 10px;
}

/* --- Behörden ------------------------------------------------------------ */

/* Kopf: Überschrift, darunter Zähler und Button; ab Desktop alles in einer Zeile */
.docgen-section-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

@media (min-width: 992px) {
  .docgen-section-head {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
  }
}

/* Mobil Zähler links, Button rechts; auf schmalen Geräten bricht der Zähler um */
.docgen-selection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

@media (min-width: 992px) {
  .docgen-selection {
    gap: 16px;
  }
}

/* Text und unsichtbarer Platzhalter liegen übereinander */
.docgen-selection-count {
  display: grid;
  font-size: 14.9px;
  font-variant-numeric: tabular-nums;
  line-height: 26px;
  color: #737373;
}

.docgen-selection-count > span {
  grid-area: 1 / 1;
  align-self: center;
}

.docgen-selection-count-max {
  visibility: hidden;
}

/* Desktop: Zähler rechtsbündig direkt vor dem Button */
@media (min-width: 992px) {
  .docgen-selection-count {
    justify-items: end;
  }
}

.docgen-select-all {
  --bs-btn-font-size: 16.2px;
  --bs-btn-line-height: 1.5;
  --bs-btn-padding-x: 12.8px;
  --bs-btn-padding-y: 6.4px;
  display: inline-grid;
  flex: none;
}

/* Beide Beschriftungen in derselben Zelle: Der Button ist so breit wie die längere */
.docgen-select-all-label {
  grid-area: 1 / 1;
}

.docgen-select-all-label.is-hidden {
  visibility: hidden;
}

.docgen-authorities {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.docgen-authority-group-title {
  margin-bottom: 10px;
  font-family: "Open Sans Condensed", "Open Sans", Arial, sans-serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.75;
  color: #212121;
}

/* Kacheln: so viele Spalten wie mit mindestens 240px passen, am Desktop drei,
   mobil eine. Reihenfolge zeilenweise wie im Entwurf. */
.docgen-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 10px 12px;
}

/* Kachel: Box und Name in einem Label, die ganze Fläche ist klickbar */
.docgen-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  margin: 0;
  padding: 8px 12px;
  font-family: "Open Sans Condensed", "Open Sans", Arial, sans-serif;
  font-size: 17px;
  font-weight: 300;
  line-height: 1.3;
  color: #212121;
  background: #fff;
  border: 2px solid #e9e9e9;
  border-radius: var(--bs-border-radius);
  cursor: pointer;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

@media (min-width: 992px) {
  .docgen-tile {
    min-height: 52px;
  }
}

.docgen-tile:hover {
  border-color: #cecece;
}

/* Gewählt: roter Rahmen, Name fett */
.docgen-tile:has(:checked) {
  font-weight: 700;
  border-color: var(--bs-primary);
}

.docgen-tile:has(:focus-visible) {
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Eigene Box statt der Browser-Checkbox, bleibt aber ein echtes Eingabefeld */
.docgen-tile-input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  appearance: none;
  background: #fff no-repeat center / 15.4px;
  border: 1px solid #767676;
  border-radius: 5.1px;
  cursor: pointer;
}

.docgen-tile-input:focus-visible {
  outline: none;
}

.docgen-tile-input:checked {
  background-color: var(--bs-primary);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15.4 15.4'%3e%3cpath fill='none' stroke='%23fff' stroke-width='1.925' stroke-linecap='round' stroke-linejoin='round' d='M3.21 8.02l2.89 2.89 6.09-6.1'/%3e%3c/svg%3e");
  border-color: var(--bs-primary);
}

/* --- Aktion ---------------------------------------------------------------- */

/* Desktop: Download links, "Eingaben leeren" rechts, Datenschutz-Zeile darunter */
.docgen-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.docgen .docgen-download {
  --bs-btn-font-size: 27.2px;
  --bs-btn-line-height: 1.1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 32px 14px 28px;
  letter-spacing: 0;
}

.docgen-download-icon {
  flex: none;
  width: 26px;
  height: 26px;
}

.docgen-privacy {
  flex-basis: 100%;
  order: 1;
  margin: 0;
  font-size: 10.2px;
  line-height: 1.75;
}

/* "Eingaben leeren": grauer Outline-Button mit X. Erst sichtbar, sobald etwas
   eingegeben wurde (hidden per JS). */
.docgen-clear {
  --bs-btn-color: #737373;
  --bs-btn-border-color: #959595;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #737373;
  --bs-btn-hover-border-color: #737373;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #5c5c5c;
  --bs-btn-active-border-color: #5c5c5c;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.docgen-clear-icon {
  width: 0.9em;
  height: 0.9em;
}

/* Tastatur-Fokus sichtbar machen (das Theme blendet ihn an Buttons aus) */
.docgen .btn:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* Mobil: Download über die ganze Breite, Datenschutz-Zeile zentriert
   darunter, "Eingaben leeren" zuletzt */
@media (max-width: 767.98px) {
  .docgen-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .docgen .docgen-download {
    width: 100%;
    padding: 12px 16px;
  }

  .docgen-privacy {
    order: 0;
    text-align: center;
  }

  .docgen-clear {
    align-self: center;
    margin: 6px 0 0;
  }
}

/* --- Hinweise unter der grauen Fläche ------------------------------------ */
.docgen-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
  padding: 0 4px;
  font-size: 14.9px;
  line-height: 26px;
}

@media (min-width: 768px) {
  .docgen-notes {
    gap: 4px;
    margin-top: 34px;
    padding: 0 40px;
  }
}

@media (min-width: 992px) {
  .docgen-notes {
    padding: 0 51px;
  }
}

.docgen-notes p {
  display: flex;
  align-items: flex-start;
  gap: 8.5px;
  margin: 0;
}

.docgen-notes-icon {
  flex: none;
  width: 17px;
  height: 17px;
  margin-top: 4px;
  color: var(--bs-primary);
}

/* --- Hinweis-Dialog nach dem Download ------------------------------------ */
.docgen-dialog {
  width: calc(100% - 2rem);
  max-width: 34rem;
  padding: 0;
  border: 0;
  border-radius: var(--bs-border-radius);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.25);
  background: #fff;
  color: var(--bs-body-color);
}

/* Browser ohne <dialog>-Unterstützung: geschlossen ausblenden */
.docgen-dialog:not([open]) {
  display: none;
}

.docgen-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.docgen-dialog-body {
  padding: 2rem;
}

.docgen-dialog-title {
  margin: 0 0 1rem;
  font-family: "Open Sans Condensed", "Open Sans", Arial, sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--bs-primary);
}

.docgen-dialog-steps {
  margin: 0 0 1.75rem;
  padding-left: 1.25rem;
}

.docgen-dialog-steps li + li {
  margin-top: 0.75rem;
}

@media (max-width: 575.98px) {
  .docgen-dialog-body {
    padding: 1.5rem;
  }
}

.docgen-dialog-close {
  width: 100%;
}

@media (min-width: 576px) {
  .docgen-dialog-close {
    width: auto;
  }
}
