/* ════════════════════════════════════════════════════════════════
   Invoice/POS/PriceOffer Mobile Optimization
   ─────────────────────────────────────────────
   • تطبيق على: FrmOrders, FrmPOS, FrmPriceOffer
   • شاشات الفاتورة و POS و عرض السعر على الموبايل
   • هدف: تجربة فاتورة مريحة على الجوال
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

    /* ═══ 1) Header Card — مدمج و compact ═══ */
    body .invoice-header-card,
    body .order-header-card,
    body .pos-header-card,
    body .invoice-header,
    body .frm-header {
        padding: 8px 10px !important;
        margin-bottom: 6px !important;
        border-radius: 10px !important;
    }

    /* ═══ 2) Form fields في الـ header — صف كل واحد ═══ */
    body .inv-grid-card .row > [class*="col-"],
    body .invoice-header .row > [class*="col-"],
    body .frm-form-row > [class*="col-"] {
        margin-bottom: 6px !important;
    }

    /* ═══ 3) Customer/Items search inputs — أكبر و touch-friendly ═══ */
    body .inv-cust-search,
    body .inv-item-search,
    body input[placeholder*="customer" i],
    body input[placeholder*="عميل"],
    body input[placeholder*="صنف"],
    body input[placeholder*="item" i] {
        min-height: 44px !important;
        font-size: 16px !important;
        padding: 10px 14px !important;
    }

    /* ═══ 4) Grid Card على الموبايل — full width و scrollable، ملتصق بالـ Footer ═══ */
    body .inv-grid-card,
    body .pos-grid-card,
    body .order-grid-card {
        margin: 4px 0 0 !important;        /* ✦ مفيش margin سفلى */
        padding: 4px 4px 0 !important;     /* مفيش padding سفلى */
        border-radius: 8px 8px 0 0 !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    /* الـ inv-grid-body بدون padding سفلى */
    body .inv-grid-body {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }

    /* ═══ 5) Hide بعض الأعمدة الثانوية فى DxGrid على الموبايل ═══ */
    /* ItemCode (يظهر فى ItemName عادة) */
    body .inv-grid-card .dxbl-grid th[data-fieldname="ItemCode"],
    body .inv-grid-card .dxbl-grid td[data-fieldname="ItemCode"],
    body .pos-grid-card .dxbl-grid th[data-fieldname="ItemCode"],
    body .pos-grid-card .dxbl-grid td[data-fieldname="ItemCode"] {
        display: none !important;
    }
    /* StoreName (الفرع) — لو شركة واحدة */
    body .inv-grid-card .dxbl-grid th[data-fieldname="StoreName"],
    body .inv-grid-card .dxbl-grid td[data-fieldname="StoreName"] {
        display: none !important;
    }
    /* PatchNumber — اخفِ على الموبايل */
    body .inv-grid-card .dxbl-grid th[data-fieldname="PatchNumber"],
    body .inv-grid-card .dxbl-grid td[data-fieldname="PatchNumber"] {
        display: none !important;
    }

    /* ═══ 6) Totals/Footer Section — Sticky أسفل الشاشة ═══ */
    body .inv-totals,
    body .invoice-totals,
    body .order-totals,
    body .pos-totals,
    body .frm-footer-totals {
        position: sticky !important;
        bottom: 70px !important;       /* فوق الـ Bottom Nav */
        background: #fff !important;
        border-top: 2px solid var(--fs-primary) !important;
        box-shadow: 0 -4px 16px rgba(0,0,0,.12) !important;
        padding: 10px 12px !important;
        z-index: 100 !important;
        margin: 8px -8px 0 !important;
        border-radius: 12px 12px 0 0 !important;
    }

    /* النصوص داخل الـ totals — أوضح */
    body .inv-totals .total-label,
    body .invoice-totals .total-label,
    body .order-totals .total-label {
        font-size: 12px !important;
        font-weight: 600 !important;
    }
    body .inv-totals .total-value,
    body .invoice-totals .total-value,
    body .order-totals .total-value,
    body .grand-total {
        font-size: 17px !important;
        font-weight: 800 !important;
        color: var(--fs-primary) !important;
    }

    /* ═══ 7) Action Buttons (Save/Print/Cancel) — bigger و واضح ═══ */
    body .inv-actions,
    body .order-actions,
    body .pos-actions,
    body .frm-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 8px !important;
    }
    body .inv-actions .btn,
    body .order-actions .btn,
    body .pos-actions .btn,
    body .frm-actions .btn {
        flex: 1 1 auto !important;
        min-width: 100px !important;
        min-height: 44px !important;
        font-size: 13.5px !important;
        font-weight: 700 !important;
    }
    /* زر الحفظ الأساسى — أبرز */
    body .inv-actions .btn-save,
    body .inv-actions .btn-primary[type="submit"],
    body .btn.save-btn {
        background: linear-gradient(135deg, #22c55e, #16a34a) !important;
        border: none !important;
        color: #fff !important;
        flex: 2 1 auto !important;
    }

    /* ═══ 8) Section titles — أوضح ═══ */
    body .inv-section-title,
    body .invoice-section-title,
    body .frm-section-title {
        font-size: 13px !important;
        font-weight: 700 !important;
        color: var(--fs-primary-ink) !important;
        padding: 8px 10px !important;
        background: var(--fs-tint-2) !important;
        border-inline-start: 3px solid var(--fs-primary) !important;
        margin: 8px 0 4px !important;
        border-radius: 6px !important;
    }

    /* ═══ 9) Search Result Dropdowns — bottom sheet style ═══ */
    body .inv-search-results,
    body .item-search-popup,
    body .customer-search-popup {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        max-height: 70vh !important;
        max-height: 70dvh !important;
        border-radius: 16px 16px 0 0 !important;
        box-shadow: 0 -8px 32px rgba(0,0,0,.2) !important;
        animation: fs-bottom-sheet-up .25s cubic-bezier(0.22,1,0.36,1) both !important;
        overflow-y: auto !important;
        z-index: 9999 !important;
    }

    /* ═══ 10) Print Preview على الموبايل ═══ */
    body .fs-print-popup .dxbl-popup {
        height: 92vh !important;
        height: 92dvh !important;
        max-height: 92vh !important;
        max-height: 92dvh !important;
    }

    /* ═══ 11) Stats/KPI cards — صفين ═══ */
    body .inv-stats-row,
    body .order-stats-row {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }

    /* ═══ 12) الجرد ملتصق بالـ Footer (مفيش مسافة) ═══ */
    body .inv-grid-card,
    body .pos-grid-card,
    body .order-grid-card {
        margin-bottom: 0 !important;
    }
}

/* ─── PHONES (≤480px) — إحكام أكتر ─── */
@media (max-width: 480px) {
    body .inv-grid-card,
    body .pos-grid-card,
    body .order-grid-card {
        padding: 2px !important;
    }
    body .inv-section-title {
        font-size: 12px !important;
        padding: 6px 8px !important;
    }
    body .grand-total {
        font-size: 16px !important;
    }
}
