/* ==========================================================================
   KE Form Builder Widget (v0.16.0)
   ========================================================================== */

/* Form Container */
.ke-form-builder {
    width: 100%;
}

.ke-form-builder form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ke-space-5);
    margin: 0;
    padding: 0;
}

/* Form Fields Container (Phantom-Klasse, nirgends im Markup — behalten als
   Flex-Fallback falls jemand eigenen HTML-Container mit dieser Klasse nutzt). */
.ke-form-fields {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ke-space-5);
    width: 100%;
}

/* v0.26.8: Step-Container ist der echte Grid-Container. `--ke-form-cols` wird
   vom `form_columns`-Control gesetzt (Default 1 Spalte). `row-gap` und
   `column-gap` kommen aus den jeweiligen Widget-Controls. */
.ke-form-step {
    display: grid;
    grid-template-columns: repeat(var(--ke-form-cols, 1), minmax(0, 1fr));
    width: 100%;
}

/* Auf Mobile immer 1-Spaltig, unabhängig vom Desktop-Setting (Felder nebeneinander
   auf kleinen Screens sind kaum lesbar). Elementor-Responsive-Control kann für
   Tablet/Mobile noch gezielt auf 2 Spalten zurück, falls gewünscht. */
@media (max-width: 767px) {
    .ke-form-step {
        --ke-form-cols: 1;
    }
}

/* Form Fields */
.ke-form-field {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.ke-field-width-100 {
    flex: 0 0 100%;
    max-width: 100%;
}

.ke-field-width-75 {
    flex: 0 0 calc(75% - 15px);
    max-width: calc(75% - 15px);
}

.ke-field-width-66 {
    flex: 0 0 calc(66.666% - 13.333px);
    max-width: calc(66.666% - 13.333px);
}

.ke-field-width-50 {
    flex: 0 0 calc(50% - 10px);
    max-width: calc(50% - 10px);
}

.ke-field-width-33 {
    flex: 0 0 calc(33.333% - 13.333px);
    max-width: calc(33.333% - 13.333px);
}

.ke-field-width-25 {
    flex: 0 0 calc(25% - 15px);
    max-width: calc(25% - 15px);
}

/* Form Footer & Button Alignment */
.ke-form-footer {
    width: 100%;
    display: flex;
}

.ke-form-submit-align-left .ke-form-footer {
    justify-content: flex-start;
}

.ke-form-submit-align-center .ke-form-footer {
    justify-content: center;
}

.ke-form-submit-align-right .ke-form-footer {
    justify-content: flex-end;
}

.ke-form-submit-align-stretch .ke-form-footer {
    justify-content: stretch;
}

.ke-form-submit-align-stretch .ke-form-submit {
    width: 100%;
}

/* Labels */
/* v0.25.8: color: inherit — Labels erben die Textfarbe vom Parent (Section/Popup).
   Vorher war sie hart auf var(--ke-text) gesetzt und damit auf dunklen Hintergründen
   (z.B. Optin-Pop-Ups) unlesbar. Für Overrides steht weiterhin das Widget-Control
   „Label-Farbe" zur Verfügung. */
.ke-form-label {
    display: block;
    margin-bottom: var(--ke-space-2);
    font-weight: 600;
    font-size: 14px;
    color: inherit;
}

.ke-form-required {
    color: var(--ke-danger);
    margin-left: 2px;
}

/* Input Fields
 *
 * iOS-Safari-Härtung (v0.39.4):
 *  - `-webkit-appearance: none` + `appearance: none` deaktiviert das implizite
 *    UA-Styling (Round-Borders, Inner-Shadow), das auf iOS sonst eine eigene
 *    intrinsische Breite mitbringt und `width: 100%` aushebelt.
 *  - `display: block` (statt UA-Default `inline-block`) macht aus dem Input
 *    einen Block-Container — dann ist `width: 100%` deterministisch die volle
 *    Parent-Breite, unabhängig vom `size`-Attribut und Font-Größe.
 *  - `min-width: 0` neutralisiert die `min-content`-Auto-Berechnung in Grid-
 *    /Flex-Containern, die das Element sonst auf eine Default-Mindestbreite
 *    zwingt (klassisches iOS-Safari-Symptom: Inputs sind schmaler als der
 *    Field-Wrapper und reagieren nur auf Font-Size-Vergrößerung).
 *  - `font-size: 16px` minimal — verhindert den iOS-Zoom-Bei-Focus, der sonst
 *    bei kleineren Font-Sizes greift. Vorher 14px → führte zum Zoom-In beim
 *    Antippen eines Inputs.
 *  - `border-radius: 0` auf textuelle Inputs neutralisiert iOS-Default-Radius.
 */
.ke-form-input,
.ke-form-textarea,
.ke-form-select {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ke-text);
    background-color: var(--ke-card-solid);
    border: 1px solid var(--ke-gray-200);
    border-radius: var(--ke-radius-sm);
    transition: border-color var(--ke-transition-fast), box-shadow var(--ke-transition-fast);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.ke-form-input:focus,
.ke-form-textarea:focus,
.ke-form-select:focus {
    outline: none;
    border-color: var(--ke-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.ke-form-input::placeholder,
.ke-form-textarea::placeholder {
    color: var(--ke-gray-400);
}

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

.ke-form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23333' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
    cursor: pointer;
}

/* Radio and Checkbox Groups */
.ke-form-radio-group,
.ke-form-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ke-form-radio-group--inline,
.ke-form-checkbox-group--inline {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
}

.ke-form-radio-label,
.ke-form-checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--ke-space-2);
    cursor: pointer;
    font-size: 14px;
    color: inherit;
}

