/**
 * Bishtar Bekhar — Wholesale Pricing Frontend Styles
 * Strict Scoping: .rp-wholesale-container & .rp-cart-price-wrap
 * WCAG AAA Contrast, Persian Typography & Mobile-First Precision
 */

.rp-wholesale-container {
    --rp-primary: #5B000A;
    --rp-accent: #C5A059;
    --rp-active-bg: #fff5f6;
    --rp-card-bg: #ffffff;
    --rp-card-border: #e2e8f0;
    --rp-hover-border: #C5A059;
    --rp-container-bg: #fafafb;
    --rp-container-border: #e5e7eb;
    --rp-text: #1e293b;
    --rp-badge-text: #ffffff;

    margin: 12px 0 16px;
    padding: 10px 14px;
    background: var(--rp-container-bg, #fafafb);
    border: 1px solid var(--rp-container-border, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    direction: rtl;
    text-align: right;
    font-family: inherit;
    box-sizing: border-box;
    clear: both;
}

.rp-wholesale-container * {
    box-sizing: border-box;
}

/* Header */
.rp-wholesale-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
}

.rp-wholesale-title-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--rp-text, #1e293b);
    font-size: 12.5px;
    font-weight: 700;
}

.rp-wholesale-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--rp-primary, #5B000A);
}

.rp-wholesale-title-text {
    color: var(--rp-text, #1e293b);
}

.rp-wholesale-hint {
    font-size: 11px;
    color: #94a3b8;
}

/* Grid / Flex of Pill Chips */
.rp-wholesale-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: stretch;
    width: 100%;
}

