/* ============================================================
   Web_POS — Responsive layer (mobile / tablet)
   Makes the whole app usable on small screens: sidebar drawer,
   compact header, stacked forms, scrollable tables, full-screen modals.
   ============================================================ */

/* ---------- Base safety ---------- */
html, body { overflow-x: hidden; }
img, video, canvas, svg { max-width: 100%; height: auto; }
* { box-sizing: border-box; }

/* ---------- Mobile sidebar drawer ---------- */
@media (max-width: 991.98px) {
    #main-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px !important;
        max-width: 86vw;
        height: 100vh;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateX(100%);
        transition: transform 0.28s ease;
        box-shadow: -6px 0 24px rgba(0,0,0,0.18);
        z-index: 1100;
    }
    body.sidebar-open #main-sidebar { transform: translateX(0); }
    // على الموبايل: تخطي وضع sidebar-mini المطوي — يجب أن يظهر السايدبار كاملاً
    html body.sidebar-mini #main-sidebar,
    html body.sidebar-mini.sidebar-open #main-sidebar,
    html body.sidebar-open #main-sidebar {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: auto !important;
        width: 85vw !important;
        max-width: 340px !important;
        height: 100vh !important;
        padding: 20px 14px !important;
        padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
        transform: translateX(0) !important;
        display: block !important;
        z-index: 1200 !important;
        overflow-y: auto !important;
        background: #fff !important;
    }
    html body:not(.sidebar-open) #main-sidebar { transform: translateX(100%) !important; }
    html body.sidebar-mini #main-sidebar h3,
    html body.sidebar-mini #main-sidebar .sidebar-user-zone,
    html body.sidebar-mini #main-sidebar .nav-group-title,
    html body.sidebar-mini #main-sidebar .collapse-label {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    html body.sidebar-mini #main-sidebar a {
        justify-content: flex-start !important;
        font-size: 0.95rem !important;
        padding: 12px 14px !important;
    }
    html body.sidebar-mini #main-sidebar a span { display: inline !important; }
    html body.sidebar-mini #main-sidebar a i { font-size: 1rem !important; margin-left: 10px; }
    body.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1090;
    }
    .main-content {
        margin-right: 0 !important;
        width: 100% !important;
        padding: 12px 14px !important;
    }
    #main-header { padding: 8px 12px !important; gap: 6px; flex-wrap: wrap; }
    #main-header h4 { font-size: 1.05rem; }
    .mobile-menu-btn { display: inline-flex !important; }
}

@media (min-width: 992px) {
    .mobile-menu-btn { display: none !important; }
    body.sidebar-open::after { display: none; }
}

/* ---------- Tablet ---------- */
@media (max-width: 991.98px) {
    .container, .container-fluid { padding-left: 10px; padding-right: 10px; }
    .row { margin-left: -6px; margin-right: -6px; }
    .row > * { padding-left: 6px; padding-right: 6px; }
    .card { margin-bottom: 12px; }
    .btn { min-height: 38px; }
}

/* ---------- Small phones ---------- */
@media (max-width: 575.98px) {
    body { font-size: 14px; }
    .main-content { padding: 8px 10px !important; }
    #main-header { padding: 6px 10px !important; }
    #main-header h4 { font-size: 0.95rem; }
    h2, .h2 { font-size: 1.25rem; }
    h3, .h3 { font-size: 1.1rem; }
    h4, .h4 { font-size: 1rem; }
    .table { font-size: 12px; }
    .btn-sm { padding: 4px 8px; font-size: 12px; }
    /* 16px to prevent iOS auto-zoom on focus */
    .form-control, .form-select, input, select, textarea { font-size: 16px !important; min-height: 44px; }
    .modal-dialog { margin: 8px; max-width: calc(100% - 16px); }
    .modal-content { border-radius: 12px; }
}

/* ---------- Tables: horizontal scroll ---------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { max-width: 100%; }
/* make any bare table scrollable */
.table { min-width: 600px; }
@media (max-width: 575.98px) {
    .table { min-width: 520px; }
}

