
/*
 * Izolacja od stylów motywu/page buildera hosta: bez tego resetu reguły strony
 * (np. resety list/formularzy z Oxygena, Bootstrapa itp.) mieszają się nieprzewidywalnie
 * z naszymi, bo w kaskadzie CSS zwykła reguła autora zawsze wygrywa z regułą user-agent —
 * a "autorem" z punktu widzenia przeglądarki jest też CSS samego motywu. `all: revert`
 * cofa każdy element do czystych domyślnych stylów przeglądarki, na których dopiero
 * budujemy własny, spójny wygląd poniżej.
 */
.easylead-form,
.easylead-form * {
    all: revert;
    box-sizing: border-box;
}

/*
 * Wyjątek: pola formularza (input/select/button/textarea) domyślnie w przeglądarkach
 * NIE dziedziczą font-family (to klasyczna pułapka CSS) — łapiemy więc czcionkę
 * aktualnie używanego motywu strony (przez naturalne dziedziczenie), żeby formularz
 * wtapiał się w resztę strony pod względem typografii.
 */
.easylead-form,
.easylead-form input,
.easylead-form select,
.easylead-form button,
.easylead-form textarea,
.easylead-form legend {
    font-family: inherit;
}

.easylead-form {
    --easylead-text: #111827;
    --easylead-muted: #6b7280;
    --easylead-border: #e5e7eb;
    --easylead-accent: #2271b1;
    --easylead-accent-hover: #135e96;
    --easylead-surface: #ffffff;
    --easylead-field-bg: #f9fafb;
    --easylead-radius: 16px;
    --easylead-max-width: 560px;
    --easylead-ring: color-mix(in srgb, var(--easylead-accent) 22%, transparent);

    display: block;
    box-sizing: border-box;
    max-width: var(--easylead-max-width);
    margin: 0 auto;
    padding: 36px 32px;
    background: var(--easylead-surface);
    border: 1px solid var(--easylead-border);
    border-radius: var(--easylead-radius);
    box-shadow:
        0 1px 2px rgba(16, 24, 40, 0.04),
        0 12px 32px rgba(16, 24, 40, 0.08);
    color: var(--easylead-text);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/*
 * Reset dla atrybutu [hidden]: reguła autorska (np. .easylead-form__step { display: flex })
 * zawsze wygrywa w kaskadzie z regułą user-agent [hidden]{display:none}, niezależnie od
 * specyficzności — bez tego resetu ukryte kroki i przyciski i tak by się wyświetlały.
 */
.easylead-form [hidden] {
    display: none !important;
}

.easylead-form__description {
    margin: 0 0 24px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--easylead-muted);
}

/* Intro pochodzi z edytora WYSIWYG — może zawierać kilka akapitów, listy, linki itd. */

.easylead-form__intro {
    margin: 0 0 24px;
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--easylead-muted);
}

.easylead-form__intro > *:first-child {
    margin-top: 0;
}

.easylead-form__intro > *:last-child {
    margin-bottom: 0;
}

.easylead-form__intro a {
    color: var(--easylead-accent);
}

.easylead-form__intro h1,
.easylead-form__intro h2,
.easylead-form__intro h3,
.easylead-form__intro h4,
.easylead-form__intro h5,
.easylead-form__intro h6 {
    margin: 0 0 0.5em;
    line-height: 1.3;
    font-weight: 700;
    color: var(--easylead-text);
}

.easylead-form__intro h1 {
    font-size: 1.5rem;
}

.easylead-form__intro h2 {
    font-size: 1.3rem;
}

.easylead-form__intro h3,
.easylead-form__intro h4,
.easylead-form__intro h5,
.easylead-form__intro h6 {
    font-size: 1.1rem;
}

.easylead-form__intro ul,
.easylead-form__intro ol {
    margin: 0 0 1em;
    padding-left: 1.4em;
}

.easylead-form__step {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.easylead-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.easylead-field label,
.easylead-field legend {
    padding: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--easylead-text);
}

.easylead-field__required {
    color: #ef4444;
}

.easylead-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.easylead-field select {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 12px 16px;
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--easylead-text);
    background: var(--easylead-field-bg);
    border: 1px solid var(--easylead-border);
    border-radius: 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.easylead-field input::placeholder {
    color: #9ca3af;
}

.easylead-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
.easylead-field select:hover {
    border-color: color-mix(in srgb, var(--easylead-border) 40%, var(--easylead-muted));
}

.easylead-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.easylead-field select:focus {
    outline: none;
    background: var(--easylead-surface);
    border-color: var(--easylead-accent);
    box-shadow: 0 0 0 4px var(--easylead-ring);
}

