/*
 * Envio24 – Formularze (Upust + Kontakt) – Wspólne Style
 *
 * @version 1.2.1
 * @package envio24-core/assets/css/contact-forms/
 *
 * ZMIANY 1.2.1 (PL):
 * - Naprawa regresu po 1.2.0:
 *   a) Stan filled działa TYLKO gdy pole nie jest aktywnie edytowane (nie ma fokusa).
 *      Reguła :focus-within na wrapperze .e24-fi__field wygrywa nad .is-filled,
 *      więc podczas pisania zawsze widoczny jest pomarańczowy stan aktywny.
 *   b) Nowe tokeny filled mają wbudowane fallbacki z wartościami bezpośrednimi (#E9C931, #FEF6E1),
 *      żeby pole nie wpadało w czarno-białe style przeglądarki gdy token nie zostanie odczytany.
 *   c) Autofill przeglądarki uproszczony do bezpiecznego minimum – tylko zmiana tła przez
 *      box-shadow inset na samym polu tekstowym, bez modyfikacji wrapperów.
 *
 * ZMIANY 1.2.0 (PL):
 * - Wycofana z powodu regresu (czarne ramki, błędna kolejność stanów filled/focus).
 *
 * ZMIANY 1.1.0 (PL):
 * - Poprawka 1: Zwiększono odstępy między wierszami formularza (--ef-row-gap).
 * - Poprawka 2: Radio w stylu Order Form (inline, mała czcionka, bez kafelków).
 *   Grid wiersza 2 zmieniony z 2/3+1/3 na 1/2+1/2.
 * - Poprawka 3: Zmniejszono rozmiar bloku CAPTCHA (czcionka, padding, pole odpowiedzi).
 *
 * SPIS TREŚCI (PL):
 * 1. Tokeny responsywne formularza
 * 2. Kontener główny
 * 3. Nagłówek formularza
 * 4. System inputów (.e24-form)
 * 5. Radio buttons (styl Order Form – inline)
 * 6. Textarea
 * 7. CAPTCHA (matematyczna – kompaktowa)
 * 8. Checkbox RODO
 * 9. Przyciski akcji
 * 10. Komunikaty walidacji i błędów
 * 11. Panel sukcesu (po wysłaniu)
 * 12. Grid formularza i warianty kolumn
 * 13. RWD
 */

/* ========================================
 * 1. TOKENY RESPONSYWNE FORMULARZA
 * ===================================== */
.e24-form-wrapper {
    --ef-pad-y:          32px;
    --ef-pad-x:          40px;
    --ef-row-gap:        28px;
    --ef-gap-sm:         12px;

    --ef-fs-label:       13px;
    --ef-fs-input:       16px;
    --ef-fs-placeholder: 15px;
    --ef-fs-unit:        14px;
    --ef-fs-msg:         12px;
    --ef-fs-heading:     22px;
    --ef-fs-sub:         14px;

    --ef-input-min-h:    44px;
    --ef-input-pad-y:    8px;
    --ef-input-pad-x:    14px;
    --ef-radius:         6px;
    --ef-radius-lg:      10px;
}

/* ========================================
 * 2. KONTENER GŁÓWNY
 * ===================================== */
.e24-form-wrapper {
    max-width: 820px;
    margin: 0 auto;
    font-family: "Open Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--e24-text-main);
}

.e24-form-box {
    background-color: #FFFFFF;
    border-radius: var(--ef-radius-lg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: var(--ef-pad-y) var(--ef-pad-x);
}

/* ========================================
 * 3. NAGŁÓWEK FORMULARZA
 * ===================================== */
.e24-form-heading {
    margin: 0 0 6px 0;
    font-family: "Rubik", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: var(--ef-fs-heading);
    font-weight: 700;
    color: var(--e24-brand-dark);
    border-bottom: 2px solid var(--e24-orange);
    padding-bottom: 10px;
}

.e24-form-subheading {
    margin: 0 0 28px 0;
    font-size: var(--ef-fs-sub);
    color: var(--e24-text-muted);
    line-height: 1.5;
}

/* ========================================
 * 4. SYSTEM INPUTÓW
 * ===================================== */

/* Wrapper pojedynczego pola */
.e24-form .e24-fi {
    display: flex;
    flex-direction: column;
}

/* Label */
.e24-form .e24-fi__label {
    display: block;
    margin-bottom: 5px;
    font-size: var(--ef-fs-label);
    font-weight: 600;
    color: var(--e24-text-main);
}

/* Oznaczenie obowiązkowego pola */
.e24-form .e24-fi__label .e24-required {
    color: var(--e24-orange);
    margin-left: 2px;
    font-weight: 700;
}

/* Opakowanie pola */
.e24-form .e24-fi__field {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--e24-input-border);
    border-radius: var(--ef-radius);
    background-color: #FFFFFF;
    overflow: hidden;
    transition: border-color 0.2s ease-out, background-color 0.2s ease-out, box-shadow 0.2s ease-out;
    box-shadow: none;
}

