/**
 * صفحه عمده‌فروشی — UI اختصاصی B2B
 */
.wholesale-page {
    --ws-accent: var(--theam-color, #2563eb);
    --ws-accent-soft: color-mix(in srgb, var(--ws-accent) 12%, transparent);
    --ws-accent-mid: color-mix(in srgb, var(--ws-accent) 22%, transparent);
    --ws-hero-text: #fff;
    --ws-surface: #ffffff;
    --ws-muted: #f1f5f9;
    --ws-border: #e2e8f0;
    --ws-text: #0f172a;
    --ws-text-muted: #64748b;
    padding-bottom: 3rem;
}

/* ── Hero ── */
.wholesale-hero {
    position: relative;
    border-radius: var(--ui-radius-xl, 20px);
    padding: 1.5rem 1.25rem 1.65rem;
    margin-bottom: 1.75rem;
    overflow: hidden;
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--ws-accent) 92%, #0f172a) 0%,
        color-mix(in srgb, var(--theam-secend-color, var(--ws-accent)) 75%, #1e293b) 55%,
        #1e293b 100%
    );
    box-shadow: var(--ui-shadow-lg, 0 12px 40px rgba(15, 23, 42, 0.15));
    color: var(--ws-hero-text);
}

.wholesale-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.14) 0%, transparent 42%),
        radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.08) 0%, transparent 40%);
    pointer-events: none;
}

.wholesale-hero__inner {
    position: relative;
    z-index: 1;
}

.wholesale-hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: var(--ui-radius-pill, 999px);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.22);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.85rem;
    backdrop-filter: blur(6px);
}

.wholesale-hero__title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 0.5rem;
    line-height: 1.35;
}

.wholesale-hero__desc {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
    max-width: 36rem;
    line-height: 1.7;
}

.wholesale-hero__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.wholesale-stat {
    flex: 1 1 120px;
    min-width: 110px;
    max-width: 200px;
    padding: 0.85rem 1rem;
    border-radius: var(--ui-radius-md, 12px);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
}

.wholesale-stat__value {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.2;
}

.wholesale-stat__label {
    display: block;
    font-size: 0.72rem;
    opacity: 0.85;
    margin-top: 0.2rem;
}

@media (min-width: 992px) {
    .wholesale-hero {
        padding: 1.35rem 1.75rem 1.5rem;
    }

    .wholesale-hero__inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr) max-content;
        align-items: center;
        gap: 1rem 1.25rem;
    }

    .wholesale-hero__main {
        min-width: 0;
        max-width: 100%;
    }

    .wholesale-hero__badge {
        margin-bottom: 0.55rem;
        font-size: 0.75rem;
        padding: 0.28rem 0.7rem;
    }

    .wholesale-hero__title {
        font-size: clamp(1.25rem, 2.2vw, 1.65rem);
        margin-bottom: 0.35rem;
    }

    .wholesale-hero__desc {
        font-size: 0.88rem;
        max-width: 32rem;
        line-height: 1.55;
    }

    .wholesale-hero__stats {
        margin-top: 0;
        display: flex;
        flex-flow: row nowrap;
        align-items: stretch;
        justify-content: flex-start;
        gap: 0.45rem;
        width: max-content;
        max-width: none;
        flex-shrink: 0;
    }

    .wholesale-stat {
        flex: 0 0 5.25rem;
        width: 5.25rem;
        min-width: 5.25rem;
        max-width: 5.25rem;
        padding: 0.5rem 0.4rem;
        text-align: center;
    }

    .wholesale-stat__value {
        font-size: 1rem;
    }

    .wholesale-stat__label {
        font-size: 0.65rem;
        line-height: 1.25;
    }
}

/* ── Filters ── */
.wholesale-filters-card {
    border: 1px solid var(--ws-border);
    border-radius: var(--ui-radius-lg, 16px);
    background: var(--ws-surface);
    box-shadow: var(--ui-shadow-sm);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.wholesale-filters-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(180deg, var(--ws-muted) 0%, var(--ws-surface) 100%);
    border-bottom: 1px solid var(--ws-border);
}

.wholesale-filters-card__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ws-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wholesale-filters-card__title i {
    color: var(--ws-accent);
    font-size: 1.25rem;
}

