/* Escape Academy Form Builder – Frontend Styles */

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.eaf-form-wrapper {
    width: 100%;
}

.eaf-form {
    width: 100%;
}

/* ── Field Grid ──────────────────────────────────────────────────────────── */
.eaf-fields-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0 4%;
}

.eaf-field-wrap {
    width: 100%;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.eaf-col-full {
    width: 100%;
}

.eaf-col-half {
    width: 48%;
}

@media (max-width: 600px) {
    .eaf-col-half {
        width: 100%;
    }
}

/* ── Hidden (Conditional) ────────────────────────────────────────────────── */
.eaf-hidden {
    display: none !important;
}

/* ── Labels ──────────────────────────────────────────────────────────────── */
.eaf-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.eaf-required-star {
    color: #c00;
    margin-left: 2px;
}

.eaf-field-description {
    margin: 4px 0 8px;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.eaf-input,
.eaf-textarea,
.eaf-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 0;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
    background: #fff;
    color: #333;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}

.eaf-input:focus,
.eaf-textarea:focus,
.eaf-select:focus {
    outline: none;
    border-color: #1a1a1a;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .12);
}

.eaf-textarea {
    resize: vertical;
    min-height: 120px;
}

.eaf-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* ── Char Counter ────────────────────────────────────────────────────────── */
.eaf-char-count {
    font-size: 12px;
    color: #888;
    text-align: right;
    margin-top: 4px;
}

.eaf-char-count.eaf-char-warn {
    color: #c00;
    font-weight: 600;
}

/* ── Consent-Felder: Schriftgröße vererben ───────────────────────────────── */
.eaf-consent-field {
    font-size: var(--eaf-consent-size, 12px);
}

.eaf-consent-field .eaf-label,
.eaf-consent-field .eaf-legend,
.eaf-consent-field .eaf-checkbox-text,
.eaf-consent-field .eaf-radio-label,
.eaf-consent-field .eaf-text-content {
    font-size: inherit;
}

/* ── Fieldsets / Radio / Checkbox ────────────────────────────────────────── */
.eaf-fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.eaf-legend {
    font-weight: 600;
    margin-bottom: 8px;
    padding: 0;
}

/* Checkbox-Option: Checkbox + Text getrennt, damit Links im Text klickbar bleiben */
.eaf-checkbox-option,
.eaf-radio-option {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 6px;
}

/* ── Sichtbarkeit der Standard-Felder theme-fest erzwingen ──
   Manche Themes (z. B. Divi) blenden Formular-Steuerelemente mit hoher
   Spezifität und/oder !important aus. Wir erzwingen daher die Sichtbarkeit der
   normalen Felder. Ausgenommen: Checkbox/Radio (werden unten selbst gezeichnet),
   das „Anderes"-Textfeld (.eaf-other-text, per JS ein-/ausgeblendet), versteckte
   Inputs und der Honeypot (über .eaf-hp-Container versteckt). */
.eaf-form input:not(.eaf-checkbox):not(.eaf-radio):not(.eaf-other-text):not([type="hidden"]),
.eaf-form select,
.eaf-form textarea {
    display: revert !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    pointer-events: auto !important;
    clip: auto !important;
    clip-path: none !important;
    transform: none !important;
}

/* ── Checkbox & Radio selbst zeichnen (komplett theme-unabhängig) ──
   Das native Feld wird unsichtbar, bleibt aber funktionsfähig (Klick erfolgt
   über das verknüpfte Label). Dadurch ist es egal, ob ein Theme native
   Checkboxen/Radios ausblendet – das sichtbare Kästchen/der Punkt sind eigene
   Elemente. */
.eaf-checkbox-option,
.eaf-radio-option {
    position: relative;
}

.eaf-form .eaf-checkbox,
.eaf-form .eaf-radio {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    pointer-events: none;
}

/* Sichtbares Kästchen = das (leere) Label .eaf-checkbox-tick */
.eaf-checkbox-tick {
    position: relative;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin: 1px 10px 0 0;
    border: 2px solid #1a1a1a;
    border-radius: 4px;
    background: #fff;
    box-sizing: border-box;
    cursor: pointer;
    display: inline-block;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.eaf-checkbox-tick::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
}

.eaf-form .eaf-checkbox:checked + .eaf-checkbox-tick {
    background: #1a1a1a;
    border-color: #1a1a1a;
}

.eaf-form .eaf-checkbox:checked + .eaf-checkbox-tick::after {
    opacity: 1;
}

.eaf-form .eaf-checkbox:focus-visible + .eaf-checkbox-tick {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .2);
}

/* Der Textinhalt ist ein eigenständiges span – Klick öffnet Links, nicht die Checkbox */
.eaf-checkbox-text {
    font-size: 15px;
    line-height: 1.4;
    cursor: default;
}

.eaf-checkbox-text a {
    color: #1a1a1a;
    text-decoration: underline;
    cursor: pointer;
}

.eaf-radio-label {
    position: relative;
    padding-left: 30px;
    font-size: 15px;
    cursor: pointer;
    line-height: 1.4;
}

.eaf-radio-label::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1px;
    width: 20px;
    height: 20px;
    border: 2px solid #1a1a1a;
    border-radius: 50%;
    background: #fff;
    box-sizing: border-box;
    transition: box-shadow .15s ease;
}

