/* ----------------------------------------------------------------
 * Storefront listing polish
 * Kept at the end of the stylesheet so the listing has one reliable
 * cascade layer after the legacy component-specific breakpoints.
 * ---------------------------------------------------------------- */
.erp-theme-shell .erp-shop,
.erp-theme-shell .erp-shop *,
.erp-theme-shell .erp-shop *::before,
.erp-theme-shell .erp-shop *::after {
    box-sizing: border-box;
}

.erp-theme-shell .erp-shop {
    width: 100%;
    max-width: 1280px;
    margin-right: auto;
    margin-left: auto;
    padding: 32px clamp(16px, 2vw, 24px) 64px;
    padding-right: max(clamp(16px, 2vw, 24px), env(safe-area-inset-right, 0px));
    padding-left: max(clamp(16px, 2vw, 24px), env(safe-area-inset-left, 0px));
}

.erp-theme-shell .erp-shop__sidebar {
    width: 264px;
    flex: 0 0 264px;
}

.erp-theme-shell .erp-shop__main {
    min-width: 0;
}

/* Listing toolbar and sorting */
.erp-shop__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 0 0 14px;
    padding: 0;
}

.erp-shop__toolbar-results {
    min-width: 0;
    margin: 0;
    color: var(--erp-text-muted);
    font-size: 14px;
    line-height: 1.5;
}

.erp-shop__toolbar-results strong {
    color: var(--erp-text);
    font-variant-numeric: tabular-nums;
}

.erp-shop__sort {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    margin: 0;
}

.erp-shop__sort label {
    margin: 0;
    color: var(--erp-text-muted);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.erp-shop__sort select,
.erp-shop__sort button {
    min-height: 44px;
    border: 1px solid var(--erp-border);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
}

.erp-shop__sort select {
    max-width: 100%;
    padding: 9px 36px 9px 12px;
    background-color: #fff;
    color: var(--erp-text);
    cursor: pointer;
}

.erp-shop__sort button {
    padding: 9px 15px;
    border-color: var(--erp-primary);
    background: var(--erp-primary);
    color: #fff;
    font-weight: 750;
    cursor: pointer;
}

/* Product-card content and action footer */
.erp-theme-shell .erp-product-card {
    height: 100%;
    border-radius: 16px;
}

.erp-product-card__link {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
}

.erp-product-card__media {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #fff;
}

.erp-product-card__media .erp-product-card__image,
.erp-product-card__media .erp-product-card__no-image {
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
}

.erp-product-card__media .erp-product-card__image {
    display: block;
    object-fit: contain;
}

.erp-product-card__body {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
}

/* Keep model and plan suffixes visible, including on narrow mobile cards. */
.erp-product-card__title {
    display: block;
    overflow: visible;
    overflow-wrap: anywhere;
    white-space: normal;
}

.erp-product-card__price-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 3px 8px;
    margin-top: auto;
    padding-top: 12px;
}

.erp-product-card__price-row .erp-product-card__price {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 7px;
    margin: 0;
}

.erp-product-card__price-current {
    font-variant-numeric: tabular-nums;
}

.erp-product-card__price-note {
    flex: 1 0 100%;
    color: var(--erp-text-muted);
    font-size: 10px;
    line-height: 1.35;
}

.erp-product-card__footer {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid color-mix(in srgb, var(--erp-border) 72%, transparent);
    background: #fff;
}

.erp-product-card__availability {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}

.erp-product-card__availability i {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.16);
}

.erp-product-card__availability.is-available {
    color: #15803d;
}