/* ---------- Forms / grids stack ---------- */
@media (max-width: 767.98px) {
    .row.g-3 > [class*="col-"], .row.g-2 > [class*="col-"], .row > [class*="col-md-"], .row > [class*="col-lg-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .d-flex.gap-3, .d-flex.gap-4 { flex-wrap: wrap; }
}

/* ---------- Modals full screen on mobile ---------- */
@media (max-width: 575.98px) {
    .modal-dialog { width: 100%; max-width: 100%; margin: 0; }
    .modal-content { min-height: 100vh; border-radius: 0; }
    .modal-fullscreen-sm-down { width: 100vw; max-width: none; height: 100vh; margin: 0; }
}

@media (max-width: 991.98px) {
    #pos-tab { height: auto !important; min-height: 100vh; }
    #pos-tab > .row { height: auto !important; min-height: auto; }
    .table-wrapper { min-height: 200px; max-height: 40vh; }
}

/* ---------- AI chat panel ---------- */
@media (max-width: 575.98px) {
    #ai-chat-panel { width: calc(100vw - 12px) !important; left: 6px !important; right: 6px !important; }
}

/* ---------- Dropdowns ---------- */
.dropdown-menu { max-width: calc(100vw - 20px); }

/* ---------- Sidebar user zone compact ---------- */
@media (max-width: 991.98px) {
    .sidebar { width: 280px !important; max-width: 85vw; }
    .sidebar-user-zone { padding: 12px !important; }
}

/* ---------- Fix wide inputs ---------- */
input, select, textarea { max-width: 100%; }

/* ---------- Remove inner scrollbars on mobile (single page scroll) ---------- */
@media (max-width: 767.98px) {
    [style*="overflow-y: auto"],
    [style*="overflow:auto"],
    .table-wrapper,
    .modal-box,
    .dropdown-menu {
        max-height: none !important;
        overflow: visible !important;
    }
    .z-payments-inputs, #z-payments-inputs { max-height: none !important; overflow: visible !important; }
    .modal-box { width: 100% !important; max-width: 100% !important; margin: 0 !important; border-radius: 0 !important; min-height: 100vh; }
    /* 🧾 تأكيد الدفع على الموبايل: السكرول داخل المحتوى والأزرار تفضل ظاهرة تحت */
    #checkout-modal { align-items: flex-end !important; }
    #checkout-modal .modal-box {
        width: 100% !important; max-width: 100% !important; margin: 0 !important;
        min-height: 0 !important; height: auto !important; max-height: 92vh !important;
        border-radius: 18px 18px 0 0 !important; overflow: hidden !important;
        display: flex !important; flex-direction: column !important; padding: 14px 16px !important;
    }
    #checkout-modal #checkout-scroll-area {
        flex: 1 1 auto !important; min-height: 0 !important;
        overflow-y: auto !important; -webkit-overflow-scrolling: touch;
    }
    #checkout-modal .modal-box > h3 { flex: 0 0 auto; margin-bottom: 8px !important; }
    #checkout-modal .modal-box > .mt-3 { flex: 0 0 auto; }
    /* زرار «إضافة» في الكارت على الموبايل — أيقونة فقط وحجم مناسب */
    .btn-addon-inline { padding: .32rem .55rem; font-size: .72rem; line-height: 1.1; }
    .btn-addon-inline .addon-btn-label { display: none; }
    /* 🛡️ تحديد الصلاحيات على الموبايل: السكرول + زر التأكيد ثابت تحت */
    #user-permissions-modal { align-items: flex-end !important; }
    #user-permissions-modal .modal-box {
        width: 100% !important; max-width: 100% !important; margin: 0 !important;
        min-height: 0 !important; max-height: 94vh !important;
        border-radius: 18px 18px 0 0 !important; overflow: hidden !important;
        display: flex !important; flex-direction: column !important; padding: 12px 12px 0 !important;
    }
    #user-permissions-modal #upm-groups { overflow-y: auto !important; min-height: 0; flex: 1 1 auto; -webkit-overflow-scrolling: touch; padding-bottom: 10px; }
    #user-permissions-modal .upm-footer {
        position: sticky; bottom: 0; background: #fff; z-index: 5; flex: 0 0 auto;
        margin: 0 -12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        border-top: 1px solid #e5e7eb; box-shadow: 0 -6px 16px rgba(0,0,0,.06);
    }
    /* 🗺️ اختيار المحافظات/المناطق: يدعم السكرول */
    #gov-modal { align-items: flex-end !important; }
    #gov-modal .modal-box {
        width: 100% !important; max-width: 100% !important; margin: 0 !important;
        min-height: 0 !important; max-height: 92vh !important;
        border-radius: 18px 18px 0 0 !important; overflow: hidden !important;
        display: flex !important; flex-direction: column !important;
    }
    #gov-modal #gov-list { overflow-y: auto !important; max-height: 56vh !important; -webkit-overflow-scrolling: touch; }
    .container.vh-100, .d-flex.vh-100 { min-height: 100vh !important; height: auto !important; }
}
/* ---------- Modern auth cards ---------- */
.auth-page .card, #login-screen .card { border-radius: 20px !important; box-shadow: 0 20px 60px rgba(128,0,32,0.15) !important; }
.brand-mark { width: 72px; height: 72px; border-radius: 22px; display: flex; align-items: center; justify-content: center; font-size: 30px; background: linear-gradient(135deg, var(--brand, #800020), #b33a5a); color: #fff; box-shadow: 0 10px 30px rgba(128,0,32,0.25); }
@media (max-width: 575.98px) {
    #login-screen .card, .auth-page .card { border-radius: 0 !important; min-height: 100vh; box-shadow: none !important; }
    #login-screen .card-body, .auth-page .card-body { padding: 28px 20px !important; }
}

/* ---------- Touch targets ---------- */
@media (max-width: 767.98px) {
    a, button, .nav-link { min-height: 36px; }
}

/* ---------- Print reset ---------- */
@media print {
    .sidebar, #main-header, .mobile-menu-btn { display: none !important; }
    .main-content { margin: 0 !important; width: 100% !important; padding: 0 !important; }
}
@media (max-width: 991.98px) {
    .mobile-bottom-nav { display: flex !important; }
    #ai-chat-widget {
        position: fixed !important;
        bottom: 72px !important;
        right: auto !important;
        left: 14px !important;
        z-index: 1040 !important;
    }
    #ai-chat-fab { width:52px !important; height:52px !important; font-size:22px !important; box-shadow: 0 6px 18px rgba(26,26,26,.35); }
    body { padding-bottom: 72px !important; overflow-y: auto !important; height: auto !important; }
    .main-content { height: auto !important; min-height: calc(100vh - 64px) !important; overflow-y: visible !important; }
    #main-area { overflow-y: visible !important; }
}

/* ---------- Product cards (grid view) ---------- */
.product-card {
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    background: #fff !important;
    display: flex !important;
    flex-direction: column !important;
    height: 260px !important;
    min-height: 260px !important;
    overflow: visible !important;
}
#products-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 5), 1fr) !important;
    gap: 12px !important;
    align-items: stretch !important;
}
@media (max-width: 767.98px) {
    #products-grid { grid-template-columns: repeat(var(--grid-cols-mobile, 2), 1fr) !important; }
}
.pc-img {
    position: relative;
    width: 100%;
    height: 150px;
    min-height: 150px;
    background: #f8fafc;
    overflow: hidden;
    border-bottom: 1px solid #eef2f7;
    flex-shrink: 0;
}
.pc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* أول حرفين من الاسم عندما لا توجد صورة */
.pc-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    font-weight: 800;
    color: #6B0F1A;
    background: linear-gradient(135deg, #FBF3F4, #F1E3E6);
    letter-spacing: 1px;
    user-select: none;
}
.product-card .pc-overlay { pointer-events: none; }
.product-card .pc-overlay button { pointer-events: auto; }
@media (hover: hover) {
    .product-card:hover .pc-overlay { opacity: 1 !important; }
}
@media (max-width: 767.98px) {
    .product-card .pc-overlay { opacity: 1 !important; background: rgba(0,0,0,.35) !important; }
    .product-card .pc-overlay button { padding: 4px 8px; font-size: 12px; }
}

/* ---------- شاشات التسجيل/الدخول على الموبايل (تجنب القطع) ---------- */
@media (max-width: 575.98px) {
    .auth-page .container.vh-100,
    .auth-page .d-flex.vh-100 { min-height: 100vh !important; height: auto !important; padding-top: 6px; padding-bottom: 6px; overflow-y: auto; display: block; }
    .auth-page .card { padding: 18px 12px !important; border-radius: 12px !important; overflow: visible !important; }
    .brand-mark { width: 56px !important; height: 56px !important; font-size: 24px !important; }
    .auth-page h3 { font-size: 1.35rem !important; }
    .auth-page .card-body { padding: 16px 10px !important; }
}
    .auth-page .card { padding: 20px 12px !important; border-radius: 12px !important; }
    .brand-mark { width: 56px !important; height: 56px !important; font-size: 24px !important; }
    .auth-page h3 { font-size: 1.35rem !important; }

/* ---------- Mobile bottom navigation ---------- */
.mobile-bottom-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 62px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    display: none;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    padding-bottom: env(safe-area-inset-bottom);
}
.mobile-bottom-nav .mbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: #6b7280;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 2px;
    min-height: 56px;
    transition: color .15s;
}
.mobile-bottom-nav .mbn-item i { font-size: 18px; }
.mobile-bottom-nav .mbn-item.active { color: var(--brand); }
.mobile-bottom-nav .mbn-item:active { transform: scale(0.95); }