/*
 * Stan FOKUS – pomarańcz (bez zmian).
 * :focus-within na wrapperze ma wyższy priorytet niż .is-filled,
 * więc podczas aktywnej edycji zawsze wyświetla się ten styl.
 */
.e24-form .e24-fi__field:focus-within {
    border-color: var(--e24-input-focus-border);
    background-color: var(--e24-input-focus-bg);
    box-shadow: 0 0 0 2px rgba(211, 84, 0, 0.10);
}

/*
 * Stan FILLED – żółta tonacja.
 * Aktywuje się tylko gdy wrapper .e24-fi ma klasę .is-filled
 * ORAZ wrapper .e24-fi__field NIE ma aktywnego fokusa (:focus-within).
 * Fallbacki (#E9C931, #FEF6E1) zabezpieczają przed sytuacją gdy token CSS
 * nie zostanie odczytany przez przeglądarkę.
 */
.e24-form .e24-fi.is-filled .e24-fi__field:not(:focus-within) {
    border-color: var(--e24-input-filled-border, #E9C931);
    background-color: var(--e24-input-filled-bg-new, #FEF6E1);
    box-shadow: none;
}

/* Błąd walidacji – bez zmian, zawsze nadpisuje filled */
.e24-form .e24-fi.is-invalid .e24-fi__field {
    border-color: var(--e24-error-border);
    background-color: #FDECEC;
    box-shadow: 0 0 0 2px rgba(217, 48, 37, 0.08);
}

/* Właściwy element input/select */
.e24-form .e24-fi__input {
    flex: 1 1 auto;
    border: none;
    outline: none;
    padding: var(--ef-input-pad-y) var(--ef-input-pad-x);
    font-size: var(--ef-fs-input);
    color: var(--e24-text-input);
    background-color: transparent;
    box-shadow: none;
    border-radius: 0;
    margin: 0;
    width: 100%;
    min-height: var(--ef-input-min-h);
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.e24-form .e24-fi__input::placeholder {
    font-size: var(--ef-fs-placeholder);
    color: #B0B0B0;
    opacity: 1;
}

.e24-form .e24-fi__input:focus {
    outline: none;
    box-shadow: none;
}

/* Ukrycie spinnerów dla number input */
.e24-form input[type="number"] {
    -moz-appearance: textfield;
}
.e24-form input[type="number"]::-webkit-outer-spin-button,
.e24-form input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/*
 * AUTOFILL PRZEGLĄDARKI (PL) – wersja bezpieczna:
 * Tylko zmiana koloru tła przez box-shadow inset na samym polu tekstowym.
 * Nie modyfikujemy wrapperów (.e24-fi__field), żeby uniknąć regresu.
 * Przeglądarki blokują zmianę background-color dla autofill,
 * ale box-shadow inset można bezpiecznie nadpisać.
 */
.e24-form .e24-fi__input:-webkit-autofill,
.e24-form .e24-fi__input:-webkit-autofill:hover,
.e24-form .e24-fi__input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0px 1000px var(--e24-input-filled-bg-new, #FEF6E1) inset !important;
    -webkit-text-fill-color: var(--e24-text-input) !important;
    box-shadow: 0 0 0px 1000px var(--e24-input-filled-bg-new, #FEF6E1) inset !important;
    transition: background-color 99999s ease-in-out 0s !important;
}

/* ========================================
 * 5. RADIO BUTTONS (STYL ORDER FORM – INLINE)
 *    Wzorowane na .e24-packaging-options z section-1.css
 * ===================================== */

/* Tytuł grupy wyboru */
.e24-form .e24-fi__choices-label {
    display: block;
    margin-bottom: 8px;
    font-size: var(--ef-fs-label);
    font-weight: 600;
    color: var(--e24-text-main);
}

.e24-form .e24-fi__choices-label .e24-required {
    color: var(--e24-orange);
    margin-left: 2px;
    font-weight: 700;
}

/* Kontener opcji – inline obok siebie */
.e24-form .e24-fi__choices {
    display: inline-flex;
    align-items: center;
    gap: 24px;
    padding-top: 6px;
}

/* Pojedyncza opcja – prosty inline jak w Order Form */
.e24-form .e24-choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

/* Natywny radio – widoczny i ostylowany */
.e24-form .e24-choice input[type="radio"],
.e24-form .e24-choice input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--e24-orange);
}

/* Tekst opcji – mała czcionka jak w Order Form */
.e24-form .e24-choice__text {
    font-size: 13px;
    color: var(--e24-text-input);
    transition: color 0.15s ease-out;
    white-space: nowrap;
}

/* Stan zaznaczony – pogrubiony tekst */
.e24-form .e24-choice input[type="radio"]:checked + .e24-choice__text,
.e24-form .e24-choice input[type="checkbox"]:checked + .e24-choice__text {
    color: var(--e24-text-main);
    font-weight: 600;
}

/* Stan błędu dla grupy radio/checkbox */
.e24-form .e24-fi--choices.is-invalid .e24-fi__choices-label {
    color: var(--e24-error-text);
}

/* ========================================
 * 6. TEXTAREA
 * ===================================== */
.e24-form textarea.e24-fi__input {
    min-height: 130px;
    resize: vertical;
    line-height: 1.55;
    padding-top: 10px;
    padding-bottom: 10px;
}

/* ========================================
 * 7. CAPTCHA (MATEMATYCZNA – KOMPAKTOWA)
 * ===================================== */
.e24-form .e24-captcha {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.e24-form .e24-captcha__question {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    background-color: var(--e24-input-unit-bg);
    border: 1px solid var(--e24-input-border);
    border-radius: var(--ef-radius);
    font-size: 14px;
    font-weight: 700;
    color: var(--e24-brand-dark);
    letter-spacing: 0.5px;
    white-space: nowrap;
    min-height: 36px;
}

.e24-form .e24-captcha__equals {
    font-size: 16px;
    font-weight: 700;
    color: var(--e24-text-muted);
    line-height: 1;
}

/* Pole odpowiedzi – wąskie i niższe */
.e24-form .e24-captcha__answer-wrap {
    flex: 0 0 80px;
}

.e24-form .e24-captcha__answer-wrap .e24-fi__input {
    min-height: 36px;
    font-size: 14px;
    padding: 4px 10px;
    text-align: center;
}

/* Label CAPTCHA – mniejszy rozmiar */
.e24-form .e24-fi--captcha .e24-fi__label {
    font-size: 12px;
}

/* ========================================
 * 8. CHECKBOX RODO
 * ===================================== */
.e24-form .e24-rodo {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 4px;
}

.e24-form .e24-rodo__checkbox {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--e24-orange);
}

.e24-form .e24-rodo__text {
    font-size: 13px;
    color: var(--e24-text-muted);
    line-height: 1.5;
}

.e24-form .e24-rodo__text a {
    color: var(--e24-orange);
    text-decoration: none;
    font-weight: 600;
}

.e24-form .e24-rodo__text a:hover {
    color: #BE4C00;
    text-decoration: underline;
}

/* Stan błędu RODO */
.e24-form .e24-rodo-wrap.is-invalid .e24-rodo__text {
    color: var(--e24-error-text);
}

/* ========================================
 * 9. PRZYCISKI AKCJI
 * ===================================== */
.e24-form .e24-form-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #E9E9E9;
}

/* Główny przycisk Submit */
.e24-form .e24-form-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 32px;
    font-size: 16px;
    font-weight: 600;
    font-family: "Rubik", sans-serif;
    border-radius: var(--ef-radius);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    text-decoration: none;
    border: 2px solid transparent;
    background-color: var(--e24-orange);
    color: #FFFFFF;
    outline: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.e24-form .e24-form-submit:hover {
    background-color: #BE4C00;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(211, 84, 0, 0.22);
    color: #FFFFFF;
}

.e24-form .e24-form-submit:active {
    transform: translateY(0) scale(0.99);
    box-shadow: none;
}

.e24-form .e24-form-submit:focus,
.e24-form .e24-form-submit:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Stan loading – spinner */
.e24-form .e24-form-submit.is-loading {
    pointer-events: none;
    opacity: 0.75;
}

.e24-form .e24-form-submit.is-loading .e24-btn-text {
    opacity: 0.6;
}

/* Stan disabled */
.e24-form .e24-form-submit:disabled,
.e24-form .e24-form-submit.is-disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.4);
    transform: none;
    box-shadow: none;
}