.eaf-radio-label::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1a1a1a;
    opacity: 0;
    transition: opacity .15s ease;
}

.eaf-form .eaf-radio:checked + .eaf-radio-label::after {
    opacity: 1;
}

.eaf-form .eaf-radio:focus-visible + .eaf-radio-label::before {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .2);
}

/* Radio-Gruppe: untereinander (Standard) */
.eaf-radio-group.eaf-radio-vertical .eaf-radio-option {
    margin-bottom: 6px;
}

/* Radio-/Checkbox-Gruppe: nebeneinander – Optionen brechen als Ganzes um,
   Button/Checkbox und Text bleiben dabei immer zusammen.
   !important + .eaf-form-Präfix: einige Themes (z. B. Divi) überschreiben das
   display von Form-Elementen mit hoher Spezifität – sonst fällt die Gruppe
   wieder in die vertikale Darstellung zurück. */
.eaf-form .eaf-radio-group.eaf-radio-horizontal,
.eaf-form .eaf-checkbox-group.eaf-checkbox-horizontal {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px 28px;
}

.eaf-form .eaf-radio-group.eaf-radio-horizontal .eaf-radio-option,
.eaf-form .eaf-checkbox-group.eaf-checkbox-horizontal .eaf-checkbox-option {
    margin-bottom: 0;
    flex: 0 0 auto;
    max-width: 100%;
}

/* Innerhalb einer Option bleiben Steuerelement und Text zusammen */
.eaf-form .eaf-checkbox-option,
.eaf-form .eaf-radio-option {
    display: flex !important;
    align-items: flex-start;
}

.eaf-other-text {
    margin-top: 8px;
    width: 100%;
}

/* ── File Input ──────────────────────────────────────────────────────────── */
.eaf-file-input {
    display: block;
    width: 100%;
    padding: 8px 0;
    font-size: 14px;
    cursor: pointer;
}

.eaf-file-hint {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

/* ── Typography Fields ───────────────────────────────────────────────────── */
.eaf-heading {
    margin: 0 0 12px;
}

.eaf-subheading {
    margin: 0 0 10px;
}

.eaf-separator {
    border: none;
    border-top: 1px solid #ddd;
    margin: 8px 0;
    width: 100%;
}

.eaf-text-content {
    margin-bottom: 4px;
    line-height: 1.6;
}

.eaf-text-content a {
    color: #1a1a1a;
    text-decoration: underline;
}

/* ── Submit Button ───────────────────────────────────────────────────────── */
.eaf-submit-row {
    margin-top: 8px;
}

.eaf-submit-btn {
    display: inline-block;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 0;
    padding: 13px 32px;
    font-size: 16px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: .02em;
    transition: background .15s;
    -webkit-appearance: none;
    appearance: none;
}

.eaf-submit-btn:hover {
    background: #000000;
}

.eaf-submit-btn:focus {
    outline: 3px solid rgba(0, 0, 0, .35);
    outline-offset: 2px;
}

.eaf-submit-btn:disabled {
    opacity: .65;
    cursor: not-allowed;
}

/* ── Messages ────────────────────────────────────────────────────────────── */
.eaf-form-messages {
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: 0;
    font-size: 15px;
}

.eaf-form-messages.eaf-success {
    background: #edfaf0;
    border-left: 4px solid #2e7d32;
    color: #1b5e20;
}

.eaf-form-messages.eaf-error {
    background: #fef0f0;
    border-left: 4px solid #c62828;
    color: #b71c1c;
}

.eaf-success-message {
    font-weight: 600;
}

/* ── Field Error State ───────────────────────────────────────────────────── */
.eaf-field-error .eaf-input,
.eaf-field-error .eaf-textarea,
.eaf-field-error .eaf-select {
    border-color: #c62828;
    box-shadow: 0 0 0 2px rgba(198, 40, 40, .15);
}

.eaf-error-msg {
    display: block;
    font-size: 12px;
    color: #c62828;
    margin-top: 4px;
}

/* ── Ladeindikator ───────────────────────────────────────────────────────── */
.eaf-progress-wrap {
    margin-top: 14px;
}

.eaf-progress-bar {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.eaf-progress-fill {
    height: 100%;
    width: 30%;
    background: #1a1a1a;
    border-radius: 2px;
    animation: eaf-progress-slide 1.6s ease-in-out infinite;
}

@keyframes eaf-progress-slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.eaf-progress-msg {
    margin: 8px 0 0;
    font-size: 14px;
    color: #555;
    transition: opacity .3s;
}

/* ── Honeypot ────────────────────────────────────────────────────────────── */
.eaf-hp {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    height: 0;
    overflow: hidden;
}