@media (max-width: 991.98px) {
    .mobile-bottom-nav { display: flex !important; }
    body { padding-bottom: 70px !important; overflow-y: auto !important; height: auto !important; min-height: 100vh; }
    .main-content { overflow-y: visible !important; height: auto !important; min-height: 0 !important; }
    #main-area { overflow-y: visible !important; height: auto !important; }
    #app-screen { height: auto !important; min-height: 100vh !important; }
    #ai-chat-widget {
        position: fixed !important;
        bottom: 72px !important;
        left: 12px !important;
        right: auto !important;
        z-index: 1001 !important;
    }
    #ai-chat-fab { width: 50px !important; height: 50px !important; font-size: 20px !important; box-shadow: 0 6px 18px rgba(26,26,26,.35); }
    .table-responsive { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
    .table { min-width: 600px; }
}
@media (min-width: 992px) {
    .mobile-bottom-nav { display: none !important; }
}

/* ============================================================
   🔐 شاشات الدخول والتسجيل — تخطيط منقسم موحّد (Flex)
   (المحتوى التعريفي يمين / الفورم شمال) — متطابق في الصفحتين
   ============================================================ */
.login-shell,
.reg-shell {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 100vh;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    background: #FAF8F8;
    position: relative;
    z-index: 10;
}
.login-shell > *, .reg-shell > * { min-width: 0; }