.ke-form-radio-label input[type="radio"],
.ke-form-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--ke-primary);
}

/* Acceptance Field */
/* v0.26.54: color: inherit (analog zu v0.25.8 für Form-Labels) — sonst war
   der DSGVO-Text auf dunklen Section-/Popup-Hintergründen unsichtbar.
   v0.26.55: align-items: center — Text war vertikal am oberen Rand der
   Checkbox angeklebt. Plus 14px Font-Size + 16px Checkbox als Default. */
.ke-form-acceptance-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    color: inherit;
}
.ke-form-acceptance-label .ke-acceptance-text {
    color: inherit;
}

.ke-form-acceptance-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--ke-primary);
}

.ke-form-acceptance-label a {
    color: var(--ke-primary);
    text-decoration: underline;
}

.ke-form-acceptance-label a:hover {
    color: var(--ke-primary-dark);
}

/* Date/Time Fields */
.ke-form-input[type="date"],
.ke-form-input[type="time"] {
    padding: 10px 15px;
}

/* HTML Content Field */
.ke-form-html {
    padding: 15px;
    background: var(--ke-gray-50);
    border: 1px solid var(--ke-gray-150);
    border-radius: var(--ke-radius-sm);
    font-size: 14px;
    line-height: 1.6;
}

.ke-form-html p:last-child {
    margin-bottom: 0;
}

/* Honeypot (hidden) */
.ke-form-field--honeypot {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
}

/* Submit Button */
.ke-form-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ke-space-2);
    padding: 14px 30px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: #fff;
    background-color: var(--ke-primary);
    border: none;
    border-radius: var(--ke-radius-sm);
    cursor: pointer;
    transition: background-color var(--ke-transition-fast), transform 0.1s ease;
}

.ke-form-submit:hover {
    background-color: var(--ke-primary-dark);
}

.ke-form-submit:active {
    transform: scale(0.98);
}

.ke-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ke-form-submit .ke-form-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(var(--ke-white-rgb), 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ke-form-spin 0.8s linear infinite;
}

.ke-form-builder.ke-form-loading .ke-form-submit .ke-form-spinner {
    display: inline-block;
}

.ke-form-builder.ke-form-loading .ke-form-submit .ke-form-button-text {
    opacity: 0.7;
}