.erp-product-card__availability.is-available i {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.erp-product-card__availability.is-low,
.erp-shop-search__card-stock.is-low {
    color: #b45309;
}

.erp-product-card__availability.is-low i {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
}

.erp-product-card__availability.is-incoming {
    color: #a16207;
}

.erp-product-card__availability.is-incoming i {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
}

.erp-product-card__availability.is-backorder,
.erp-shop-search__card-stock.is-backorder {
    color: #1d4ed8;
}

.erp-product-card__availability.is-backorder i {
    background: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.erp-product-card__availability.is-unavailable {
    color: #b91c1c;
}

.erp-product-card__availability.is-unavailable i {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}

.erp-product-card__details,
.erp-product-card__footer .erp-product-card__atc {
    display: inline-flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin: 0;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 750;
    line-height: 1.25;
    text-align: center;
}

.erp-product-card__details {
    border: 1px solid var(--erp-border);
    border: 1px solid color-mix(in srgb, var(--erp-primary) 42%, var(--erp-border));
    background: #fff;
    background: color-mix(in srgb, var(--erp-primary) 5%, #fff);
    color: var(--erp-primary);
    text-decoration: none;
}

.erp-product-card__details svg {
    flex: 0 0 auto;
    transition: transform 0.18s ease;
}

.erp-product-card__atc {
    min-height: 44px;
}

/* Empty listing state */
.erp-shop__empty {
    display: grid;
    min-height: 240px;
    margin: 0;
    padding: clamp(30px, 6vw, 58px) 20px;
    place-items: center;
    align-content: center;
    gap: 9px;
    border: 1px dashed var(--erp-border);
    border-color: color-mix(in srgb, var(--erp-primary) 30%, var(--erp-border));
    border-radius: 18px;
    background: linear-gradient(145deg, #fff, var(--erp-bg-light));
    color: var(--erp-text-muted);
    text-align: center;
}

.erp-shop__empty > svg {
    margin-bottom: 4px;
    color: var(--erp-primary);
}

.erp-shop__empty h3,
.erp-shop__empty p {
    margin: 0;
}

.erp-shop__empty h3 {
    color: var(--erp-text);
    font-family: var(--erp-heading-font);
    font-size: clamp(19px, 3vw, 24px);
}

.erp-shop__empty p {
    max-width: 520px;
    line-height: 1.6;
}

.erp-shop__empty > a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 9px 16px;
    border-radius: 10px;
    background: var(--erp-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 750;
    text-decoration: none;
}

/* Pagination: supports both WordPress list output and legacy flat links. */
.erp-shop__pagination {
    display: flex;
    justify-content: center;
    margin-top: 36px;
}

.erp-shop__pagination .page-numbers {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--erp-border);
    border-radius: 10px;
    background: #fff;
    color: var(--erp-text);
    font-size: 14px;
    line-height: 1.2;
    text-decoration: none;
}

.erp-shop__pagination ul.page-numbers {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    list-style: none;
}

.erp-shop__pagination ul.page-numbers > li {
    margin: 0;
}

.erp-shop__pagination .page-numbers.current {
    border-color: var(--erp-primary);
    background: var(--erp-primary);
    color: #fff;
}

.erp-shop__pagination .prev,
.erp-shop__pagination .next {
    width: auto;
    padding-right: 14px;
    padding-left: 14px;
}

/* Comfortable touch targets and theme-independent keyboard focus. */
.erp-shop__categories li a,
.erp-shop__breadcrumb a {
    min-height: 44px;
}

.erp-shop__breadcrumb a {
    display: inline-flex;
    align-items: center;
}

.erp-shop__categories li a:focus-visible,
.erp-shop__breadcrumb a:focus-visible,
.erp-shop__primary-link:focus-visible,
.erp-shop__secondary-link:focus-visible,
.erp-shop__home-feature:focus-visible,
.erp-shop__category-card:focus-visible,
.erp-shop-search__card:focus-visible,
.erp-product-card__details:focus-visible,
.erp-product-card__atc:focus-visible,
.erp-shop__empty > a:focus-visible,
.erp-shop__pagination a.page-numbers:focus-visible,
.erp-shop__sort select:focus-visible,
.erp-shop__sort button:focus-visible {
    outline: 3px solid var(--erp-primary);
    outline-offset: 3px;
}

.erp-shop__home-feature:focus-visible,
.erp-shop__primary-link:focus-visible,
.erp-shop__secondary-link:focus-visible {
    outline-color: #fff;
}

@media (hover: hover) {
    .erp-product-card__details:hover {
        border-color: var(--erp-primary);
        background: color-mix(in srgb, var(--erp-primary) 10%, #fff);
        color: var(--erp-primary);
    }

    .erp-product-card__details:hover svg {
        transform: translateX(2px);
    }

    .erp-shop__pagination a.page-numbers:hover {
        border-color: var(--erp-primary);
        color: var(--erp-primary);
    }

    .erp-shop__sort button:hover,
    .erp-shop__empty > a:hover {
        background: var(--erp-primary-hover);
        color: #fff;
    }
}

@media (hover: none) {
    .erp-shop__categories li a:hover,
    .erp-shop__primary-link:hover,
    .erp-shop__secondary-link:hover,
    .erp-shop__category-card:hover,
    .erp-product-card:hover,
    .erp-shop__category-card:hover .erp-shop__category-card-media img,
    .erp-product-card:hover .erp-product-card__image,
    .erp-shop__home-feature:hover > img {
        transform: none;
    }
}

/* Consolidated storefront breakpoints */
@media (max-width: 768px) {
    .erp-theme-shell .erp-shop {
        width: 100%;
        max-width: 100%;
        flex-direction: column;
        gap: 0;
        padding: 20px 14px 52px;
        padding-right: max(14px, env(safe-area-inset-right, 0px));
        padding-left: max(14px, env(safe-area-inset-left, 0px));
    }

    .erp-theme-shell .erp-shop__sidebar {
        width: 100%;
        flex: 0 0 auto;
        margin-bottom: 18px;
    }

    .erp-theme-shell .erp-shop__main {
        width: 100%;
    }

    .erp-shop__grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .erp-theme-shell .erp-product-card {
        border-radius: 14px;
    }

    .erp-product-card__body {
        padding: 12px;
    }

    .erp-product-card__footer {
        padding: 11px 12px 12px;
    }

    .erp-product-card__atc,
    .erp-product-card__footer .erp-product-card__atc,
    .erp-product-card__details {
        min-height: 44px;
        margin: 0;
        padding: 9px 10px;
        font-size: 13px;
    }

    .erp-product-card > .erp-product-card__atc {
        width: calc(100% - 24px);
        margin: 0 12px 12px;
    }
}

@media (max-width: 640px) {
    .erp-shop__toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 11px;
    }

    .erp-shop__sort {
        width: 100%;
    }

    .erp-shop__sort select {
        min-width: 0;
        flex: 1 1 auto;
    }

    .erp-shop__section-heading--products {
        gap: 12px;
    }

    .erp-shop__pagination {
        margin-top: 28px;
    }
}

@media (max-width: 480px) {
    .erp-theme-shell .erp-shop {
        padding-top: 14px;
        padding-right: max(12px, env(safe-area-inset-right, 0px));
        padding-bottom: 44px;
        padding-left: max(12px, env(safe-area-inset-left, 0px));
    }

    .erp-shop-search__grid {
        grid-template-columns: 1fr;
    }

    .erp-shop__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .erp-shop__sort {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .erp-shop__sort label {
        grid-column: 1 / -1;
        white-space: normal;
    }

    .erp-shop__sort select,
    .erp-shop__sort button {
        width: 100%;
    }

    .erp-shop__category-grid {
        gap: 9px;
    }

    .erp-product-card__price-current {
        font-size: 16px;
    }

    .erp-product-card__availability {
        font-size: 11px;
    }

    .erp-shop__pagination ul.page-numbers {
        gap: 6px;
    }

    .erp-shop__pagination .page-numbers {
        padding-right: 10px;
        padding-left: 10px;
    }
}

@media (max-width: 359px) {
    .erp-shop__grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .erp-theme-shell .erp-shop *,
    .erp-theme-shell .erp-shop *::before,
    .erp-theme-shell .erp-shop *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .erp-shop__primary-link:hover,
    .erp-shop__secondary-link:hover,
    .erp-shop__home-feature:hover > img,
    .erp-shop__category-card:hover,
    .erp-shop__category-card:hover .erp-shop__category-card-media img,
    .erp-product-card:hover,
    .erp-product-card:hover .erp-product-card__image,
    .erp-product-card__details:hover svg {
        transform: none;
    }
}