/* Spinner CSS (rotujący kółek) */
.e24-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: e24-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ========================================
 * 10. KOMUNIKATY WALIDACJI I BŁĘDÓW
 * ===================================== */

/* Komunikat pod polem */
.e24-form .e24-fi-msg {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    border-width: 1px;
    border-style: solid;
    font-size: var(--ef-fs-msg);
    min-height: 22px;
}

.e24-form .e24-fi-msg.e24-fi-msg--error {
    background-color: var(--e24-error-bg);
    border-color: var(--e24-error-border);
    color: var(--e24-error-text);
}

.e24-form .e24-fi-msg.e24-fi-msg--warn {
    background-color: var(--e24-warn-bg);
    border-color: var(--e24-warn-border);
    color: var(--e24-warn-text);
}

/* Globalny komunikat błędu/sukcesu formularza */
.e24-form .e24-form-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--ef-radius);
    border-width: 1px;
    border-style: solid;
    font-size: 14px;
    line-height: 1.5;
    margin-top: 16px;
}

.e24-form .e24-form-notice--error {
    background-color: var(--e24-error-bg);
    border-color: var(--e24-error-border);
    color: var(--e24-error-text);
}

.e24-form .e24-form-notice--warn {
    background-color: var(--e24-warn-bg);
    border-color: var(--e24-warn-border);
    color: var(--e24-warn-text);
}

