/* WPNest Returns for WooCommerce — frontend
   Scope: My Account orders + view-order page (link only) + /returns/ page (wizard).
   Conventions: mobile-first; vanilla CSS; system font stack so Polish glyphs always render. */

.wpnest-rfw-app {
    --rfw-bg: #ffffff;
    --rfw-surface: #f8f9fa;
    --rfw-border: #e2e4e7;
    --rfw-border-strong: #c3c4c7;
    --rfw-text: #1d2327;
    --rfw-muted: #50575e;
    --rfw-accent: #2271b1;
    --rfw-accent-hover: #135e96;
    --rfw-success: #007017;
    --rfw-warn: #b26200;
    --rfw-error: #b32d2e;
    --rfw-radius: 6px;
    --rfw-radius-lg: 10px;
    --rfw-shadow: 0 6px 24px rgba(0,0,0,.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--rfw-text);
}
.wpnest-rfw-app * { font-family: inherit; }

/* ── Button fallbacks ─────────────────────────────────────────────
   Every CTA inside .wpnest-rfw-app carries three classes:
     - `button alt` (WooCommerce frontend convention)
     - `btn btn-primary` / `btn btn-ghost` (theme design system, e.g. wpnest theme)
     - plugin namespace (`wpnest-rfw-btn`, `wpnest-rfw-submit`)
   When the host theme styles either `.button.alt` or `.btn-primary`, the theme's
   rules win automatically. The fallbacks below use `:where()` (specificity 0)
   so themes ALWAYS override — they only kick in on themes that style neither. */