/* Individual Pill Chip */
.rp-wholesale-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 calc(30% - 10px);
    min-width: 115px;
    min-height: 40px;
    padding: 8px 12px;
    background: var(--rp-card-bg, #ffffff);
    border: 1.5px solid var(--rp-card-border, #e2e8f0);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    white-space: nowrap;
    box-sizing: border-box;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.rp-card-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
}

.rp-card-qty {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--rp-text, #334155);
}

.rp-card-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 6px;
    background: var(--rp-primary, #5B000A);
    color: var(--rp-badge-text, #ffffff) !important;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    line-height: 1.3;
}

.rp-card-tag-subtle {
    font-size: 11px;
    color: #64748b;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
}

/* Active Touch Feedback */
.rp-wholesale-card:active {
    transform: scale(0.98);
}

/* Hover state - Strict invariant: Text NEVER turns white on light surface! */
.rp-wholesale-card:hover {
    border-color: var(--rp-hover-border, #C5A059);
    background-color: var(--rp-card-bg, #ffffff);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.rp-wholesale-card:hover .rp-card-qty {
    color: var(--rp-text, #1e293b);
}

/* Active State */
.rp-wholesale-card.is-active {
    border-color: var(--rp-primary, #5B000A);
    background-color: var(--rp-active-bg, #fff5f6);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.rp-wholesale-card.is-active .rp-card-qty {
    color: var(--rp-primary, #5B000A);
    font-weight: 700;
}

/* Wholesale Inquiry Chip (> threshold) */
.rp-wholesale-card-inquiry {
    border: 1.5px dashed var(--rp-accent, #C5A059);
    background: var(--rp-card-bg, #ffffff);
}

.rp-wholesale-card-inquiry:hover {
    border-color: var(--rp-primary, #5B000A);
    background: var(--rp-active-bg, #fff5f6);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.rp-tag-vip {
    background: var(--rp-accent, #C5A059) !important;
    color: var(--rp-badge-text, #ffffff) !important;
}

/* Dynamic Live Summary Bar (Desktop) */
.rp-wholesale-summary-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 9px;
    padding: 8px 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12px;
    color: #475569;
}

.rp-summary-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rp-summary-chip span {
    color: #64748b;
}

.rp-summary-dot {
    color: #cbd5e1;
    font-size: 11px;
}

.rp-val-qty,
.rp-val-unit {
    color: #1e293b;
    font-weight: 700;
}

.rp-summary-total-chip .rp-val-total {
    color: var(--rp-primary, #5B000A);
    font-size: 13px;
    font-weight: 800;
}

/* Notice for redirect when high quantity entered */
.rp-wholesale-redirect-notice {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
}

.rp-notice-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.rp-notice-text {
    font-size: 12px;
    color: #92400e;
    font-weight: 600;
}

.rp-notice-link.button {
    background-color: var(--rp-primary, #5B000A) !important;
    color: var(--rp-badge-text, #ffffff) !important;
    border: none !important;
    border-radius: 5px !important;
    padding: 4px 12px !important;
    font-size: 11.5px !important;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.rp-notice-link.button:hover {
    opacity: 0.9 !important;
    color: var(--rp-badge-text, #ffffff) !important;
}

/* Cart Item Styles */
.rp-cart-price-wrap {
    --rp-primary: #5B000A;
    --rp-badge-text: #ffffff;
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
}

.rp-cart-old-price {
    font-size: 11px;
    color: #94a3b8;
    text-decoration: line-through;
}

.rp-cart-new-price {
    font-weight: 700;
    color: var(--rp-primary, #5B000A);
}

.rp-cart-badge {
    display: inline-block;
    padding: 1px 5px;
    background: var(--rp-primary, #5B000A);
    color: var(--rp-badge-text, #ffffff) !important;
    font-size: 9.5px;
    font-weight: 600;
    border-radius: 3px;
    margin-top: 1px;
    width: fit-content;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* Tablet and Standard Mobile (up to 640px): 2 cards per row */
@media (max-width: 640px) {
    .rp-wholesale-container {
        margin: 10px 0 14px;
        padding: 9px 10px;
        border-radius: 9px;
    }

    .rp-wholesale-header {
        margin-bottom: 7px;
        padding-bottom: 5px;
    }

    .rp-wholesale-title-wrap {
        font-size: 12px;
    }

    .rp-wholesale-hint {
        font-size: 10.5px;
    }

    .rp-wholesale-grid {
        gap: 6px;
    }

    /* Exactly 2 cards per row */
    .rp-wholesale-card {
        flex: 1 1 calc(50% - 6px);
        min-width: 120px;
        min-height: 42px;
        padding: 8px 10px;
    }

    /* If a single card remains alone on an odd row, stretch it to 100% full width */
    .rp-wholesale-card:last-child:nth-child(odd) {
        flex: 1 1 100%;
    }

    .rp-card-qty {
        font-size: 12px;
    }

    .rp-card-tag {
        font-size: 10.5px;
        padding: 1px 5px;
    }

    /* Structured 2-column mobile summary bar */
    .rp-wholesale-summary-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 8px;
        padding: 7px 9px;
        font-size: 11.5px;
        border-radius: 7px;
    }

    .rp-wholesale-summary-bar .rp-summary-dot {
        display: none;
    }

    .rp-summary-chip {
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #f8fafc;
        padding: 5px 8px;
        border-radius: 6px;
        border: 1px solid #eef2f6;
    }

    .rp-summary-total-chip {
        grid-column: 1 / -1;
        background: var(--rp-active-bg, #fff5f6);
        border-color: var(--rp-primary, #5B000A);
    }

    .rp-summary-total-chip .rp-val-total {
        font-size: 13px;
        font-weight: 800;
        color: var(--rp-primary, #5B000A);
    }
}

/* Micro Mobile (up to 380px): 1 card per row */
@media (max-width: 380px) {
    .rp-wholesale-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .rp-wholesale-hint {
        display: none;
    }

    /* Full width 1 card per row */
    .rp-wholesale-card {
        flex: 1 1 100%;
        min-width: 100%;
        padding: 9px 12px;
    }

    .rp-wholesale-summary-bar {
        grid-template-columns: 1fr;
    }

    .rp-summary-total-chip {
        grid-column: auto;
    }
}