/* Pole typu "plik": strefa drag&drop + lista wybranych plików pod nią */

.easylead-file-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 28px 16px;
    text-align: center;
    background: var(--easylead-field-bg);
    border: 1.5px dashed var(--easylead-border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.easylead-file-dropzone:hover,
.easylead-file-dropzone:focus-visible,
.easylead-file-dropzone.is-dragover {
    border-color: var(--easylead-accent);
    background: color-mix(in srgb, var(--easylead-accent) 6%, var(--easylead-surface));
    box-shadow: 0 0 0 4px var(--easylead-ring);
    outline: none;
}

.easylead-file-dropzone__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.easylead-file-dropzone__text {
    font-size: 0.85rem;
    color: var(--easylead-muted);
}

.easylead-file-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.easylead-file-list:empty {
    display: none;
}

.easylead-file-list__item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    gap: 6px;
    padding: 4px 0;
    font-size: 0.85rem;
    color: var(--easylead-text);
}

.easylead-file-list__name {
    display: inline-block !important;
    flex: 0 1 auto !important;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.easylead-file-list__remove {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    width: 20px !important;
    height: 20px !important;
    background: none;
    border: none;
    color: #d63638;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
}

.easylead-file-list__remove:hover {
    color: #a52a2a;
}

/* Grupy checkbox/radio (fieldset) */

.easylead-field--group {
    border: none;
    padding: 0;
    margin: 0;
}

.easylead-field--group.has-error {
    outline: 2px solid #d63638;
    outline-offset: 6px;
    border-radius: 4px;
}

.easylead-field--group .easylead-field__option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--easylead-text);
    background: var(--easylead-field-bg);
    border: 1px solid var(--easylead-border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.easylead-field--group .easylead-field__option:hover {
    border-color: color-mix(in srgb, var(--easylead-border) 40%, var(--easylead-muted));
}

.easylead-field--group .easylead-field__option:first-of-type {
    margin-top: 4px;
}

.easylead-field__option input {
    width: auto;
    accent-color: var(--easylead-accent);
}

.easylead-form__extra-text {
    margin: 4px 0 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--easylead-muted);
}

.easylead-form__message {
    margin: 0 0 20px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.easylead-form__message p:first-child {
    margin-top: 0;
}

.easylead-form__message p:last-child {
    margin-bottom: 0;
}

.easylead-form__message--success {
    background: rgba(0, 163, 42, 0.1);
    color: #00641f;
}

.easylead-form__message--error {
    background: rgba(214, 54, 56, 0.1);
    color: #8a1f1f;
}

@media (prefers-color-scheme: dark) {
    .easylead-form__message--success {
        background: rgba(0, 200, 60, 0.15);
        color: #6fdb8f;
    }

    .easylead-form__message--error {
        background: rgba(255, 90, 90, 0.15);
        color: #ff9b9b;
    }
}

.easylead-form.easylead-theme-dark .easylead-form__message--success {
    background: rgba(0, 200, 60, 0.15);
    color: #6fdb8f;
}

.easylead-form.easylead-theme-dark .easylead-form__message--error {
    background: rgba(255, 90, 90, 0.15);
    color: #ff9b9b;
}

/*
 * Wskaźnik postępu (widoczny tylko gdy kroków jest więcej niż jeden).
 * Celowo zwykłe <div>y zamiast <ol>/<li> — listy bywają mocno stylowane globalnie
 * przez motyw/page builder (liczniki, odstępy, ::marker), co psuło układ.
 */

.easylead-form__progress {
    display: flex;
    align-items: flex-start;
    margin: 0 0 32px;
    padding: 0;
}

.easylead-form__progress-item {
    position: relative;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 0;
}

.easylead-form__progress-item::before {
    content: "";
    position: absolute;
    top: 15px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--easylead-border);
    z-index: 0;
}

.easylead-form__progress-item:first-child::before {
    content: none;
}

.easylead-form__progress-item.is-complete::before {
    background: var(--easylead-accent);
}

.easylead-form__progress-number {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--easylead-border);
    background: var(--easylead-surface);
    color: var(--easylead-muted);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.easylead-form__progress-item.is-active .easylead-form__progress-number {
    border-color: var(--easylead-accent);
    color: var(--easylead-accent);
    box-shadow: 0 0 0 4px var(--easylead-ring);
}

.easylead-form__progress-item.is-complete .easylead-form__progress-number {
    background: var(--easylead-accent);
    border-color: var(--easylead-accent);
    color: #fff;
}

.easylead-form__progress-label {
    display: block;
    width: 100%;
    margin: 8px 0 0;
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--easylead-muted);
    overflow-wrap: break-word;
}

