/* TYPO3 Forms – keine zusätzliche Klasse und kein CSS-Präprozessor nötig. */
form:has([name^="tx_form_formframework["]) {
  --form-blue: #063f8c;
  --form-yellow: #ffb400;
  --form-bg: #f2f7fc;
  width: 100%;
  max-width: 52rem;
  margin-inline: auto;
  padding: clamp(1rem, 4vw, 2rem);
  border: 1px solid #d6e2ef;
  border-radius: .75rem;
  background: #fff;
  box-shadow: 0 12px 36px #063f8c0a;
  box-sizing: border-box;
  color: #243b53;
  font-size: 1rem;
  line-height: 1.5;

  & *, & *::before, & *::after { box-sizing: border-box; }
  & [hidden] { display: none !important; }
  & h2 { margin: 0 0 1.5rem; color: var(--form-blue); }
  & fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
  & > fieldset {
    margin-bottom: 1.25rem;
    padding: clamp(1rem, 3vw, 1.5rem);
    border-radius: .625rem;
    background: var(--form-bg);
  }
  & > fieldset:not(:has(input, select, textarea)) { padding: 0; background: none; }
  & legend {
    float: left;
    width: 100%;
    margin-bottom: .75rem;
    padding: 0;
    color: var(--form-blue);
    font-size: 1rem;
    font-weight: 600;
  }
  & legend + * { clear: both; }
  & > fieldset > legend { font-size: 1.125rem; }
  & > fieldset > legend::after {
    content: "";
    display: block;
    width: 2rem;
    height: 3px;
    margin-top: .5rem;
    background: var(--form-yellow);
  }
  & .form-element { margin-bottom: 1rem; }
  & fieldset > .form-element:last-child { margin-bottom: 0; }
  & .form-label { display: block; margin-bottom: .375rem; font-weight: 600; }
  & .required { color: var(--form-blue); }
  & .form-control {
    display: block;
    width: 100%;
    min-height: 3rem;
    padding: .75rem;
    border: 1px solid #7b91ac;
    border-radius: .375rem;
    background: #fff;
    color: inherit;
    font: inherit;
  }
  & .form-control::placeholder { color: #65758a; opacity: 1; }
  & textarea.form-control { min-height: 8rem; resize: vertical; }
  & :is([role="group"], [role="radiogroup"]) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
    gap: .5rem;
  }
  & .form-check { margin: 0; padding: 0; }
  & .form-check-wrapping-label {
    display: flex;
    align-items: center;
    gap: .625rem;
    height: 100%;
    min-height: 3rem;
    padding: .625rem .75rem;
    border: 1px solid #cad9eb;
    border-radius: .375rem;
    background: #fff;
    cursor: pointer;
  }
  & .form-check-wrapping-label:has(:checked) { border-color: var(--form-blue); }
  & .form-check-input {
    flex: 0 0 auto;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    accent-color: var(--form-blue);
    cursor: pointer;
  }
  & .form-check-label { overflow-wrap: anywhere; }
  & :is(.form-control, .form-check-input, button):focus-visible {
    outline: 3px solid var(--form-blue);
    outline-offset: 3px;
  }
  & .form-control:disabled { background: #e9eef4; cursor: not-allowed; }
  & :is(.form-control[aria-invalid="true"], .form-control.is-invalid) { border-color: #b42318; }
  & :is(.invalid-feedback, .error.help-block) { margin-top: .375rem; color: #b42318; }
  & :is(.form-text, .help-block) { font-size: .875rem; }
  & .form-navigation { display: flex; flex-wrap: wrap; gap: .75rem; }
  & .form-navigation button {
    min-height: 3rem;
    padding: .75rem 1.5rem;
    border: 1px solid var(--form-yellow);
    border-radius: .375rem;
    background: var(--form-yellow);
    color: var(--form-blue);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }
  & .form-navigation button:hover { background: var(--form-blue); border-color: var(--form-blue); color: #fff; }
  & .form-navigation button:disabled { opacity: .6; cursor: not-allowed; }
  & .form-navigation .btn-secondary { background: #fff; border-color: var(--form-blue); color: var(--form-blue); }
  & .visually-hidden,
  &[id^="service-"] fieldset:has(> :is([id$="-geraet"], [id$="-tympanometer_01"], [id$="-hoergeraete_anpassungssystemeja"], [id$="-andereja"])) > legend {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  @media (max-width: 36rem) {
    & :is([role="group"], [role="radiogroup"]) { grid-template-columns: 1fr; }
    & .form-navigation button { width: 100%; }
  }
}

/* Ergänzungen für das Beratungsformular. */
form[id^="beratungvereinbaren-"] {
  max-width: 46rem;

  & h2 {
    margin-bottom: .5rem;
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    line-height: 1.2;
  }
  & .consultation-intro { margin-bottom: 1.5rem; color: #51647c; }
  & .consultation-intro p { margin: 0; }
  & [id$="-product-context"] {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: .5rem 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f2f7fc;
  }
  & [id$="-product-context"]::before {
    content: "Produktbild folgt";
    display: grid;
    place-items: center;
    grid-column: 1;
    grid-row: 1 / span 2;
    min-height: 5rem;
    padding: .5rem;
    border: 1px dashed #7b91ac;
    border-radius: .375rem;
    color: #51647c;
    font-size: .75rem;
    text-align: center;
  }
  & [id$="-product-context"] > .form-element {
    grid-column: 2;
    min-width: 0;
    margin: 0;
  }
  & [id$="-product-context"] .form-label { margin: 0; font-size: .875rem; font-weight: 400; }
  & [id$="-text-1"] {
    min-height: 2rem;
    padding: .25rem 0;
    border: 0;
    background: transparent;
    color: #063f8c;
    font-weight: 700;
    text-overflow: ellipsis;
  }
  & [id$="-product-context"] p { margin: 0; color: #51647c; font-size: .875rem; }
  & .consultation-privacy { margin-block: 1rem; font-size: .875rem; color: #51647c; }
  & .consultation-privacy p { margin: 0; }
  & .consultation-privacy a { color: #063f8c; text-underline-offset: .15em; }
  & .form-navigation button { width: 100%; }
  & .consultation-note { margin: .75rem 0; color: #51647c; font-size: .875rem; text-align: center; }
  & .consultation-required { margin: 0; color: #51647c; font-size: .8125rem; }
  @media (max-width: 30rem) {
    & [id$="-product-context"] { grid-template-columns: 3.75rem minmax(0, 1fr); gap: .5rem .75rem; }
    & [id$="-product-context"]::before { min-height: 4rem; }
  }
}

/* TYPO3 Felogin – passend zu den AURITEC-Formularen. */
form:has(#tx-felogin-input-username) {
  width: 100%;
  max-width: 30rem;
  margin-inline: auto;
  padding: clamp(1rem, 4vw, 2rem);
  border: 1px solid #d6e2ef;
  border-radius: .75rem;
  background: #fff;
  box-shadow: 0 12px 36px #063f8c0a;
  box-sizing: border-box;
  color: #243b53;
  font-size: 1rem;
  line-height: 1.5;

  & * { box-sizing: border-box; }
  & fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
  & legend {
    float: left;
    width: 100%;
    margin-bottom: 1.5rem;
    padding: 0;
    color: #063f8c;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    line-height: 1.2;
  }
  & legend::after {
    content: "";
    display: block;
    width: 2rem;
    height: 3px;
    margin-top: .75rem;
    background: #ffb400;
  }
  & legend + div { clear: both; }
  & fieldset > div:has(input:not([type="hidden"])) { margin-bottom: 1rem; }
  & label { display: block; margin-bottom: .375rem; font-weight: 600; }
  & input:is([type="text"], [type="password"]) {
    display: block;
    width: 100%;
    min-height: 3rem;
    padding: .75rem;
    border: 1px solid #7b91ac;
    border-radius: .375rem;
    background: #fff;
    color: inherit;
    font: inherit;
  }
  & input[type="submit"] {
    width: 100%;
    min-height: 3rem;
    margin-top: .5rem;
    padding: .75rem 1.5rem;
    border: 1px solid #ffb400;
    border-radius: .375rem;
    background: #ffb400;
    color: #063f8c;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }
  & input[type="submit"]:hover { background: #063f8c; border-color: #063f8c; color: #fff; }
  & input:focus-visible { outline: 3px solid #063f8c; outline-offset: 3px; }
  & input:disabled { opacity: .6; cursor: not-allowed; }
  & input[aria-invalid="true"] { border-color: #b42318; }
  & a { color: #063f8c; text-underline-offset: .15em; }
  & :is(.felogin-hidden, [hidden]) { display: none !important; }
}