/* Ukryty element */
.e24-form .e24-hidden {
    display: none !important;
}

/* ========================================
 * 11. PANEL SUKCESU (PO WYSŁANIU)
 * ===================================== */
.e24-form-success {
    display: none; /* JS przełącza na flex */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 20px;
}

.e24-form-success.is-visible {
    display: flex;
}

/*
 * Ikona sukcesu formularza (PL):
 * Celowo używa --e24-input-filled-bg (stary token, pomarańczowy)
 * a NIE --e24-input-filled-bg-new, żeby zachować spójność z kolorem CTA
 * w tym elemencie dekoracyjnym (nie jest to pole formularza).
 */
.e24-form-success__icon {
    width: 64px;
    height: 64px;
    background-color: var(--e24-input-filled-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    border: 2px solid var(--e24-orange);
}

.e24-form-success__icon svg {
    width: 32px;
    height: 32px;
    stroke: var(--e24-orange);
}

.e24-form-success__title {
    font-family: "Rubik", sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--e24-brand-dark);
    margin: 0 0 10px 0;
}

.e24-form-success__text {
    font-size: 15px;
    color: var(--e24-text-muted);
    line-height: 1.6;
    margin: 0;
    max-width: 420px;
}

/* ========================================
 * 12. GRID FORMULARZA I WARIANTY KOLUMN
 * ===================================== */

/* Grid 2-kolumnowy (używany przez oba formularze) */
.e24-form-grid {
    display: grid;
    gap: var(--ef-gap-sm);
}

/* Odstęp między kolejnymi wierszami */
.e24-form-grid + .e24-form-grid {
    margin-top: var(--ef-row-gap);
}

/* Kolumna 1/3 + 2/3 */
.e24-form-grid--1-2 {
    grid-template-columns: 1fr 2fr;
}

/* Kolumna 2/3 + 1/3 */
.e24-form-grid--2-1 {
    grid-template-columns: 2fr 1fr;
}

/* Kolumna 1/2 + 1/2 */
.e24-form-grid--1-1 {
    grid-template-columns: 1fr 1fr;
}

/* Pełna szerokość */
.e24-form-grid--full {
    grid-template-columns: 1fr;
}

/* ========================================
 * 13. RWD
 * ===================================== */

@media (max-width: 1024px) {
    .e24-form-wrapper {
        --ef-pad-x: 28px;
        --ef-pad-y: 24px;
        --ef-row-gap: 24px;
    }
}

@media (max-width: 768px) {
    .e24-form-wrapper {
        --ef-pad-x: 16px;
        --ef-pad-y: 20px;
        --ef-row-gap: 20px;
    }

    /* Na mobile wszystkie gridy stają się jednokolumnowe */
    .e24-form-grid--1-2,
    .e24-form-grid--2-1,
    .e24-form-grid--1-1 {
        grid-template-columns: 1fr;
    }

    .e24-form-box {
        border-radius: 0;
        box-shadow: none;
    }

    .e24-form .e24-form-footer {
        justify-content: center;
    }

    .e24-form .e24-form-submit {
        width: 100%;
    }

    .e24-form .e24-captcha {
        flex-direction: column;
        align-items: flex-start;
    }

    .e24-form .e24-captcha__answer-wrap {
        flex: 0 0 120px;
    }

    /* Radio – na mobile też w jednym rzędzie, ale z mniejszym gap */
    .e24-form .e24-fi__choices {
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .e24-form-wrapper {
        --ef-pad-x: 12px;
    }

    .e24-form-success {
        padding: 36px 16px;
    }

    /* Na najwęższych ekranach radio łamie się do kolumny */
    .e24-form .e24-fi__choices {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}