/* إخفاء عناصر التطبيق عند عرض شاشة الدخول/التسجيل */
body.auth-lock .mobile-bottom-nav,
body.auth-lock #ai-chat-widget,
body.auth-lock #main-sidebar,
body.auth-lock #main-header { display: none !important; }
.login-aside,
.reg-aside {
    flex: 0 0 45%;
    display: flex; flex-direction: column; justify-content: center;
    padding: 44px 42px;
    background: linear-gradient(160deg, #4A0812 0%, #6B0F1A 55%, #8F2A3A 100%);
    color: #fff; position: relative; overflow: hidden;
    border-radius: 0 0 0 40px;
}
.login-aside::after,
.reg-aside::after {
    content: ""; position: absolute; width: 360px; height: 360px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.10) 0%, transparent 68%);
    top: -130px; inset-inline-start: -110px; pointer-events: none;
}
.login-aside > *, .reg-aside > * { position: relative; z-index: 1; }
.login-logo, .reg-logo {
    width: 86px; height: 86px; border-radius: 26px; margin-bottom: 20px;
    box-shadow: 0 16px 40px rgba(0,0,0,.32);
}
.login-aside h1, .reg-aside h1 {
    font-size: clamp(28px, 3.2vw, 42px); font-weight: 800; color: #fff; margin-bottom: 12px; line-height: 1.3;
}
.login-aside p.lead, .reg-aside p.lead {
    color: rgba(255,255,255,.88); font-size: 15px; line-height: 1.95; margin-bottom: 24px;
}
.login-perks, .reg-perks { list-style: none; padding: 0; margin: 0; }
.login-perks li, .reg-perks li {
    display: flex; align-items: flex-start; gap: 11px;
    font-size: 14.5px; color: rgba(255,255,255,.93); margin-bottom: 12px; line-height: 1.6;
}
.login-perks i, .reg-perks i {
    width: 27px; height: 27px; border-radius: 9px; flex-shrink: 0; margin-top: 1px;
    background: rgba(255,255,255,.16); color: #fff; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
}
.login-aside .mini-badge, .reg-aside .mini-badge {
    display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
    background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28);
    padding: 7px 15px; border-radius: 999px; font-size: 12.5px; font-weight: 700; margin-bottom: 18px;
}
.login-form-wrap, .reg-form-wrap {
    flex: 1 1 55%;
    display: flex; align-items: center; justify-content: center;
    padding: 34px 26px;
    align-self: center;
}
/* بطاقة موحّدة للفورم */
.login-card, .reg-card {
    width: 100%; max-width: 520px;
    background: #fff; border-radius: 20px;
    box-shadow: 0 24px 60px rgba(74, 8, 18, .10);
    border: 1px solid #EFE7E8;
    overflow: hidden;
}
.login-card .top-bar, .reg-card .top-bar {
    height: 6px; background: linear-gradient(90deg, #6B0F1A, #8F2A3A, #C98D97);
}
.login-card .inner, .reg-card .inner { padding: 30px 30px 26px; }

/* ---------- شاشات أقل من الكمبيوتر: المحتوى فوق والفورم تحته ---------- */
@media (max-width: 1099.98px) {
    .login-shell, .reg-shell {
        flex-direction: column;
        min-height: 100vh;
    }
    .login-aside, .reg-aside {
        flex: 0 0 auto;
        border-radius: 0 0 28px 28px;
        padding: 28px 22px;
        text-align: center; align-items: center;
    }
    .login-aside h1, .reg-aside h1 { font-size: 25px; margin-bottom: 8px; }
    .login-aside p.lead, .reg-aside p.lead { font-size: 14px; margin-bottom: 0; }
    /* المزايا تظل ظاهرة (كانت تختفي) — عمودان على التابلت */
    .login-perks, .reg-perks {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px 18px;
        width: 100%; max-width: 620px;
        margin: 14px 0 0; text-align: right;
    }
    .login-perks li, .reg-perks li { margin-bottom: 0; font-size: 12.5px; gap: 8px; }
    .login-perks i, .reg-perks i { width: 24px; height: 24px; font-size: 11px; }
    .login-aside .mini-badge, .reg-aside .mini-badge { align-self: center; margin-bottom: 12px; }
    .login-logo, .reg-logo { width: 64px; height: 64px; border-radius: 20px; margin-bottom: 12px; }
    .login-form-wrap, .reg-form-wrap {
        flex: 0 0 auto; align-self: stretch;
        padding: 16px 14px 34px;
    }
}
@media (max-width: 575.98px) {
    .login-aside, .reg-aside { padding: 22px 16px 24px; }
    .login-aside h1, .reg-aside h1 { font-size: 22px; }
    .login-logo, .reg-logo { width: 58px; height: 58px; }
    .login-perks, .reg-perks { grid-template-columns: 1fr; }
    .login-card, .reg-card { border-radius: 16px; }
    .login-card .inner, .reg-card .inner { padding: 22px 18px; }
}

/* ---------- POS layout: everything fixed, only cart scrolls ---------- */#pos-tab { height: calc(100vh - 90px); overflow: hidden; }
#pos-tab .pos-layout { height: 100% !important; overflow: hidden; }
#pos-tab .cart-container { min-height: 0; overflow: hidden; }
#pos-tab .table-wrapper { min-height: 0; overflow-y: auto !important; overflow-x: hidden; }
#pos-tab .table-wrapper .table-responsive { overflow: visible !important; }
#pos-tab .table-wrapper table { min-width: 0 !important; width: 100% !important; }
#pos-tab #cart-items td { word-break: break-word; white-space: normal; }
#pos-tab .pos-side-card { overflow-y: auto; }
/* على الشاشات الأكبر: حساب ارتفاع الهيدر */
@media (min-width: 992px) {
    #pos-tab { height: calc(100vh - 88px) !important; }
    #pos-tab .pos-layout { height: 100% !important; }
}

/* Mobile POS: everything stacked but cart area scrolls only */
@media (max-width: 991.98px) {
    body, html { overflow-x: hidden; }
    #app-screen { height: auto !important; min-height: 100vh !important; overflow: visible !important; }
    #main-area { overflow-y: visible !important; height: auto !important; min-height: calc(100vh - 62px) !important; }
    .main-content { overflow-y: visible !important; height: auto !important; }
    /* المنتجات وغيرها: سكرول طبيعي */
    #products-tab, #purchases-tab, #invoices-tab, #reports-tab, #settings-tab,
    #inventory-logs-tab, #customers-tab, #hall-tab, #users-tab, #dashboard-tab {
        overflow: visible !important;
        height: auto !important;
    }
    /* شاشة البيع فقط: ثابتة بداخل إطار الشاشة */
    #pos-tab { height: calc(100vh - 62px) !important; overflow: hidden !important; padding: 0 !important; }    #pos-tab .pos-layout {
        height: 100% !important;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 6px 6px 0 !important;
    }
    #pos-tab .pos-layout > .col-xl-9,
    #pos-tab .pos-layout > .col-lg-8 {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        padding: 0 !important;
    }
    #pos-tab .cart-container { height: 100% !important; gap: 0; }
    #pos-tab .table-wrapper { flex: 1 1 auto !important; min-height: 120px; max-height: none; }
    #pos-tab .mb-3.d-flex.gap-2 { margin-bottom: 6px !important; }
    #pos-tab #barcode-input { height: 48px; font-size: 16px; }
    #pos-tab .mt-auto.pt-3 { padding: 8px !important; margin-top: 6px !important; }
    #pos-tab .mt-auto .mb-3 { margin-bottom: 6px !important; flex-wrap: nowrap; }
    #pos-tab .mt-auto #grand-total { font-size: 1.4rem; }
    #pos-tab .mt-auto .d-flex.gap-2 > button { padding: .5rem .6rem; }
    #pos-tab .mt-auto .btn-lg { font-size: 1rem !important; }
    /* side column becomes a collapsible strip, hidden by default on mobile */
    #pos-tab .pos-side-col { display: none !important; }
    #pos-tab .pos-side-col.mobile-show {
        display: block !important;
        position: fixed;
        left: 0; right: 0; bottom: 62px;
        top: auto;
        max-height: 55vh;
        z-index: 1050;
        background: #fff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -8px 24px rgba(0,0,0,.18);
        padding: 10px !important;
        margin: 0 !important;
        overflow-y: auto;
    }
    #pos-tab .pos-side-col.mobile-show .pos-side-card { height: auto !important; box-shadow: none !important; }
    #pos-tab .pos-side-col .mb-3 .row, #pos-tab .pos-side-col .row .col-4 { padding-inline: 3px; }
    /* mobile-only strip buttons */
    .pos-mobile-strip { display: flex !important; gap: 6px; margin: 6px 0 0; }
}
.pos-mobile-strip { display: none; }
.pos-mobile-strip button, .pos-mobile-strip a { flex: 1; font-size: 12px; padding: 8px 4px; border-radius: 10px; }