@keyframes ke-form-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Messages */
.ke-form-messages {
    margin-top: var(--ke-space-5);
    width: 100%;
}

.ke-form-success,
.ke-form-error {
    padding: 15px 20px;
    border-radius: var(--ke-radius-sm);
    font-size: 14px;
    line-height: 1.5;
}

.ke-form-success {
    background-color: var(--ke-success-bg);
    border: 1px solid var(--ke-success);
    color: #155724;
}

.ke-form-error {
    background-color: var(--ke-danger-bg);
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.ke-form-field-error {
    margin-top: 5px;
    font-size: 12px;
    color: var(--ke-danger);
}

.ke-form-field.has-error .ke-form-input,
.ke-form-field.has-error .ke-form-textarea,
.ke-form-field.has-error .ke-form-select {
    border-color: var(--ke-danger);
}

/* Multi-Step Form */
.ke-form-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    padding: 0;
}

/* Progress Bar Style */
.ke-form-progress--bar {
    display: block;
    width: 100%;
    height: 8px;
    background: var(--ke-gray-150);
    border-radius: var(--ke-radius-sm);
    overflow: hidden;
}

.ke-form-progress--bar .ke-form-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ke-primary), var(--ke-success));
    border-radius: var(--ke-radius-sm);
    transition: width var(--ke-transition);
}

/* Progress Numbers Style */
.ke-form-progress--numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.ke-form-progress--numbers .ke-form-progress-step {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ke-gray-150);
    color: var(--ke-gray-600);
    font-weight: 600;
    font-size: 14px;
    transition: var(--ke-transition);
}

.ke-form-progress--numbers .ke-form-progress-step.active {
    background: var(--ke-primary);
    color: #fff;
}

.ke-form-progress--numbers .ke-form-progress-step.completed {
    background: var(--ke-success);
    color: #fff;
}

.ke-form-progress--numbers .ke-form-progress-connector {
    width: 40px;
    height: 3px;
    background: var(--ke-gray-150);
}

.ke-form-progress--numbers .ke-form-progress-connector.completed {
    background: var(--ke-success);
}

/* Progress Dots Style */
.ke-form-progress--dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--ke-space-3);
}

.ke-form-progress--dots .ke-form-progress-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ke-gray-150);
    transition: var(--ke-transition);
}

.ke-form-progress--dots .ke-form-progress-dot.active {
    background: var(--ke-primary);
    transform: scale(1.3);
}

.ke-form-progress--dots .ke-form-progress-dot.completed {
    background: var(--ke-success);
}

/* Form Steps — v0.26.10: Multi-Step-Hider nutzt `:not(.ke-step-active)`
   statt einer separaten Override-Regel. Die vorherige Version hatte zwei
   konkurrierende Regeln: `.ke-form-step { display: none }` + `.ke-form-step.ke-step-active { display: flex }`.
   Die zweite war spezifischer und überschrieb damit auch das neue
   `.ke-form-step { display: grid }` (v0.26.8) — Spalten-Control wirkte daher
   nicht. Jetzt greift die Grid-Definition ungestört, nur inaktive Steps
   werden explizit versteckt. */
.ke-form-step:not(.ke-step-active) {
    display: none;
}

.ke-form-step-title {
    flex: 0 0 100%;
    margin: 0 0 15px;
    font-size: 20px;
    font-weight: 600;
    color: inherit;
}

/* Step Navigation */
.ke-form-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    width: 100%;
    margin-top: 10px;
}

.ke-form-nav-prev,
.ke-form-nav-next {
    display: inline-flex;
    align-items: center;
    gap: var(--ke-space-2);
    padding: var(--ke-space-3) var(--ke-space-6);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--ke-radius-sm);
    cursor: pointer;
    transition: var(--ke-transition-fast);
}

.ke-form-nav-prev {
    color: var(--ke-gray-600);
    background: var(--ke-gray-150);
    border: none;
}