:where(.wpnest-rfw-app) :where(.button) {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 6px;
    border: 1px solid var(--rfw-border-strong);
    background: #fff;
    color: var(--rfw-text);
    font: inherit;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
:where(.wpnest-rfw-app) :where(.button):hover,
:where(.wpnest-rfw-app) :where(.button):focus {
    background: var(--rfw-surface);
    border-color: var(--rfw-text);
    color: var(--rfw-text);
}
:where(.wpnest-rfw-app) :where(.button.alt) {
    background: var(--rfw-accent);
    border-color: var(--rfw-accent);
    color: #fff;
    font-weight: 600;
}
:where(.wpnest-rfw-app) :where(.button.alt):hover,
:where(.wpnest-rfw-app) :where(.button.alt):focus {
    background: var(--rfw-accent-hover);
    border-color: var(--rfw-accent-hover);
    color: #fff;
}
:where(.wpnest-rfw-app) :where(.button):disabled,
:where(.wpnest-rfw-app) :where(.button)[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.wpnest-rfw-view-order-action { margin: 16px 0 0; }

/* ── Section spacing ─────────────────────────────────────────────── */

.wpnest-rfw-app .wpnest-rfw-section { margin: 0 0 32px; }
.wpnest-rfw-app h2 { font-size: 1.4em; margin: 0 0 12px; }
.wpnest-rfw-app .wpnest-rfw-help { color: var(--rfw-muted); margin: 0 0 16px; }

.wpnest-rfw-empty {
    padding: 24px;
    background: var(--rfw-surface);
    border: 1px dashed var(--rfw-border);
    border-radius: 8px;
    text-align: center;
    color: var(--rfw-muted);
}

/* ── Eligible orders — card list (replaces the old table) ───────── */

.wpnest-rfw-orders {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.wpnest-rfw-order {
    background: #fff;
    border: 1px solid var(--rfw-border);
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.wpnest-rfw-order:hover {
    border-color: var(--rfw-accent);
    box-shadow: 0 4px 12px rgba(0,0,0,.06);
    transform: translateY(-1px);
}
.wpnest-rfw-order__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.wpnest-rfw-order__num {
    font-size: 1.05em;
    font-weight: 700;
    color: var(--rfw-text);
}
.wpnest-rfw-order__date {
    font-size: .85em;
    color: var(--rfw-muted);
}
.wpnest-rfw-order__body { flex: 1 1 auto; }
.wpnest-rfw-order__items {
    margin: 0 0 6px;
    font-size: .95em;
    line-height: 1.4;
    color: var(--rfw-text);
}
.wpnest-rfw-order__total {
    margin: 0;
    font-size: .95em;
    color: var(--rfw-muted);
    font-variant-numeric: tabular-nums;
}
.wpnest-rfw-order__total bdi { font-weight: 600; color: var(--rfw-text); }
.wpnest-rfw-order__foot {
    border-top: 1px solid var(--rfw-border);
    padding-top: 10px;
    margin-top: 4px;
}
.wpnest-rfw-order__foot .button {
    text-align: center;
}

/* ── Friendly empty state ───────────────────────────────────────── */

.wpnest-rfw-empty--friendly {
    padding: 36px 24px;
    text-align: center;
}
.wpnest-rfw-empty__icon {
    display: block;
    font-size: 36px;
    line-height: 1;
    margin-bottom: 8px;
}
.wpnest-rfw-empty--friendly h3 {
    margin: 4px 0 8px;
    font-size: 1.15em;
    color: var(--rfw-text);
}
.wpnest-rfw-empty--friendly p {
    margin: 0 auto 12px;
    max-width: 380px;
    color: var(--rfw-muted);
}

/* ── Section heading ────────────────────────────────────────────── */

.wpnest-rfw-section__title {
    margin: 0 0 6px;
    font-size: 1.5em;
    line-height: 1.3;
}

/* ── Guest verify form ─────────────────────────────────────────────── */

.wpnest-rfw-guest-form {
    background: #fff;
    border: 1px solid var(--rfw-border);
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.wpnest-rfw-guest-form .wpnest-rfw-form__row { margin-bottom: 16px; }
.wpnest-rfw-guest-form .wpnest-rfw-form__row--actions { margin-bottom: 0; }
.wpnest-rfw-guest-form input[type="email"],
.wpnest-rfw-guest-form input[type="text"] {
    padding: 10px 12px;
    font-size: 1em;
}
.wpnest-rfw-form__hint {
    display: block;
    margin-top: 4px;
    color: var(--rfw-muted);
    font-size: .85em;
    font-weight: 400;
    line-height: 1.4;
}

.wpnest-rfw-login-hint {
    margin: 12px 0 0;
    color: var(--rfw-muted);
    font-size: .92em;
}
.wpnest-rfw-login-hint a {
    color: var(--rfw-accent);
    text-decoration: underline;
    font-weight: 500;
}
.wpnest-rfw-login-hint a:hover { color: var(--rfw-accent-hover); }

/* ── Resources card (model PDF download) ──────────────────────────── */

.wpnest-rfw-resources-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: flex-start;
    background: var(--rfw-surface);
    border: 1px solid var(--rfw-border);
    border-left: 4px solid var(--rfw-accent);
    border-radius: 10px;
    padding: 20px 22px;
}
.wpnest-rfw-resources-card__icon {
    font-size: 28px;
    line-height: 1;
    padding-top: 2px;
}
.wpnest-rfw-resources-card__body h3 {
    margin: 0 0 6px;
    font-size: 1.05em;
    color: var(--rfw-text);
}
.wpnest-rfw-resources-card__body p {
    margin: 0 0 12px;
    color: var(--rfw-muted);
    font-size: .95em;
    line-height: 1.5;
}
.wpnest-rfw-resources-card__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Form primitives ─────────────────────────────────────────────── */

.wpnest-rfw-form__row {
    display: block;
    margin: 0 0 14px;
}
.wpnest-rfw-form__row > label,
.wpnest-rfw-form__label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
}
.wpnest-rfw-app textarea,
.wpnest-rfw-app input[type="email"],
.wpnest-rfw-app input[type="text"],
.wpnest-rfw-app input[type="number"],
.wpnest-rfw-app select {
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--rfw-border-strong);
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    background: #fff;
}
.wpnest-rfw-app textarea {
    width: 100%;
    min-height: 84px;
    resize: vertical;
}
.wpnest-rfw-app input[type="email"],
.wpnest-rfw-app input[type="text"] { width: 100%; }
.wpnest-rfw-app textarea:focus,
.wpnest-rfw-app input:focus,
.wpnest-rfw-app select:focus {
    outline: none;
    border-color: var(--rfw-accent);
    box-shadow: 0 0 0 1px var(--rfw-accent);
}
.wpnest-rfw-check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    cursor: pointer;
    line-height: 1.4;
}
.wpnest-rfw-check input[type="checkbox"] {
    margin: 4px 0 0;
    flex: 0 0 auto;
}
.wpnest-rfw-feedback {
    margin-top: 14px;
    font-size: .95em;
    min-height: 1.4em;
}
.wpnest-rfw-feedback.is-error { color: var(--rfw-error); }
.wpnest-rfw-feedback.is-success { color: var(--rfw-success); }

/* ── Wizard ────────────────────────────────────────────────────── */

.wpnest-rfw-wizard {
    background: #fff;
    border: 1px solid var(--rfw-border);
    border-radius: var(--rfw-radius-lg);
    padding: 24px;
    box-shadow: var(--rfw-shadow);
}
.wpnest-rfw-wizard__head { margin-bottom: 20px; }
.wpnest-rfw-wizard__head h2 { margin: 0 0 12px; }

.wpnest-rfw-stepper {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.wpnest-rfw-stepper li {
    flex: 1 1 0;
    min-width: 120px;
    padding: 10px 12px;
    background: var(--rfw-surface);
    border: 1px solid var(--rfw-border);
    border-radius: 8px;
    font-size: .95em;
    color: var(--rfw-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.wpnest-rfw-stepper li span {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--rfw-border-strong);
    color: var(--rfw-muted);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85em;
}
.wpnest-rfw-stepper li.is-active {
    background: #fff;
    border-color: var(--rfw-accent);
    color: var(--rfw-accent);
    font-weight: 600;
}
.wpnest-rfw-stepper li.is-active span {
    background: var(--rfw-accent);
    color: #fff;
    border-color: var(--rfw-accent);
}
.wpnest-rfw-stepper li.is-done {
    color: var(--rfw-success);
}
.wpnest-rfw-stepper li.is-done span {
    background: var(--rfw-success);
    border-color: var(--rfw-success);
    color: #fff;
}

.wpnest-rfw-step { display: none; }
.wpnest-rfw-step.is-active { display: block; }
.wpnest-rfw-step__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Step 1 — items grid */
.wpnest-rfw-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.wpnest-rfw-item {
    display: grid;
    grid-template-columns: auto 64px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 12px;
    background: var(--rfw-surface);
    border: 1px solid var(--rfw-border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}
.wpnest-rfw-item:hover { border-color: var(--rfw-accent); }
.wpnest-rfw-item.is-selected {
    background: #fff;
    border-color: var(--rfw-accent);
    box-shadow: inset 0 0 0 1px var(--rfw-accent);
}
.wpnest-rfw-item__check { margin: 0; flex: 0 0 auto; }
.wpnest-rfw-item__thumb { display: inline-block; }
.wpnest-rfw-item__thumb img { display: block; width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.wpnest-rfw-item__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wpnest-rfw-item__name { font-weight: 600; }
.wpnest-rfw-item__meta { color: var(--rfw-muted); font-size: .9em; }
.wpnest-rfw-item__meta p { margin: 0; }
.wpnest-rfw-item__price { color: var(--rfw-muted); font-size: .92em; }
.wpnest-rfw-item__qty {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .9em;
    color: var(--rfw-muted);
}
.wpnest-rfw-item__qty-input {
    width: 64px !important;
    text-align: center;
    padding: 6px 8px;
}
.wpnest-rfw-item__qty-label { display: none; }

/* Step 2 — reasons */
.wpnest-rfw-reasons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.wpnest-rfw-reason {
    background: var(--rfw-surface);
    border: 1px solid var(--rfw-border);
    border-radius: 8px;
    padding: 14px 16px;
}
.wpnest-rfw-reason__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: .98em;
}
.wpnest-rfw-reason__qty {
    font-size: .85em;
    color: var(--rfw-muted);
    background: #fff;
    border: 1px solid var(--rfw-border);
    padding: 2px 8px;
    border-radius: 999px;
}
.wpnest-rfw-reason select { width: 100%; }
.wpnest-rfw-reason textarea { width: 100%; min-height: 60px; }

/* Step 3 — summary */
.wpnest-rfw-summary {
    background: var(--rfw-surface);
    border: 1px solid var(--rfw-border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
}
.wpnest-rfw-summary__table { width: 100%; border-collapse: collapse; }
.wpnest-rfw-summary__table th,
.wpnest-rfw-summary__table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--rfw-border);
}
.wpnest-rfw-summary__table tr:last-child td { border-bottom: 0; }
.wpnest-rfw-summary__table .qty { width: 60px; color: var(--rfw-muted); font-variant-numeric: tabular-nums; }
.wpnest-rfw-summary__table .name { font-weight: 600; }
.wpnest-rfw-summary__table .reason { color: var(--rfw-muted); font-size: .92em; }
.wpnest-rfw-summary__table .note { color: var(--rfw-muted); font-size: .9em; margin-top: 2px; }

.wpnest-rfw-success {
    margin-top: 14px;
    padding: 14px 16px;
    background: #e8f5ee;
    border: 1px solid #b6e1c5;
    color: var(--rfw-success);
    border-radius: 8px;
}

/* ── Responsive ─────────────────────────────────────────────────── */

/* Tablet + small desktop: gives wizard breathing room before phone layout kicks in. */
@media (max-width: 720px) {
    .wpnest-rfw-wizard { padding: 18px; }
    .wpnest-rfw-app .wpnest-rfw-section { margin: 0 0 24px; }
    .wpnest-rfw-section__title { font-size: 1.35em; }

    .wpnest-rfw-stepper li { min-width: 0; padding: 8px 10px; font-size: .88em; }
    .wpnest-rfw-stepper li span { width: 20px; height: 20px; font-size: .8em; }

    .wpnest-rfw-item {
        grid-template-columns: auto 56px 1fr;
        grid-auto-flow: row;
        row-gap: 8px;
    }
    .wpnest-rfw-item__qty {
        grid-column: 1 / -1;
        justify-content: flex-end;
        flex-wrap: wrap;
        padding-top: 6px;
        border-top: 1px dashed var(--rfw-border);
    }
    .wpnest-rfw-item__qty-label { display: inline; }

    .wpnest-rfw-step__actions { flex-direction: column-reverse; }
    .wpnest-rfw-step__actions .button { width: 100%; }

    .wpnest-rfw-orders { grid-template-columns: 1fr; }
    .wpnest-rfw-guest-form { padding: 18px; }
    .wpnest-rfw-resources-card { padding: 16px 18px; grid-template-columns: 1fr; }
    .wpnest-rfw-resources-card__icon { font-size: 22px; }
    .wpnest-rfw-resources-card__actions .button { flex: 1 1 auto; text-align: center; }
}

/* Phone — wizard must fit in 360-414px range without horizontal scroll. */
@media (max-width: 540px) {
    .wpnest-rfw-app { font-size: 15px; }
    .wpnest-rfw-wizard { padding: 14px; border-radius: 8px; }
    .wpnest-rfw-wizard__head { margin-bottom: 16px; }
    .wpnest-rfw-section__title { font-size: 1.2em; line-height: 1.35; }

    /* Stepper: collapse to dots — label only visible on the active step. Saves
       the 3×120px width that overflowed phones below ~390px. */
    .wpnest-rfw-stepper { gap: 6px; }
    .wpnest-rfw-stepper li {
        flex: 0 0 auto;
        min-width: 0;
        padding: 6px 10px;
        font-size: 0;        /* hide label text */
        gap: 0;
    }
    .wpnest-rfw-stepper li.is-active {
        flex: 1 1 auto;
        padding: 6px 12px;
        font-size: .88em;    /* show label only on active step */
        gap: 6px;
    }
    .wpnest-rfw-stepper li span { width: 22px; height: 22px; font-size: .82em; }

    /* Items: stack thumb + body in one row, checkbox above. */
    .wpnest-rfw-item {
        grid-template-columns: 56px 1fr;
        padding: 10px;
        gap: 10px;
    }
    .wpnest-rfw-item__check {
        grid-column: 1 / -1;
        order: -1;
    }
    .wpnest-rfw-item__thumb img { width: 56px; height: 56px; }
    .wpnest-rfw-item__name { font-size: .98em; }
    .wpnest-rfw-item__qty { gap: 8px; font-size: .88em; }

    /* Reason head: wrap qty pill below product name on narrow screens. */
    .wpnest-rfw-reason { padding: 12px 14px; }
    .wpnest-rfw-reason__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-bottom: 8px;
    }
    .wpnest-rfw-reason__qty { align-self: flex-end; }

    /* Summary table: card layout — each row becomes a stacked block.
       Native table cells with display:block + data-attribute-driven labels
       would require JS; instead we just relax cell widths + show meta on
       its own line. */
    .wpnest-rfw-summary { padding: 10px 12px; }
    .wpnest-rfw-summary__table th,
    .wpnest-rfw-summary__table td { padding: 6px 4px; font-size: .92em; }
    .wpnest-rfw-summary__table .qty { width: 40px; }
    .wpnest-rfw-summary__table .reason { display: block; margin-top: 2px; }

    .wpnest-rfw-guest-form { padding: 16px; }
    .wpnest-rfw-guest-form input[type="email"],
    .wpnest-rfw-guest-form input[type="text"] {
        padding: 9px 11px;
        font-size: 16px;     /* prevents iOS zoom on focus */
    }
    .wpnest-rfw-app textarea,
    .wpnest-rfw-app input[type="number"],
    .wpnest-rfw-app select { font-size: 16px; }  /* same iOS zoom guard */

    /* Resources card: reduce vertical bulk. */
    .wpnest-rfw-resources-card { padding: 14px 16px; gap: 10px; }
    .wpnest-rfw-resources-card__body h3 { font-size: 1em; }
    .wpnest-rfw-resources-card__body p { font-size: .9em; line-height: 1.45; }

    /* Hero/login hint — readable on narrow viewports. */
    .wpnest-rfw-login-hint { font-size: .88em; }
}