/* ---------- Tables: horizontal scroll (all screens) ---------- */
/* ================= 💬 كاشير برو — رسائل العملاء (شات حقيقي) ================= */
#messages-tab .inbox-shell { display: flex; height: calc(100vh - 150px); min-height: 520px; padding: 0; background: #fff; border: 1px solid #ece7e7; border-radius: 18px; overflow: hidden; }
#messages-tab .inbox-list-pane { width: 100%; flex: 1; background: #fff; display: flex; flex-direction: column; overflow: hidden; }
#messages-tab .inbox-chat-pane { position: relative; width: 100%; flex: 1; background: #fff; display: none; flex-direction: column; overflow: hidden; }
#messages-tab .inbox-shell.inbox-chat-mode .inbox-list-pane { display: none; }
#messages-tab .inbox-shell.inbox-chat-mode .inbox-chat-pane { display: flex; }
#messages-tab .inbox-list-head { padding: 16px 16px 8px; border-bottom: 1px solid #f0eeee; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#messages-tab .inbox-search { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fafafa; border-bottom: 1px solid #f0eeee; }
#messages-tab .inbox-search input { border: none; background: transparent; outline: none; width: 100%; font-size: 14px; color: #222; }
#messages-tab .inbox-search i { color: #9ca3af; }
#messages-tab .inbox-chips { display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; border-bottom: 1px solid #f0eeee; }
#messages-tab .chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid #e5e7eb; background: #fff; color: #374151; font-size: .78rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
#messages-tab .chip-active { color: #fff !important; }
#messages-tab .chip-ok { background: #22c55e; color: #fff; border-radius: 6px; padding: 1px 6px; font-size: .66rem; }
#messages-tab .chip-off { background: #e5e7eb; color: #6b7280; border-radius: 6px; padding: 1px 6px; font-size: .66rem; }
#messages-tab .inbox-items { flex: 1; overflow-y: auto; padding: 8px; }
#messages-tab .inbox-conv-item { width: 100%; text-align: right; border: none; background: transparent; padding: 10px; border-radius: 12px; cursor: pointer; }
#messages-tab .inbox-conv-item:hover { background: #fdf6f7; }
#messages-tab .inbox-conv-item-active { background: #fdf6f7; border: 1px solid #f3d1d7 !important; }
#messages-tab .inbox-conv-row { display: flex; align-items: center; gap: 10px; }
#messages-tab .inbox-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg,#800020,#a3123c); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
#messages-tab .inbox-avatar-sm { width: 38px; height: 38px; font-size: 14px; }
#messages-tab .inbox-conv-body { flex: 1; min-width: 0; }
#messages-tab .inbox-conv-name { font-weight: 800; color: #111827; font-size: .92rem; }
#messages-tab .inbox-conv-last { font-size: .78rem; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; }
#messages-tab .inbox-conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
#messages-tab .inbox-conv-time { font-size: .7rem; color: #9ca3af; }
#messages-tab .inbox-conv-debt { font-size: .75rem; color: #b91c1c; font-weight: 700; background: #fef2f2; padding: 2px 8px; border-radius: 6px; }
#messages-tab .inbox-chat-head { background: linear-gradient(135deg,#800020,#a3123c); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
#messages-tab .inbox-head-profile { display: flex; align-items: center; gap: 10px; background: transparent; border: none; color: inherit; text-align: inherit; cursor: pointer; border-radius: 14px; padding: 6px 8px; min-width: 0; flex: 1; }
#messages-tab .inbox-head-profile:hover { background: rgba(255,255,255,.14); }
#messages-tab .inbox-chat-head-info { min-width: 0; }
#messages-tab .inbox-back-btn { width: 38px; height: 38px; border-radius: 12px; border: none; background: rgba(255,255,255,.18); color: #fff; }
#messages-tab .inbox-back-btn:hover { background: rgba(255,255,255,.28); }
#messages-tab .inbox-chat-name { font-weight: 800; font-size: 1.02rem; }
#messages-tab .inbox-chat-sub { font-size: .75rem; opacity: .85; }
#messages-tab .inbox-head-actions { display: flex; gap: 6px; }
#messages-tab .inbox-head-actions .btn { background: rgba(255,255,255,.14); color: #fff; border: none; width: 38px; height: 38px; border-radius: 12px; }
#messages-tab .inbox-head-actions .btn:hover { background: rgba(255,255,255,.28); }
#messages-tab .inbox-msg-search-bar { background: #fafafa; padding: 8px 12px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #f0eeee; flex-shrink: 0; }
#messages-tab .inbox-msg-search-bar input { flex: 1; border: none; background: transparent; outline: none; font-size: .88rem; }
#messages-tab .inbox-thread { flex: 1; overflow-y: auto; padding: 16px; background: #fdfcfb; }
#messages-tab .inbox-bubble-row { display: flex; margin-bottom: 10px; }
#messages-tab .inbox-bubble-user { justify-content: flex-start; }
#messages-tab .inbox-bubble-assistant { justify-content: flex-end; }
#messages-tab .inbox-bubble { max-width: 70%; padding: 8px 12px 6px; border-radius: 16px; font-size: .88rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
#messages-tab .bubble-received { background: #edeef0; color: #111827; border-bottom-left-radius: 4px; }
#messages-tab .bubble-sent { background: #800020; color: #fff; border-bottom-right-radius: 4px; }
#messages-tab .inbox-bubble-time { font-size: .65rem; opacity: .65; margin-top: 4px; text-align: left; }
#messages-tab .inbox-bubble-loading { opacity: .75; }
#messages-tab .inbox-empty-state { text-align: center; padding: 60px 20px; color: #9ca3af; }
/* زر النزول لآخر رسالة — يظهر عند السكرول للأعلى */
#messages-tab .inbox-scroll-bottom { position: absolute; bottom: 78px; right: 20px; z-index: 20; width: 50px; height: 50px; border-radius: 50%; border: none; background: rgba(128, 0, 32, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: #fff; font-size: 1.15rem; cursor: pointer; box-shadow: 0 8px 20px rgba(128, 0, 32, .32), inset 0 0 0 1.5px rgba(255, 255, 255, .28); display: flex; align-items: center; justify-content: center; padding: 0; line-height: 1; transition: background .18s ease, transform .18s ease; animation: inboxPop .18s ease-out; }
#messages-tab .inbox-scroll-bottom:hover { background: rgba(128, 0, 32, .78); transform: scale(1.08); }
#messages-tab .inbox-scroll-bottom i { position: relative; top: 1px; }
@keyframes inboxPop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* مرفقات داخل الفقاعات */
#messages-tab .inbox-attach-img { max-width: 230px; max-height: 170px; border-radius: 12px; display: block; margin-top: 6px; object-fit: cover; }
#messages-tab .inbox-attach-video { max-width: 260px; max-height: 180px; border-radius: 12px; display: block; margin-top: 6px; }
#messages-tab .inbox-attach-file { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.16); text-decoration: none; color: inherit; }
#messages-tab .bubble-received .inbox-attach-file { background: rgba(0,0,0,.06); }
#messages-tab .inbox-attach-file i { font-size: 1.2rem; }
/* نافذة بروفايل العميل */
#messages-tab .inbox-profile-modal { position: fixed; inset: 0; z-index: 2100; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.5); padding: 16px; }
#messages-tab .inbox-profile-card { width: 100%; max-width: 430px; max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
#messages-tab .inbox-profile-head { position: relative; display: flex; align-items: center; gap: 14px; padding: 18px 18px 16px; background: linear-gradient(135deg,#800020,#a3123c); color: #fff; }
#messages-tab .inbox-profile-close { position: absolute; top: 8px; inset-inline-end: 8px; font-size: 1.15rem; text-decoration: none; }
#messages-tab .inbox-profile-avatar { width: 74px; height: 74px; border-radius: 50%; background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.45); display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 800; overflow: hidden; flex-shrink: 0; }
#messages-tab .inbox-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
#messages-tab .inbox-profile-name { font-weight: 800; font-size: 1.15rem; }
#messages-tab .inbox-profile-phone { opacity: .9; direction: ltr; text-align: start; font-size: .9rem; margin-top: 2px; }
#messages-tab .inbox-profile-blocked { display: inline-flex; align-items: center; gap: 5px; background: #7f1d1d; border: 1px solid #fecaca; border-radius: 6px; padding: 2px 8px; font-size: .72rem; font-weight: 700; margin-top: 6px; }
#messages-tab .inbox-profile-body { padding: 16px; }
#messages-tab .inbox-profile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
#messages-tab .inbox-profile-stat { background: #faf8f8; border: 1px solid #eee5e5; border-radius: 12px; text-align: center; padding: 8px 4px; }
#messages-tab .inbox-profile-stat-val { font-weight: 800; font-size: .95rem; }
#messages-tab .inbox-profile-stat-lbl { font-size: .62rem; color: #6b7280; margin-top: 2px; }
#messages-tab .inbox-profile-details { list-style: none; padding: 0; margin: 0 0 14px; }
#messages-tab .inbox-profile-details li { display: flex; align-items: center; gap: 8px; padding: 7px 4px; border-bottom: 1px dashed #eee; font-size: .85rem; color: #374151; }
#messages-tab .inbox-profile-details li:last-child { border-bottom: none; }
#messages-tab .inbox-profile-details b { color: #111827; font-weight: 700; }
#messages-tab .inbox-profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#messages-tab .inbox-profile-actions .btn { flex: 1; min-width: 110px; }
#messages-tab .inbox-chat-foot { display: none; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-top: 1px solid #ece7e7; flex-shrink: 0; }
#messages-tab .inbox-chat-foot input[type="text"] { flex: 1; height: 46px; border: 1px solid #e5e7eb; border-radius: 14px; padding: 0 14px; outline: none; font-size: .95rem; }
#messages-tab .inbox-chat-foot input:focus { border-color: #800020; }
#messages-tab .inbox-attach-btn { border: none; background: #f3f4f6; width: 46px; height: 46px; border-radius: 14px; }
#messages-tab .inbox-send-btn { border: none; background: #800020; width: 46px; height: 46px; border-radius: 14px; color: #fff; }
#messages-tab .inbox-send-btn:hover { background: #5a0026; }
@media (max-width: 991.98px) {
    #messages-tab .inbox-shell { height: auto; min-height: 0; border: none; background: transparent; border-radius: 0; }
    #messages-tab .inbox-list-pane,
    #messages-tab .inbox-chat-pane { border: 1px solid #ece7e7; border-radius: 16px; overflow: hidden; height: calc(100vh - 170px); min-height: 70vh; }
    #messages-tab .inbox-bubble { max-width: 88%; }
    #messages-tab .inbox-profile-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== صندوق الرسائل (Inbox) ===== */
.inbox-conv-item { background: #fff; border: 1px solid #eef2f5; border-radius: 12px; padding: 8px 10px; cursor: pointer; text-align: inherit; font-family: inherit; }
.inbox-conv-item:hover { background: #f9f5f3; border-color: #e5d5d5; }
.inbox-conv-item:focus-visible { outline: 2px solid #6B0F1A; outline-offset: 2px; }
.inbox-bubble-row { display: flex; margin-bottom: 8px; }
.inbox-bubble-row.inbox-user { justify-content: flex-start; }
.inbox-bubble-row.inbox-assistant { justify-content: flex-end; }
.inbox-bubble { max-width: 80%; padding: 8px 12px; border-radius: 14px; font-size: .88rem; white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.bubble-user { background: #e5e7eb; color: #111827; border-bottom-left-radius: 4px; }
.bubble-assistant { background: #800020; color: #fff; border-bottom-right-radius: 4px; }
@media (max-width: 768px) {
    .inbox-bubble { max-width: 92%; }
}

/* ===== طي لوحة الأكثر/الأقل مبيعاً — والشاشة تاخد كامل العرض ===== */
body.pos-side-hidden #pos-tab .pos-side-col { display: none !important; }
body.pos-side-hidden #pos-tab .pos-layout > .col-xl-9 { flex: 0 0 100% !important; max-width: 100% !important; }
.pos-side-expand { display: none; }
body.pos-side-hidden .pos-side-expand {
    display: inline-flex !important;
    position: fixed;
    left: 10px;
    right: auto;
    top: 45%;
    z-index: 1040;
    width: 38px;
    height: 78px;
    border: none;
    border-radius: 12px;
    background: #6B0F1A;
    color: #f3c969;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(107,15,26,.4);
}

.table-responsive {
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    scrollbar-width: thin;
}
.pos-side-expand:hover { background: #8a1230; }
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-thumb { background: #c7c7c7; border-radius: 8px; }
.table-responsive::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 8px; }
@media (max-width: 991.98px) {
    .table-responsive { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
    .table-responsive > table.table { min-width: 580px; }
    .tab-content { overflow-x: visible !important; }
    .card .table, .card-body .table { width: 100%; }
}
/* ---------- Font unification: IBM Plex Sans Arabic ONLY (exclude FontAwesome icons) ---------- */
body, h1, h2, h3, h4, h5, h6, p, label, a, span, div, strong, small, em, i, b, u, li, ol, ul, blockquote, input, button, textarea, select, table, th, td {
    font-family: 'IBM Plex Sans Arabic', sans-serif;
}
/* Keep FontAwesome icons working */
.fa, .fas, .far, .fab, .fal, .fad, .fa-solid, .fa-regular, .fa-brands, .fa-light, .fa-duotone, [class^="fa-"], [class*=" fa-"] {
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Brands', 'FontAwesome' !important;
}