.ke-form-nav-prev:hover {
    background: var(--ke-gray-150);
}

.ke-form-nav-next {
    color: #fff;
    background: var(--ke-primary);
    border: none;
    margin-left: auto;
}

.ke-form-nav-next:hover {
    background: var(--ke-primary-dark);
}

/* Draft Resume Notice */
.ke-form-draft-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    width: 100%;
    padding: 12px 15px;
    margin-bottom: var(--ke-space-5);
    background: var(--ke-warning-bg);
    border: 1px solid var(--ke-warning);
    border-radius: var(--ke-radius-sm);
    font-size: 14px;
    color: #856404;
}

.ke-form-draft-notice-buttons {
    display: flex;
    gap: 10px;
}

.ke-form-draft-notice button {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 3px;
    cursor: pointer;
    transition: var(--ke-transition-fast);
}

.ke-form-draft-resume {
    color: #fff;
    background: var(--ke-success);
    border: none;
}

.ke-form-draft-resume:hover {
    background: #218838;
}

.ke-form-draft-discard {
    color: #856404;
    background: transparent;
    border: 1px solid #856404;
}

.ke-form-draft-discard:hover {
    background: rgba(133, 100, 4, 0.1);
}

/* Editor Placeholder */
.ke-form-editor-notice {
    padding: 30px;
    background: var(--ke-gray-50);
    border: 2px dashed var(--ke-gray-150);
    border-radius: var(--ke-radius-md);
    text-align: center;
}

.ke-form-editor-notice h4 {
    margin: 0 0 10px;
    font-size: 18px;
    color: var(--ke-text);
}

.ke-form-editor-notice p {
    margin: 0;
    font-size: 14px;
    color: var(--ke-gray-600);
}

/* Responsive */
@media (max-width: 767px) {
    .ke-form-builder form {
        gap: 15px;
    }

    .ke-field-width-75,
    .ke-field-width-66,
    .ke-field-width-50,
    .ke-field-width-33,
    .ke-field-width-25 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .ke-form-radio-group--inline,
    .ke-form-checkbox-group--inline {
        flex-direction: column;
    }

    .ke-form-navigation {
        flex-direction: column;
    }

    .ke-form-nav-prev,
    .ke-form-nav-next {
        width: 100%;
        justify-content: center;
    }

    .ke-form-draft-notice {
        flex-direction: column;
        text-align: center;
    }
}

/* ==========================================================================
   JVaffili Schnellkauf Overlay (v0.21.0)
   Wird vom Form-Builder-Widget nach submit_success eingeblendet,
   während zu jvaffili.net weitergeleitet wird. Styling-Werte kommen via
   CSS Custom Properties aus den Form-Settings.
   ========================================================================== */

.kjaf-schnellkauf-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--kjaf-bg, rgba(250, 250, 250, 0.8));
    z-index: 9999;
    animation: kjaf-fade-in 200ms ease-out;
}

.kjaf-schnellkauf-overlay--viewport {
    position: fixed;
    inset: 0;
    z-index: 999999;
}

.kjaf-schnellkauf-overlay__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
}

.kjaf-schnellkauf-overlay__spinner {
    width: 56px;
    height: 56px;
    border: 4px solid var(--kjaf-spinner, #CCCCCC);
    border-top-color: var(--kjaf-spinner-acc, #333333);
    border-radius: 50%;
    animation: kjaf-spin 900ms linear infinite;
}

.kjaf-schnellkauf-overlay__message {
    color: var(--kjaf-text, #333333);
    font-family: var(--kjaf-font, inherit);
    font-size: var(--kjaf-font-size, 16px);
    font-weight: var(--kjaf-font-weight, 400);
    text-align: center;
    line-height: 1.4;
}

@keyframes kjaf-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes kjaf-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .kjaf-schnellkauf-overlay { animation: none; }
    .kjaf-schnellkauf-overlay__spinner { animation-duration: 2s; }
}