.wholesale-filters-card__status {
    margin: 0;
    font-size: 0.8rem;
    color: var(--ws-text-muted);
}

.wholesale-filters-card__body {
    padding: 1.25rem;
}

.wholesale-filter-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ws-text-muted);
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.wholesale-filter-label i {
    color: var(--ws-accent);
    font-size: 1rem;
}

.wholesale-page .wholesale-search-input {
    border-radius: var(--ui-radius-md);
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    background: var(--ws-muted);
    border-color: transparent;
}

.wholesale-page .wholesale-search-input:focus {
    background: var(--ws-surface);
}

.wholesale-page #wholesale-filters-form .form-select {
    border-radius: var(--ui-radius-sm);
    font-size: 0.88rem;
}

.wholesale-page #wholesale-clear-filters {
    border-radius: var(--ui-radius-pill);
    padding: 0.45rem 1.1rem;
    font-weight: 500;
}

/* ── Table card ── */
.wholesale-table-card {
    border: 1px solid var(--ws-border);
    border-radius: var(--ui-radius-lg, 16px);
    background: var(--ws-surface);
    box-shadow: var(--ui-shadow-md);
    overflow: hidden;
}

.wholesale-results {
    min-height: 200px;
}

.wholesale-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1.5rem;
    gap: 1rem;
}

.wholesale-loading__spinner {
    width: 3rem;
    height: 3rem;
    border-width: 0.2rem;
    color: var(--ws-accent);
}

.wholesale-results.is-loading #wholesale-results-body {
    opacity: 0.35;
    pointer-events: none;
    filter: blur(1px);
}

.wholesale-results--denied {
    min-height: 220px;
}

.wholesale-access-denied {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3.5rem 1.5rem;
    gap: 0.35rem;
}

.wholesale-access-denied__icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--ws-accent) 12%, #fff);
    color: var(--ws-accent);
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

/* Meta toolbar */
.wholesale-results-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--ws-muted);
    border-bottom: 1px solid var(--ws-border);
}

.wholesale-results-meta__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.wholesale-results-meta__actions .btn-outline-success {
    border-radius: var(--ui-radius-pill);
    font-weight: 600;
    font-size: 0.8rem;
}

.wholesale-results-meta__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.wholesale-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--ui-radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--ws-surface);
    border: 1px solid var(--ws-border);
    color: var(--ws-text);
}

.wholesale-chip--accent {
    background: var(--ws-accent-soft);
    border-color: var(--ws-accent-mid);
    color: var(--ws-accent);
}

.wholesale-chip--success {
    background: color-mix(in srgb, #16a34a 10%, transparent);
    border-color: color-mix(in srgb, #16a34a 25%, transparent);
    color: #15803d;
}

/* Table */
.wholesale-table-wrap {
    max-height: min(72vh, 880px);
    overflow: auto;
}

.wholesale-products-table {
    margin: 0;
    font-size: 0.88rem;
    --bs-table-hover-bg: rgba(15, 23, 42, 0.03);
}

.wholesale-table-head th {
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0.01em;
    padding: 0.85rem 0.75rem;
    background: linear-gradient(180deg, var(--ws-text) 0%, #334155 100%);
    color: #f8fafc;
    border: none;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.wholesale-products-table tbody td {
    padding: 0.85rem 0.75rem;
    vertical-align: middle;
    border-color: var(--ws-border);
}

.wholesale-product-row {
    transition: background 0.15s ease;
}

.wholesale-group-header td,
.wholesale-row-simple .wholesale-col-product {
    background: var(--ws-accent-soft) !important;
}

.wholesale-row-simple td:not(.wholesale-col-product) {
    background: #fff !important;
}

.wholesale-group-header td {
    border-bottom: 1px solid var(--ws-border);
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
}

.wholesale-row-simple td {
    border-bottom: 1px solid var(--ws-border);
}

.wholesale-group-child td {
    background: #fff !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.85);
}

.wholesale-group-last td {
    border-bottom: 1px solid var(--ws-border);
}

.wholesale-group-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.75rem;
}

.wholesale-group-header__title {
    flex: 1 1 100%;
    margin-top: 0.15rem;
}

.wholesale-group-header__title .wholesale-product-name {
    font-size: 1rem;
}

.wholesale-group-header + .wholesale-group-child td {
    border-top: none;
}

.wholesale-variation-child {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.wholesale-group-connector {
    display: block;
    width: 12px;
    min-width: 12px;
    margin-top: 0.35rem;
    border-right: 1px solid var(--ws-border);
    border-bottom: 1px solid var(--ws-border);
    border-bottom-right-radius: 4px;
}

.wholesale-variation-label {
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--ws-text);
}

.wholesale-col-cart {
    width: 110px;
    min-width: 100px;
}

.wholesale-cart-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.wholesale-qty-input {
    width: 52px;
    min-width: 52px;
    text-align: center;
    padding: 0.25rem 0.35rem;
}

.wholesale-add-cart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
}

.wholesale-col-num {
    width: 48px;
    color: var(--ws-text-muted);
    font-weight: 600;
    font-size: 0.8rem;
}

.wholesale-product-name {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--ws-text);
    text-decoration: none;
    line-height: 1.45;
    transition: color 0.15s ease;
}

.wholesale-product-name:hover {
    color: var(--ws-accent);
}

.wholesale-type-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: var(--ui-radius-pill);
}

