/* 
 * POS Table Fix - إصلاح جدول المنتجات في نقطة البيع
 * تصميم احترافي ومدمج للأزرار والحقول
 */

/* ==========================================
 * QUANTITY CONTAINER - مربع الكمية المدمج
 * ========================================== */

.pos-qty-container {
    display: inline-flex !important;
    align-items: center !important;
    background: white !important;
    border: 2px solid #dfe4ea !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    max-width: 110px !important;
    margin: 0 !important;
    vertical-align: middle !important;
}

.pos-qty-btn {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    border: none !important;
    color: #495057 !important;
    padding: 4px 6px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-size: 12px !important;
    min-width: 24px !important;
    width: 24px !important;
    height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.pos-qty-minus {
    border-right: 2px solid #dfe4ea !important;
}

.pos-qty-minus i {
    color: #dc3545 !important;
}

.pos-qty-plus {
    border-left: 2px solid #dfe4ea !important;
}

.pos-qty-plus i {
    color: #28a745 !important;
}

.pos-qty-btn:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%) !important;
    transform: scale(1.05) !important;
}

.pos-qty-btn:active {
    transform: scale(0.95) !important;
}

.pos-qty-input {
    flex: 1 !important;
    border: none !important;
    text-align: center !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 4px 6px !important;
    background: transparent !important;
    min-width: 40px !important;
    max-width: 60px !important;
    height: 28px !important;
}

.pos-qty-input:focus {
    outline: none !important;
    background: #f8f9fa !important;
}

/* حماية الأيقونات */
.pos-qty-btn i {
    font-family: 'Font Awesome 6 Free', 'FontAwesome' !important;
    font-weight: 900 !important;
    font-size: 10px !important;
    pointer-events: none !important;
    line-height: 1 !important;
}

/* ==========================================
 * TABLE OPTIMIZATIONS - تحسينات الجدول
 * ========================================== */

/* إزالة الظلال من صفوف الجدول */
#pos_table tbody tr.product_row {
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    background-color: #fff !important;
    border-bottom: 1px solid #e9ecef !important;
}

#pos_table tbody tr.product_row:hover {
    background-color: #f8f9fa !important;
}

/* تصغير عرض الأعمدة وتقليل الارتفاع */
#pos_table th,
#pos_table td {
    padding: 6px 4px !important;
    vertical-align: middle !important;
    line-height: 1.2 !important;
}

/* تقليل الارتفاع الإجمالي للصف */
#pos_table tbody tr {
    height: auto !important;
    min-height: 40px !important;
}

/* عمود الكمية - أصغر حجم */
#pos_table th:nth-child(2),
#pos_table td:nth-child(2) {
    width: 220px !important;
    max-width: 220px !important;
    padding: 4px 6px !important;
}

/* عمود سعر الوحدة */
#pos_table th:nth-child(3),
#pos_table td:nth-child(3) {
    width: 100px !important;
    max-width: 100px !important;
}

/* عمود المجموع */
#pos_table th:nth-child(4),
#pos_table td:nth-child(4) {
    width: 100px !important;
    max-width: 100px !important;
}

/* عمود الحذف */
#pos_table th:last-child,
#pos_table td:last-child {
    width: 50px !important;
    max-width: 50px !important;
}

/* تصغير حقول الإدخال */
#pos_table input.pos_unit_price_inc_tax,
#pos_table input.pos_line_total {
    font-size: 12px !important;
    padding: 4px 6px !important;
    text-align: center !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    height: 28px !important;
    line-height: 1.2 !important;
}

#pos_table input.pos_unit_price_inc_tax:focus,
#pos_table input.pos_line_total:focus {
    border-color: #3498db !important;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1) !important;
}

/* ==========================================
 * SUB UNIT SELECT - قائمة الوحدات الفرعية
 * ========================================== */

#pos_table select.sub_unit {
    font-size: 11px !important;
    padding: 4px 6px !important;
    margin: 0 0 0 6px !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    display: inline-block !important;
    vertical-align: middle !important;
    max-width: 90px !important;
    height: 28px !important;
}

/* Container للكمية والوحدة */
#pos_table td:nth-child(2) {
    white-space: nowrap !important;
}

/* إخفاء <br> بين الكمية والوحدة */
#pos_table td:nth-child(2) br {
    display: none !important;
}

/* ==========================================
 * DELETE BUTTON - زر الحذف
 * ========================================== */

#pos_table .pos_remove_row {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
    color: white !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    border: none !important;
}

#pos_table .pos_remove_row:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%) !important;
    transform: scale(1.05) !important;
}

/* ==========================================
 * PRODUCT NAME COLUMN - عمود اسم المنتج
 * ========================================== */

#pos_table td:first-child {
    font-size: 12px !important;
    line-height: 1.3 !important;
    padding: 4px 6px !important;
}

#pos_table .lot_number {
    font-size: 10px !important;
    margin-top: 2px !important;
}

/* تقليل المسافة بين اسم المنتج و SKU */
#pos_table td:first-child br {
    line-height: 0.8 !important;
}

/* ==========================================
 * TABLE HEADER - رأس الجدول
 * ========================================== */

#pos_table thead th {
    background-color: #8D8AA1 !important;
    color: white !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    text-align: center !important;
    border: 1px solid #7a7788 !important;
}

/* تنسيق خاص لعمود الكمية */
#pos_table .quantity-cell-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
}

/* ==========================================
 * RESPONSIVE - للشاشات الصغيرة
 * ========================================== */

@media (max-width: 768px) {
    .pos-qty-container {
        max-width: 100px !important;
    }
    
    .pos-qty-btn {
        min-width: 22px !important;
        width: 22px !important;
        height: 26px !important;
        padding: 3px 5px !important;
    }
    
    .pos-qty-btn i {
        font-size: 9px !important;
    }
    
    .pos-qty-input {
        font-size: 11px !important;
        padding: 3px 4px !important;
        height: 26px !important;
    }
    
    #pos_table th,
    #pos_table td {
        padding: 4px 3px !important;
        font-size: 11px !important;
    }
    
    #pos_table select.sub_unit {
        font-size: 10px !important;
        max-width: 70px !important;
        height: 26px !important;
    }
}

/* ==========================================
 * FIX OLD BUTTONS - إصلاح الأزرار القديمة
 * ========================================== */

/* إخفاء الأزرار القديمة إذا كانت موجودة */
#pos_table .quantity-up,
#pos_table .quantity-down {
    display: none !important;
}

/* ==========================================
 * OVERALL TABLE STYLING - تنسيق عام
 * ========================================== */

#pos_table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

#pos_table tbody {
    background: white !important;
}

/* تحسين القراءة */
#pos_table tbody tr:nth-child(even) {
    background-color: #f8f9fa !important;
}

#pos_table tbody tr:nth-child(odd) {
    background-color: #ffffff !important;
}

/* ==========================================
 * INPUT NUMBER SPINNER HIDE - إخفاء الأسهم
 * ========================================== */

#pos_table input[type=number]::-webkit-inner-spin-button,
#pos_table input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

#pos_table input[type=number] {
    -moz-appearance: textfield !important;
}

/* ==========================================
 * PRICE DISPLAY - عرض الأسعار
 * ========================================== */

#pos_table .display_currency {
    font-weight: 600 !important;
    color: #2c3e50 !important;
}

/* ==========================================
 * BORDERS - الحدود
 * ========================================== */

#pos_table {
    border: 2px solid #dee2e6 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}
