:root {
    --nxp-easy-form-spacing: 1rem;
    --nxp-easy-form-font-size: 1rem;
    --nxp-easy-form-border-radius: var(--bs-border-radius, var(--template-button-border-radius, 4px));
    --nxp-easy-form-border-color: color-mix(in srgb, currentColor 18%, transparent);
    --nxp-easy-form-input-padding: 0.55rem 0.65rem;
    --nxp-easy-form-message-success: var(--template-success-text, #137333);
    --nxp-easy-form-message-error: var(--template-danger-text, #b71c1c);
    --nxp-easy-form-button-bg: var(--template-link-color, #0d6efd);
    --nxp-easy-form-button-color: var(--template-text-light, #ffffff);
    --nxp-easy-form-button-hover-bg: color-mix(in srgb, var(--nxp-easy-form-button-bg) 85%, #000 15%);
}

.nxp-easy-form {
    margin: calc(var(--nxp-easy-form-spacing) * 1.5) 0;
    color: inherit;
    font: inherit;
}

.nxp-easy-form__group {
    margin-bottom: var(--nxp-easy-form-spacing);
}

.nxp-easy-form__label {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.nxp-easy-form__input,
.nxp-easy-form__textarea,
.nxp-easy-form__select {
    width: 100%;
    padding: var(--nxp-easy-form-input-padding);
    border: 1px solid var(--nxp-easy-form-border-color);
    border-radius: var(--nxp-easy-form-border-radius);
    font-size: var(--nxp-easy-form-font-size);
    background-color: var(--template-bg-input, var(--cassiopeia-color-bg, #ffffff));
    color: inherit;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.nxp-easy-form__input:focus,
.nxp-easy-form__textarea:focus,
.nxp-easy-form__select:focus {
    outline: none;
    border-color: var(--template-link-color, #0d6efd);
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--template-link-color, #0d6efd) 25%, transparent);
}

.nxp-easy-form__textarea {
    min-height: 120px;
}

.nxp-easy-form__messages {
    margin-bottom: var(--nxp-easy-form-spacing);
    font-weight: 600;
}

.nxp-easy-form__messages--success {
    color: var(--nxp-easy-form-message-success);
}

.nxp-easy-form__messages--error {
    color: var(--nxp-easy-form-message-error);
}

.nxp-easy-form__button,
.nxp-easy-form__actions button {
    background-color: var(--nxp-easy-form-button-bg);
    color: var(--nxp-easy-form-button-color);
    border: none;
    border-radius: var(--nxp-easy-form-border-radius);
    padding: 0.55rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.nxp-easy-form__button:hover,
.nxp-easy-form__actions button:hover {
    background-color: var(--nxp-easy-form-button-hover-bg);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.12);
}

.nxp-easy-form__button:disabled,
.nxp-easy-form__actions button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    box-shadow: none;
}

/* Save & Resume — secondary action paired with the primary Submit button.
   Outline style so the visual hierarchy reads "Submit is primary, Save
   is supporting"; same padding/radius/weight family as the Submit so the
   two buttons look like a coherent pair rather than visiting from
   different design systems. */
.nxp-draft-save-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.nxp-draft-save {
    background-color: transparent;
    color: var(--nxp-easy-form-button-bg);
    border: 1.5px solid var(--nxp-easy-form-button-bg);
    border-radius: var(--nxp-easy-form-border-radius);
    padding: 0.5rem 1.15rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.4;
    transition: background-color 0.18s ease-in-out,
                color 0.18s ease-in-out,
                box-shadow 0.18s ease-in-out;
}
.nxp-draft-save:hover,
.nxp-draft-save:focus-visible {
    background-color: var(--nxp-easy-form-button-bg);
    color: var(--nxp-easy-form-button-color);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.12);
    outline: none;
}
.nxp-draft-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}
.nxp-draft-save-result {
    font-size: 0.92rem;
    line-height: 1.4;
    padding: 0.5rem 0.75rem;
    border-radius: var(--nxp-easy-form-border-radius);
    /* Take its own line on narrow viewports — sitting next to the
       button works on desktop but wraps cleanly when there isn't room. */
    flex: 1 1 auto;
    min-width: min(20rem, 100%);
}
.nxp-draft-save-result--success {
    background: rgba(46, 160, 67, 0.10);
    color: rgb(31, 118, 49);
    border: 1px solid rgba(46, 160, 67, 0.35);
}
.nxp-draft-save-result--error {
    background: rgba(207, 34, 46, 0.10);
    color: rgb(176, 30, 40);
    border: 1px solid rgba(207, 34, 46, 0.35);
}

.nxp-easy-form__error {
    color: var(--nxp-easy-form-message-error);
    font-size: 0.875rem;
    margin: 0.35rem 0 0;
}

.nxp-easy-form__hint {
    display: block;
    font-size: 0.85rem;
    margin: 0.35rem 0 0;
    opacity: 0.75;
}

.nxp-easy-form__nxp_f {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.nxp-easy-form__required {
    color: var(--template-danger-text, #d32f2f);
}

.nxp-easy-form__range-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nxp-easy-form__range {
    flex: 1;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.nxp-easy-form__range:focus {
    outline: none;
    box-shadow: none;
}

.nxp-easy-form__range-value {
    min-width: 3ch;
    text-align: right;
    font-weight: 600;
    font-size: var(--nxp-easy-form-font-size);
}

.nxp-easy-form__form .cf-turnstile {
    padding: 1rem 0;
}

/* D1: two-column layout (Pro via layout.two_column capability).
   Renderer emits a grid container when options.layout.mode === 'two_column';
   each field's wrapper gets nxp-easy-form__group--half when field.layout.width === 'half'.
   Mobile always collapses to a single column. */
.nxp-easy-form__grid--two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.25rem;
}

.nxp-easy-form__grid--two-column > * {
    /* Structural items (buttons, full-width fields) span the whole grid row. */
    grid-column: 1 / -1;
}

.nxp-easy-form__grid--two-column > .nxp-easy-form__group--half {
    grid-column: auto;
}

@media (max-width: 640px) {
    .nxp-easy-form__grid--two-column {
        grid-template-columns: 1fr;
    }
    .nxp-easy-form__grid--two-column > .nxp-easy-form__group--half {
        grid-column: 1 / -1;
    }
}

/* D2: Multi-step forms */
.nxp-easy-form__progress {
    margin-bottom: 1.5rem;
}

.nxp-easy-form__step-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0;
    counter-reset: none;
}

.nxp-easy-form__step-indicator {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: #6c757d;
    border-bottom: 3px solid #dee2e6;
    transition: color 0.2s, border-color 0.2s;
}

.nxp-easy-form__step-indicator--active {
    color: #212529;
    border-bottom-color: #2271b1;
    font-weight: 600;
}

.nxp-easy-form__step-indicator--completed {
    color: #212529;
    border-bottom-color: #198754;
}

.nxp-easy-form__step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: #dee2e6;
    color: #495057;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.nxp-easy-form__step-indicator--active .nxp-easy-form__step-number {
    background: #2271b1;
    color: #fff;
}

.nxp-easy-form__step-indicator--completed .nxp-easy-form__step-number {
    background: #198754;
    color: #fff;
}

.nxp-easy-form__step-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nxp-easy-form__step-nav {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    justify-content: space-between;
}

/* Last step: Previous sits left, Submit sits right — same row */
.nxp-easy-form__step-nav--last {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.nxp-easy-form__step-nav--last .nxp-easy-form__step-prev {
    order: 0;
}

.nxp-easy-form__step-nav--last .nxp-easy-form__button {
    margin-left: auto;
    order: 1;
}

.nxp-easy-form__step-prev,
.nxp-easy-form__step-next {
    padding: 0.5rem 1.25rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #fff;
    color: #212529;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.nxp-easy-form__step-prev:hover,
.nxp-easy-form__step-next:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.nxp-easy-form__step-next {
    margin-left: auto;
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.nxp-easy-form__step-next:hover {
    background: #1a5a8a;
    border-color: #1a5a8a;
}

/* D2: responsive progress + step containers */
@media (max-width: 640px) {
    .nxp-easy-form__step-list {
        flex-wrap: wrap;
        gap: 4px;
    }

    .nxp-easy-form__step-indicator {
        flex: none;
        min-width: 0;
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .nxp-easy-form__step-label {
        display: none;
    }

    .nxp-easy-form__step-nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .nxp-easy-form__step-prev,
    .nxp-easy-form__step-next {
        width: 100%;
        text-align: center;
    }

    .nxp-easy-form__step {
        overflow-x: hidden;
    }
}

/* D2: clickable progress indicator cursor */
.nxp-easy-form__step-indicator[role="button"] {
    cursor: pointer;
}

.nxp-easy-form__step-indicator[role="button"]:hover {
    opacity: 0.8;
}

/* D2: ensure step containers don't overflow */
.nxp-easy-form__step {
    max-width: 100%;
    overflow-x: hidden;
}

/* D3: prevent flash of conditionally-hidden fields before JS evaluates.
   The JS evaluator removes this by setting explicit display on each field. */
.nxp-easy-form__form [data-logic] {
    visibility: hidden;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.nxp-easy-form__form [data-logic].nxp-logic-evaluated {
    visibility: visible;
    height: auto;
    overflow: visible;
    margin: revert;
    padding: revert;
}