.wholesale-type-badge--var {
    background: var(--ws-accent-soft);
    color: var(--ws-accent);
    border: 1px solid var(--ws-accent-mid);
}

.wholesale-type-badge--simple {
    background: var(--ws-muted);
    color: var(--ws-text-muted);
    border: 1px solid var(--ws-border);
}

.wholesale-attr-badge {
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.28rem 0.55rem;
    border-radius: 6px;
}

.wholesale-attr-badge--company {
    background: color-mix(in srgb, var(--ws-accent) 14%, #fff);
    color: var(--ws-accent);
}

.wholesale-attr-badge--brand {
    background: #e0f2fe;
    color: #0369a1;
}

.wholesale-attr-badge--quality {
    background: #f1f5f9;
    color: #475569;
}

.wholesale-sku {
    font-size: 0.75rem;
    padding: 0.2rem 0.45rem;
    background: var(--ws-muted);
    border-radius: 6px;
    color: var(--ws-text-muted);
    border: none;
}

.wholesale-stock {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.65rem;
    border-radius: var(--ui-radius-pill);
}

.wholesale-stock--ok {
    background: #dcfce7;
    color: #166534;
}

.wholesale-stock--low {
    background: #fef9c3;
    color: #a16207;
}

.wholesale-stock--out {
    background: #fee2e2;
    color: #b91c1c;
}

.wholesale-price {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--ws-accent);
    line-height: 1.3;
}

.wholesale-price--sale {
    color: #dc2626;
}

.wholesale-price-old {
    font-size: 0.75rem;
    color: var(--ws-text-muted);
    text-decoration: line-through;
    font-weight: 500;
}

.wholesale-price-unit {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ws-text-muted);
}

.wholesale-price-single {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-end;
    gap: 0.35rem 0.5rem;
    line-height: 1.5;
}

.wholesale-price-single__qty {
    font-size: 0.82rem;
    color: var(--ws-text-muted);
    white-space: nowrap;
}

.wholesale-price-single__eq {
    font-size: 0.85rem;
    color: var(--ws-text-muted);
}

.wholesale-volume-prices {
    display: grid;
    gap: 0.25rem;
    min-width: 9rem;
}

.wholesale-volume-prices__title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ws-text-muted);
    margin-bottom: 0.15rem;
}

.wholesale-volume-prices__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.82rem;
}

.wholesale-volume-prices__range {
    color: var(--ws-text-muted);
    white-space: nowrap;
}

.wholesale-volume-prices__price {
    font-weight: 700;
    color: var(--ws-text);
    white-space: nowrap;
}

.wholesale-empty {
    text-align: center;
    padding: 4rem 1.5rem;
}

.wholesale-empty__icon {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    background: var(--ws-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--ws-text-muted);
    margin-bottom: 1rem;
}

@media (max-width: 767.98px) {
    .wholesale-hero {
        padding: 1.5rem 1.25rem;
    }

    .wholesale-hero__stats {
        gap: 0.5rem;
    }

    .wholesale-stat {
        min-width: calc(50% - 0.5rem);
    }

    .wholesale-table-wrap {
        max-height: 65vh;
    }

    .wholesale-col-variant {
        min-width: 140px;
    }
}
