/* ==================================
   Online Invoice – Stable Responsive UI
================================== */

.oi-invoice {
    max-width: 1100px;
    margin: 24px auto;
    padding: 16px;
    background: #fff;
    border-radius: 8px;
}

/* ---------- Table Wrapper ---------- */
.oi-invoice .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

/* ---------- Table ---------- */
.oi-invoice table {
    min-width: 100%;
    width: 100%;
    border-collapse: collapse;
}

.oi-invoice th,
.oi-invoice td {
    vertical-align: middle;
    padding: 12px 8px;
}

/* ستون عنوان محصول فضای بیشتری بگیرد */
.oi-invoice th:nth-child(2),
.oi-invoice td:nth-child(2) {
    min-width: 200px;
    white-space: normal !important;
    word-break: break-word;
}

/* ---------- Inputs ---------- */
.oi-invoice input.form-control,
.oi-invoice select.form-select {
    min-width: 0;
    width: 100%;
}

/* فیلد عنوان محصول گسترده‌تر */
.oi-invoice td:nth-child(2) input.form-control {
    min-width: 180px;
}

/* ---------- Discount Cell ---------- */
.oi-invoice td .discount-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 160px;
}

.oi-invoice td .discount-type {
    min-width: 70px !important;
    max-width: 70px;
    font-size: 14px;
}

.oi-invoice td .discount {
    min-width: 80px !important;
    flex-grow: 1;
}

/* ---------- Buttons ---------- */
.oi-invoice .btn {
    white-space: nowrap;
}

/* ==================================
   Mobile Fixes (بهبود یافته - بخش تخفیف)
================================== */
@media (max-width: 768px) {
    .oi-invoice {
        padding: 12px;
        margin: 12px auto;
    }

    /* کاهش padding در موبایل */
    .oi-invoice th,
    .oi-invoice td {
        padding: 8px 6px;
        font-size: 13px;
    }

    /* تنظیم عرض ستون‌ها در موبایل */
    .oi-invoice th:nth-child(1),
    .oi-invoice td:nth-child(1) {
        width: 40px; /* ستون شماره */
    }
    
    .oi-invoice th:nth-child(2),
    .oi-invoice td:nth-child(2) {
        min-width: 160px;
        max-width: 160px;
    }
    
    .oi-invoice th:nth-child(3),
    .oi-invoice td:nth-child(3) {
        width: 70px; /* ستون تعداد */
    }
    
    .oi-invoice th:nth-child(4),
    .oi-invoice td:nth-child(4) {
        width: 100px; /* ستون قیمت */
    }
    
    /* ستون تخفیف - عرض بیشتر */
    .oi-invoice th:nth-child(5),
    .oi-invoice td:nth-child(5) {
        width: 150px !important; /* افزایش عرض */
        min-width: 150px !important;
    }
    
    .oi-invoice th:nth-child(6),
    .oi-invoice td:nth-child(6) {
        width: 90px; /* ستون مبلغ */
    }
    
    .oi-invoice th:nth-child(7),
    .oi-invoice td:nth-child(7) {
        width: 60px; /* ستون حذف */
    }

    /* بخش تخفیف - بهبود یافته */
    .oi-invoice td .discount-wrap {
        flex-direction: row !important; /* تغییر از column به row */
        align-items: center;
        gap: 6px;
        min-width: 140px !important;
    }

    /* نوع تخفیف */
    .oi-invoice td .discount-type {
        min-width: 65px !important;
        max-width: 65px !important;
        font-size: 13px;
        padding: 6px 4px;
    }
    
    /* مقدار تخفیف */
    .oi-invoice td .discount {
        min-width: 70px !important;
        flex-grow: 1;
        padding: 6px 8px;
        font-size: 13px;
    }

    /* دکمه حذف */
    .oi-invoice td .btn-danger {
        width: 34px;
        height: 34px;
        padding: 0;
        font-size: 16px;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* هدر جدول فشرده‌تر */
    .oi-invoice th {
        font-size: 12px;
        white-space: nowrap;
        padding: 8px 4px;
    }

    .oi-invoice th:nth-child(5) {
        font-size: 11.5px;
    }

    /* فیلدهای ورودی کوچکتر */
    .oi-invoice input.form-control,
    .oi-invoice select.form-select {
        font-size: 13px;
        padding: 6px 8px;
    }
}

/* تبلت‌های کوچک */
@media (min-width: 576px) and (max-width: 768px) {
    .oi-invoice th:nth-child(5),
    .oi-invoice td:nth-child(5) {
        width: 180px !important;
        min-width: 180px !important;
    }
    
    .oi-invoice td .discount-wrap {
        min-width: 160px !important;
        gap: 8px;
    }
    
    .oi-invoice td .discount-type {
        min-width: 75px !important;
        max-width: 75px !important;
    }
    
    .oi-invoice td .discount {
        min-width: 80px !important;
    }
}

/* موبایل‌های خیلی کوچک */
@media (max-width: 480px) {
    .oi-invoice {
        padding: 8px;
    }
    
    .oi-invoice th:nth-child(2),
    .oi-invoice td:nth-child(2) {
        min-width: 140px;
        max-width: 140px;
    }
    
    /* ستون تخفیف در موبایل کوچک */
    .oi-invoice th:nth-child(5),
    .oi-invoice td:nth-child(5) {
        width: 140px !important;
        min-width: 140px !important;
    }
    
    .oi-invoice th,
    .oi-invoice td {
        padding: 6px 4px;
        font-size: 12px;
    }
    
    .oi-invoice td .discount-wrap {
        min-width: 130px !important;
        gap: 4px;
    }
    
    .oi-invoice td .discount-type {
        min-width: 60px !important;
        max-width: 60px !important;
        font-size: 12px;
        padding: 5px 3px;
    }
    
    .oi-invoice td .discount {
        min-width: 65px !important;
        font-size: 12px;
        padding: 5px 6px;
    }
    
    .oi-invoice input.form-control,
    .oi-invoice select.form-select {
        font-size: 12px;
        padding: 5px 6px;
    }
}

/* دسکتاپ کوچک */
@media (min-width: 769px) and (max-width: 992px) {
    .oi-invoice th:nth-child(5),
    .oi-invoice td:nth-child(5) {
        min-width: 170px;
    }
    
    .oi-invoice td .discount-wrap {
        min-width: 150px;
    }
}