/* Bulk Discount Widget Styles - Responsive Fixed */

.bulk-discount-container {
    font-family: inherit;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    direction: rtl;
    text-align: right;
    background-color: #fff;
    position: relative; /* برای limited-notice */
    box-sizing: border-box;
    width: 100%;
}

/* Title */
.bulk-discount-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
    flex-wrap: wrap; /* ✅ اضافه شد */
}

.bulk-discount-title i,
.bulk-discount-title svg {
    font-size: 14px;
    flex-shrink: 0; /* ✅ اضافه شد */
}

/* Table Container */
.bulk-discount-table {
    padding: 0;
    width: 100%;
    overflow: hidden; /* ✅ اضافه شد */
}

/* Header Row */
.discount-header {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1.2fr; /* ✅ نسبت بهتر */
    gap: 0;
    padding: 5px 8px;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
    text-align: center;
    font-size: 11px;
    color: #888;
    box-sizing: border-box;
}

/* Discount Rows */
.discount-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1.2fr; /* ✅ هماهنگ با header */
    gap: 0;
    padding: 6px 8px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.15s ease;
    align-items: center;
    text-align: center;
    box-sizing: border-box;
}

.discount-row:last-child {
    border-bottom: none;
}

.discount-row:hover {
    background-color: #fafafa;
}

.discount-row.active {
    background-color: #f5f5f5;
}

.discount-row.recommended-row {
    position: relative;
}

/* Row Quantity */
.row-qty {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap; /* ✅ اضافه شد */
}

/* Row Price */
.row-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
    flex-wrap: wrap; /* ✅ اضافه شد */
}

.price-amount {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    direction: ltr;
    white-space: nowrap; /* ✅ اضافه شد */
}

.price-currency {
    font-size: 10px;
    color: #aaa;
    white-space: nowrap; /* ✅ اضافه شد */
}

/* Row Discount */
.row-discount {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap; /* ✅ اضافه شد - مهم‌ترین fix */
}

/* Discount Badge */
.discount-badge {
    display: inline-block;
    padding: 2px 8px;
    background-color: #e8f5e9;
    color: #388e3c;
    font-size: 12px;
    font-weight: 600;
    border-radius: 10px;
    min-width: 36px;
    text-align: center;
    white-space: nowrap; /* ✅ اضافه شد */
    flex-shrink: 0; /* ✅ اضافه شد */
}

/* Recommended Badge */
.recommended-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 5px;
    background-color: #fce4ec;
    color: #c62828;
    font-size: 9px;
    font-weight: 600;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0; /* ✅ اضافه شد */
}

.recommended-badge::before {
    content: '🔥';
    font-size: 9px;
}

/* Stock Info */
.bulk-discount-stock {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 6px;
    padding: 4px;
    color: #4caf50;
    font-weight: 600;
    font-size: 11px;
    flex-wrap: wrap; /* ✅ اضافه شد */
}

.bulk-discount-stock i {
    font-size: 12px;
    flex-shrink: 0;
}

/* =====================
   RESPONSIVE - Tablet
   ===================== */
@media (max-width: 991px) {
    .bulk-discount-container {
        padding: 8px;
    }

    .bulk-discount-title {
        font-size: 12px;
    }

    .discount-header {
        font-size: 10px;
        padding: 4px 6px;
    }

    .discount-row {
        padding: 5px 6px;
    }

    .row-qty {
        font-size: 12px;
    }

    .price-amount {
        font-size: 12px;
    }

    .discount-badge {
        padding: 2px 6px;
        font-size: 11px;
    }
}

/* =====================
   RESPONSIVE - Mobile
   ===================== */
@media (max-width: 767px) {
    .bulk-discount-container {
        padding: 8px 6px;
    }

    .bulk-discount-title {
        font-size: 12px;
        margin-bottom: 6px;
    }

    /* ✅ استفاده از fr به جای px ثابت */
    .discount-header {
        grid-template-columns: 1fr 1.4fr 1.1fr;
        font-size: 10px;
        padding: 4px 4px;
    }

    .discount-row {
        grid-template-columns: 1fr 1.4fr 1.1fr;
        padding: 5px 4px;
    }

    .row-qty {
        font-size: 11px;
    }

    .price-amount {
        font-size: 11px;
    }

    .price-currency {
        font-size: 9px;
    }

    .discount-badge {
        padding: 2px 5px;
        font-size: 10px;
        min-width: 28px; /* ✅ کوچک‌تر شد */
    }

    .recommended-badge {
        font-size: 8px;
        padding: 1px 4px;
        /* ✅ روی موبایل زیر badge بره */
        display: block;
        margin-top: 2px;
        text-align: center;
    }

    .recommended-badge::before {
        display: none; /* ✅ emoji رو روی موبایل مخفی کن */
    }

    .bulk-discount-stock {
        font-size: 10px;
        padding: 3px;
    }
}

/* =====================
   RESPONSIVE - Small Mobile
   ===================== */
@media (max-width: 480px) {

    .bulk-discount-container {
        padding: 6px 4px;
    }

    .discount-header,
    .discount-row {
        grid-template-columns: 1fr 1.3fr 1fr; /* ✅ fr به جای px */
        padding: 4px 3px;
    }

    .row-qty {
        font-size: 10px;
    }

    .price-amount {
        font-size: 10px;
    }

    .price-currency {
        display: none; /* ✅ روی خیلی کوچیک مخفی بشه */
    }

    .discount-badge {
        font-size: 10px;
        min-width: 24px;
        padding: 2px 4px;
    }

    .discount-header {
        font-size: 9px;
    }
}

/* =====================
   RESPONSIVE - XSmall (360px>)
   ===================== */
@media (max-width: 380px) {
    .bulk-discount-title span {
        font-size: 11px;
    }

    .row-qty,
    .price-amount,
    .discount-badge {
        font-size: 9px;
    }

    .discount-header {
        font-size: 8px;
    }
}

/* =====================
   Limited Notice - Fixed
   ===================== */
.bulk-discount-container.bulk-discount-disabled {
    position: relative;
    opacity: 0.5;
    pointer-events: none;
}

.bulk-discount-container.bulk-discount-disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 1;
    border-radius: inherit;
}

/* ✅ Fix: limited-notice روی موبایل */
.bulk-discount-limited-notice {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ff6b6b;
    color: white;
    padding: 10px 16px; /* ✅ کمتر از قبل */
    border-radius: 8px;
    font-weight: bold;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: normal; /* ✅ تغییر از nowrap */
    text-align: center;
    width: max-content;
    max-width: 85%; /* ✅ از container خارج نشه */
    font-size: 13px;
    line-height: 1.4;
}

@media (max-width: 480px) {
    .bulk-discount-limited-notice {
        font-size: 11px;
        padding: 8px 12px;
        max-width: 90%;
    }
}

/* =====================
   Out of Stock
   ===================== */
.discount-row.out-of-stock {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
}

.stock-unavailable {
    font-size: 10px;
    color: #e53935;
    font-weight: 500;
    margin-right: 4px;
    display: block; /* ✅ روی موبایل زیر qty بره */
}

@media (min-width: 768px) {
    .stock-unavailable {
        display: inline; /* ✅ دسکتاپ: کنار qty */
    }
}

/* =====================
   Loading & Print
   ===================== */
.bulk-discount-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

@media print {
    .bulk-discount-container {
        box-shadow: none;
    }
    .discount-row {
        cursor: default;
    }
}