.easylead-form__progress-item.is-active .easylead-form__progress-label {
    color: var(--easylead-text);
    font-weight: 600;
}

/* Pasek nawigacji: Wstecz / Dalej / Wyślij */

.easylead-form__nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
}

.easylead-form__nav-button,
.easylead-form__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.01em;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.easylead-form__nav-button--back {
    margin-right: auto;
    background: var(--easylead-surface);
    border: 1px solid var(--easylead-border);
    color: var(--easylead-text);
}

.easylead-form__nav-button--back:hover {
    background: var(--easylead-field-bg);
    border-color: color-mix(in srgb, var(--easylead-border) 40%, var(--easylead-muted));
}

.easylead-form__nav-button--next,
.easylead-form__submit {
    margin-left: auto;
    min-width: 120px;
    color: #fff;
    background: var(--easylead-accent);
    border: none;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px color-mix(in srgb, var(--easylead-accent) 28%, transparent);
}

.easylead-form__nav-button--next:hover,
.easylead-form__submit:hover {
    background: var(--easylead-accent-hover);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--easylead-accent) 35%, transparent);
    transform: translateY(-1px);
}

.easylead-form__nav-button:active,
.easylead-form__submit:active {
    transform: translateY(0);
}

@media (max-width: 480px) {
    .easylead-form {
        padding: 24px 20px;
        border-radius: 14px;
    }

    .easylead-form__progress-label {
        display: none;
    }

    .easylead-form__nav {
        flex-wrap: wrap;
    }

    .easylead-form__nav-button,
    .easylead-form__submit {
        flex: 1 1 auto;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        min-width: 0;
    }
}

@media (prefers-color-scheme: dark) {
    .easylead-form {
        --easylead-text: #f3f4f6;
        --easylead-muted: #9ca3af;
        --easylead-border: #374151;
        --easylead-surface: #111827;
        --easylead-field-bg: #1f2937;
    }
}

/* Ręczny wybór motywu w ustawieniach formularza — nadpisuje ustawienia systemowe odwiedzającego. */

.easylead-form.easylead-theme-light {
    --easylead-text: #111827;
    --easylead-muted: #6b7280;
    --easylead-border: #e5e7eb;
    --easylead-surface: #ffffff;
    --easylead-field-bg: #f9fafb;
}

.easylead-form.easylead-theme-dark {
    --easylead-text: #f3f4f6;
    --easylead-muted: #9ca3af;
    --easylead-border: #374151;
    --easylead-surface: #111827;
    --easylead-field-bg: #1f2937;
}

/* Przycisk otwierający modal (renderowany przez shortcode, gdy Form::$open_in_modal). */

.easylead-modal-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #fff;
    background: var(--easylead-accent, #2271b1);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px color-mix(in srgb, var(--easylead-accent, #2271b1) 28%, transparent);
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.easylead-modal-trigger:hover {
    background: var(--easylead-accent-hover, #135e96);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--easylead-accent, #2271b1) 35%, transparent);
    transform: translateY(-1px);
}

/* Otoczka modala — widoczna dla formularzy z włączonym "Otwórz w oknie za pomocą przycisku". */

.easylead-modal[hidden] {
    display: none;
}

.easylead-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.easylead-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.easylead-modal__dialog {
    position: relative;
    max-width: min(92vw, 640px);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
    animation: easylead-modal-in 0.2s ease-out;
}

@keyframes easylead-modal-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.easylead-modal__dialog .easylead-form {
    margin: 0;
    max-width: none;
    border: none;
    border-radius: 20px;
    box-shadow:
        0 24px 64px rgba(15, 23, 42, 0.28),
        0 2px 8px rgba(15, 23, 42, 0.08);
    padding: 40px 36px 36px;
}

.easylead-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: color-mix(in srgb, var(--easylead-surface, #fff) 88%, #e5e7eb);
    border: 1px solid var(--easylead-border, #e5e7eb);
    border-radius: 999px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--easylead-muted, #6b7280);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.easylead-modal__close:hover {
    color: var(--easylead-text, #111827);
    background: var(--easylead-field-bg, #f9fafb);
    border-color: color-mix(in srgb, var(--easylead-border, #e5e7eb) 50%, #9ca3af);
}

.easylead-modal__dialog:has(.easylead-theme-dark) .easylead-modal__close {
    background: #1f2937;
    border-color: #374151;
    color: #9ca3af;
}

.easylead-modal__dialog:has(.easylead-theme-dark) .easylead-modal__close:hover {
    background: #111827;
    color: #f3f4f6;
}
