form {
    width: calc(100% - 80px);
    margin: 40px auto;
    padding: 40px;
    background: url(../fileadmin/templatefiles/images/bg_weiss.jpg) left top repeat;
}

/* ====== Überschriften ====== */

h3.headline-form {
    padding-bottom: 8px;
    font-size: 18px;
    border-bottom: 2px solid #e5e5e5;
    color: #2c3e50;
}

h4 .headline-form {
    margin-top: 25px;
    color: #3f86c7;
    font-size: 14px;
}


/* ====== Tabs ====== */

.tabs {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 40px;
    border-bottom: 2px solid #e5e5e5;
}

.tab {
    flex: 1;
    background: #ddd;
    border: none;
    padding: 10px 18px;
    cursor: pointer;
    font-size: 14px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    border-bottom-left-radius: 0px;
    border-bottom-right-radius: 0px;
    transition: all 0.2s ease;
}

.tab:hover {
    background: #ccc;
}

.tab.active {
    background: #2980b9;
    color: white;
    font-weight: bold;
}

.tab-content {
    min-height: 400px;
    background: #ffffff;
    padding: 20px;
    border: 1px solid #e5e5e5;
    border-top: none;
    border-radius: 0 6px 6px 6px;
}

/* Inhalte ausblenden */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* ====== Form-Row Inline ====== */
.form-row {
    display: flex;
    align-items: center;
    margin-top: 15px;
    gap: 15px;
    flex-wrap: wrap;
}

/* Labels links, feste Breite */
.form-row > label:first-child {
    width: 180px;
    flex-shrink: 0;
    font-weight: normal;
    margin: 0;
}

/* Inputs flexibel */
.form-row input[type="text"],
.form-row input[type="date"],
.form-row select,
.form-row textarea {
    flex: 1;
    margin-top: 0;
}

/* Speziell für Geburtstags-Selects */
.form-row select[name="geburtsjahr"],
.form-row select[name="geburtsmonat"],
.form-row select[name="geburtstag"] {
    flex: 1;
    min-width: 80px;
}

/* Textareas etwas höher */
.form-row textarea {
    min-height: 80px;
}

/* Checkbox/Radio-Blöcke innerhalb .form-row bündig mit den Inputs ausrichten */
.form-row > div {
    flex: 1;
    min-width: 0;
}

/* Mehr Abstand zwischen einzelnen Checkbox/Radio-Optionen */
.form-row > div + div:has(input[type="checkbox"]),
.form-row > div + div:has(input[type="radio"]) {
    margin-top: 8px;
}

/* ====== Labels ====== */

label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

/* Pflichtstern */
label.required::after {
    content: " *";
    color: #c0392b;
}

/* ====== Inputs ====== */

input[type="text"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    margin-top: 5px;
    border-radius: 5px;
    border: 1px solid #ccd1d9;
    font-size: 14px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

textarea {
    resize: vertical;
    min-height: 90px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #2980b9;
    outline: none;
    box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.15);
}

/* ====== Select nebeneinander (Geburtsdatum) ====== */

select[name="geburtstag"],
select[name="geburtsmonat"],
select[name="geburtsjahr"] {
    width: 32%;
    display: inline-block;
}

select[name="geburtsjahr"] {
    margin-right: 0;
}

/* ====== Checkbox & Radio – Custom Styling ====== */

/*
 * Verstecke den nativen Browser-Input, aber behalte ihn zugänglich.
 * Das sichtbare Element wird über ::before des Labels erzeugt.
 */
input[type="checkbox"],
input[type="radio"] {
    /* Komplett aus dem Flow nehmen, aber für Screenreader erreichbar halten */
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    pointer-events: none;
}

/*
 * Jedes Label, das direkt einen Checkbox-/Radio-Input enthält,
 * wird als Flex-Zeile dargestellt.
 */
label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: normal;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    margin-top: 12px;
    margin-bottom: 4px;
    user-select: none;
    line-height: 1.4;
}

/* Pseudo-Element als sichtbares Kästchen / Kreis */
label:has(input[type="checkbox"])::before,
label:has(input[type="radio"])::before {
    content: "";
    display: inline-flex;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #ccd1d9;
    background: #fff;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    order: -1; /* Vor dem Text */
}

/* Checkbox: abgerundetes Quadrat */
label:has(input[type="checkbox"])::before {
    border-radius: 4px;
}

/* Radio: voller Kreis */
label:has(input[type="radio"])::before {
    border-radius: 50%;
}

/* Hover-Zustand */
label:has(input[type="checkbox"]):hover::before,
label:has(input[type="radio"]):hover::before {
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.12);
}

/* Focus-Zustand (Tastaturnavigation) */
label:has(input[type="checkbox"]:focus-visible)::before,
label:has(input[type="radio"]:focus-visible)::before {
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.25);
}

/* Checked-Zustand: Hintergrund blau */
label:has(input[type="checkbox"]:checked)::before,
label:has(input[type="radio"]:checked)::before {
    background: #2980b9;
    border-color: #2980b9;
}

/* Checkbox: Häkchen via clip-path */
label:has(input[type="checkbox"]:checked)::after {
    content: "";
    position: absolute;
    /* wird relativ zum Label positioniert – Label braucht position:relative */
    width: 11px;
    height: 6px;
    border-left: 2.5px solid #fff;
    border-bottom: 2.5px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
    pointer-events: none;
}

/* Damit das ::after korrekt über dem ::before liegt */
label:has(input[type="checkbox"]) {
    position: relative;
}

/* Häkchen genau über das Kästchen setzen */
label:has(input[type="checkbox"]:checked)::after {
    /* 
     * Das Kästchen ist 20px breit.
     * Wir platzieren ::after links beginnend (gap:10px vom Rand).
     */
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-60%) rotate(-45deg);
    margin-top: -1px;
}

/* Radio: innerer Punkt */
label:has(input[type="radio"]:checked)::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    pointer-events: none;
}

label:has(input[type="radio"]) {
    position: relative;
}

/* Datenschutz-Checkbox (steht nicht in .form-row > div) */
label:has(input[type="checkbox"][name="datenschutz"]) {
    margin-top: 20px;
}

/* ====== Button ====== */

button {
    margin-top: 30px;
    background: #2980b9;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

button:hover {
    background: #1f6391;
}

button:active {
    transform: scale(0.98);
}

/* ====== Trennlinie ====== */

hr {
    margin: 35px 0;
    border: none;
    border-top: 1px solid #e5e5e5;
}

/* Umfrage */

fieldset {
    border: none;
}

.radio-group {
    display: flex;
    gap: 15px;
    margin: 10px 0 25px 0;
    align-items: center;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* ====== Responsive ====== */

@media (max-width: 768px) {

    form {
        padding: 20px;
        margin: 20px;
    }

    .form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .form-row > label:first-child {
        width: 100%;
        margin-bottom: 5px;
    }

    .form-row input,
    .form-row select,
    .form-row textarea {
        width: 100%;
        flex: none;
    }

    select[name="geburtstag"],
    select[name="geburtsmonat"],
    select[name="geburtsjahr"] {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
}