/*
 * واجهة موبايل لـ Ultimate POS (mgingaz.com) — فوق AdminLTE 2 / Bootstrap 3 من غير ما نغيّر ملفاتهم.
 * بتشتغل على الشاشات الصغيرة بس (أقل من 768px)، ما عدا الخط والتحسينات العامة.
 */

/* ===== عام (كل المقاسات) ===== */
body, h1, h2, h3, h4, h5, h6, .btn, input, select, textarea, .select2-container, .main-sidebar, .content-header {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif !important;
}
.box { border-radius: 12px; }
.btn { border-radius: 8px; }
.btn-flat { border-radius: 8px; }
.form-control, .input-group-addon { border-radius: 8px; }
.input-group .form-control:not(:first-child):not(:last-child),
.input-group-addon:not(:first-child):not(:last-child) { border-radius: 0; }
.modal-content { border-radius: 14px; overflow: hidden; }

@media (max-width: 767px) {

    /* iOS بيعمل زوم لو الخط أصغر من 16px في الحقول */
    input.form-control, select.form-control, textarea.form-control,
    .select2-container .select2-selection, .select2-search__field {
        font-size: 16px !important;
    }
    .form-control, .select2-container .select2-selection--single { min-height: 44px; }
    .select2-container .select2-selection--single .select2-selection__rendered { line-height: 42px; }
    .select2-container .select2-selection--single .select2-selection__arrow { height: 42px; }

    /* ===== الهيدر: صف واحد وزراير أيقونة صغيرة ===== */
    .main-header .navbar { min-height: 50px; }
    .main-header .navbar .btn, .main-header .navbar .btn-app,
    .main-header .navbar a.btn { padding: 6px 9px !important; font-size: 13px !important; margin: 4px 2px !important; }
    .main-header .navbar .btn span, .main-header .navbar .btn .hidden-xs { display: none; }
    /* زراير الهيدر (نقطة بيع، الصيانة...) أيقونات بس */
    .main-header .navbar-custom-menu > .btn { font-size: 0 !important; line-height: 1; min-width: 38px; min-height: 36px; }
    .main-header .navbar-custom-menu > .btn strong { font-size: 0 !important; }
    .main-header .navbar-custom-menu > .btn i { font-size: 17px !important; }
    .content-header { padding: 10px 12px 0; }
    .content-header > h1 { font-size: 20px; }
    .content { padding: 10px 8px; }

    /* ===== الرئيسية: كروت الأرقام اتنين جنب بعض وأصغر ===== */
    .content .row > .col-custom { width: 50%; float: right; padding-left: 5px; padding-right: 5px; }
    .info-box, .info-box-new-style {
        display: flex !important; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 0 !important; height: auto !important;
        margin-bottom: 10px; padding: 10px 8px !important; border-radius: 14px;
    }
    .info-box .info-box-icon {
        float: none !important; position: static !important; flex: 0 0 40px; width: 40px !important; height: 40px !important;
        line-height: 40px !important; font-size: 20px !important; border-radius: 50% !important; margin: 0 !important;
    }
    .info-box .info-box-icon > i, .info-box .info-box-icon > svg { font-size: 20px !important; width: 20px; height: 20px; line-height: 40px; }
    .info-box .info-box-content { margin: 0 !important; padding: 0 !important; min-width: 0; flex: 1; }
    .info-box .info-box-text { font-size: 12px !important; white-space: normal !important; overflow: visible; text-overflow: clip; line-height: 1.4; }
    .info-box .info-box-number { font-size: 15px !important; white-space: nowrap; }
    .info-box .info-box-content small, .info-box .info-box-content p { font-size: 10px; white-space: normal; }
    .info-box > p { flex: 0 0 100%; margin: 0 !important; font-size: 10px !important; line-height: 1.5; position: static !important; }

    /* ===== الجداول ===== */
    .dataTables_wrapper .dt-buttons { text-align: center; margin-bottom: 6px; }
    .dataTables_wrapper .dt-buttons .btn { padding: 4px 8px; font-size: 12px; margin: 2px; }
    .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { text-align: center; }
    .dataTables_wrapper .dataTables_filter input { width: 100% !important; margin: 4px 0 0 !important; }
    .table-responsive, .dataTables_scrollBody, .dataTables_wrapper {
        -webkit-overflow-scrolling: touch;
    }
    table.dataTable td, table.dataTable th, .table > tbody > tr > td { font-size: 13px; padding: 6px 5px !important; white-space: nowrap; }
    table.dataTable .btn-xs, table.dataTable .btn-group .btn { padding: 4px 8px; font-size: 12px; }

    /* ===== المودالات: شاشة كاملة ===== */
    .modal-dialog { margin: 0; width: 100% !important; max-width: 100%; }
    .modal-content { border-radius: 0; min-height: 100vh; }
    .modal-footer .btn { min-height: 42px; }

    /* ===== شاشة البيع (POS) ===== */
    body.pos-mobile .pos-header { padding: 6px 8px 0; }
    body.pos-mobile .pos-header .btn { padding: 6px 9px !important; margin: 2px !important; }
    body.pos-mobile .pos-header p { margin: 0; font-size: 13px; }
    body.pos-mobile section.content { padding: 6px 4px; }
    body.pos-mobile section.content .row { margin-left: 0; margin-right: 0; }
    body.pos-mobile section.content [class*="col-"] { padding-left: 4px; padding-right: 4px; }
    body.pos-mobile .box { margin-bottom: 8px !important; }
    body.pos-mobile .box-body { padding: 8px; }

    /* جدول المنتجات: من غير المساحة الفاضية */
    body.pos-mobile .pos_product_div { min-height: 0 !important; height: auto !important; max-height: none !important; }
    body.pos-mobile #pos_table td, body.pos-mobile #pos_table th { white-space: normal; font-size: 13px; }
    body.pos-mobile #pos_table .input-group .btn { min-width: 40px; min-height: 40px; }
    body.pos-mobile #pos_table input.pos_quantity { min-height: 40px; }

    /* الإجمالي وزراير الدفع ثابتين تحت الشاشة */
    body.pos-mobile .pos-form-actions {
        position: fixed !important; left: 0; right: 0; bottom: 0; top: auto !important;
        z-index: 1030; margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
        background: #fff; box-shadow: 0 -4px 16px rgba(0, 0, 0, .12);
        border-radius: 14px 14px 0 0; width: 100% !important;
    }
    body.pos-mobile .pos-form-actions > .col-md-12 {
        display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 0; width: 100%; float: none;
    }
    body.pos-mobile .pos-form-actions .btn {
        width: 100% !important; margin: 0 !important; min-height: 42px; padding: 4px 2px !important;
        font-size: 13px !important; line-height: 1.2; white-space: normal; float: none !important;
        border-radius: 10px !important; border: 0;
    }
    body.pos-mobile .pos-form-actions .btn.hide { display: none !important; }
    body.pos-mobile .pos-form-actions .btn { order: 10; }
    /* الدفع الأول، وبعده الباقي */
    body.pos-mobile .pos-form-actions .pos-express-finalize[data-pay_method="cash"] { order: 1; }
    body.pos-mobile .pos-form-actions .pos-gateway-pay[data-gateway="kashier_card"] { order: 2; }
    body.pos-mobile .pos-form-actions .pos-gateway-pay[data-gateway="kashier_wallet"] { order: 3; }
    body.pos-mobile .pos-form-actions .pos-gateway-pay[data-gateway="fawry"] { order: 4; }
    body.pos-mobile .pos-form-actions #pos-finalize { order: 5; }
    body.pos-mobile .pos-form-actions .pos-express-finalize[data-pay_method="suspend"] { order: 6; }
    body.pos-mobile .pos-form-actions #pos-draft { order: 7; }
    body.pos-mobile .pos-form-actions #pos-quotation { order: 8; }
    body.pos-mobile .pos-form-actions #pos-cancel, body.pos-mobile .pos-form-actions #pos-delete { order: 9; }
    body.pos-mobile .pos-form-actions .pos-total, body.pos-mobile .pos-form-actions .pos-mobile-total {
        order: 0; grid-column: 1 / -1; display: flex !important; justify-content: space-between; align-items: center;
        padding: 6px 12px; border-radius: 10px; font-size: 18px; font-weight: 700; margin: 0;
    }
    body.pos-mobile .pos-form-actions .pos-total .number { font-size: 22px; }
    body.pos-mobile .pos-form-actions > .col-md-12 > *:not(.btn):not(.pos-total):not(.pos-mobile-total):not(input) { grid-column: 1 / -1; }
    /* مساحة تحت عشان المحتوى ما يستخباش ورا الزراير */
    body.pos-mobile .content-wrapper, body.pos-mobile section.content { padding-bottom: 250px !important; }
    body.pos-mobile footer { display: none; }
}
