/*
 * Hesaby ERP original POS visual contract, batch 5 — 2026-11-18.
 * Grounded in the user-supplied archived sources:
 *   ERPSYSTEM/modules/pos/views/pos_window.py (tile 132x170, image 84px)
 *   ERPSYSTEM/modules/pos/views/pos_window_ui_mixin.py::init_ui
 *       (search row 44px, secondary toolbar 54px, category row 46px,
 *        400-430px cart, 48px cart title, 38px product search,
 *        26px product price badge, 40px total, 44px save buttons).
 * This modifies presentation only, without changing order-mode or
 * financial operation availability, API requests, roles, or stored data.
 * Scope: tenant Qt POS window; never Master Owner.
 */

/* Qt main POS has zero content margins and zero gap between its 2:1 panels.
   The cart is bounded to a constant width even on wide desktops. */
body.qt-desktop-mode #body-content:has(.qt-pos-window){
 padding:0;background:#fff;min-width:0;min-height:0;
}
body.qt-desktop-mode #body-content .qt-pos-window{
 box-sizing:border-box;min-width:0;min-height:0;
 background:#fff;border:0;border-radius:0;box-shadow:none;
 font-family:"Segoe UI",Tahoma,Arial,sans-serif;
}
@media (min-width:1101px){
 body.qt-desktop-mode #body-content .qt-pos-workspace{
  display:grid;grid-template-columns:minmax(0,1fr) minmax(400px,430px);
  direction:rtl;gap:0;align-items:stretch;min-width:0;min-height:0
 }
 body.qt-desktop-mode #body-content .qt-pos-cart{
  box-sizing:border-box;min-width:400px;max-width:430px;width:100%;
 }
}
body.qt-desktop-mode #body-content .qt-pos-catalog{
 min-width:0;min-height:0;background:#fff;border-inline-end:1px solid #d1d1d6;
}

/* Qt posProductSearchBar (order row), 44px, and posSecondaryFilterFrame,
   54px. In the cloud, order controls remain visibly disabled until
   backend workflows exist; this stylesheet does not activate them. */
body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-order-modes{
 box-sizing:border-box;display:flex;flex:0 0 44px;
 height:44px;min-height:44px;max-height:44px;
 direction:rtl;align-items:center;flex-wrap:nowrap;
 gap:7px;margin:0;padding:2px 4px;overflow-x:auto;overflow-y:hidden;
 border:1px solid #d8e1eb;border-radius:8px;
 background:#f7f9fc;scrollbar-width:thin;
}
body.qt-desktop-mode #body-content .qt-pos-order-modes>strong{
 flex:0 0 64px;min-width:64px;margin-inline-end:0;
 text-align:center;white-space:nowrap;color:#102844;
 font:800 12px "Segoe UI",Tahoma,Arial,sans-serif;
}
body.qt-desktop-mode #body-content .qt-pos-order-modes>.qt-pos-tool{
 box-sizing:border-box;flex:0 0 auto;
 min-height:36px;max-height:36px;height:36px;
 border-radius:7px;white-space:nowrap;font-weight:800;
}
body.qt-desktop-mode #body-content .qt-pos-order-modes>.qt-pos-tool:nth-of-type(1){
 width:72px;min-width:72px;max-width:72px
}
body.qt-desktop-mode #body-content .qt-pos-order-modes>.qt-pos-tool:nth-of-type(2){
 width:84px;min-width:84px;max-width:84px
}
body.qt-desktop-mode #body-content .qt-pos-order-modes>.qt-pos-tool:nth-of-type(3){
 width:76px;min-width:76px;max-width:76px
}
body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-tools{
 box-sizing:border-box;display:flex;direction:rtl;justify-content:flex-start;
 align-items:center;flex:0 0 54px;height:54px;min-height:54px;max-height:54px;
 gap:3px;margin:0;padding:6px 8px;flex-wrap:nowrap;
 border:1px solid #d8e1eb;border-radius:8px;
 background:#f7f9fc;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin
}
body.qt-desktop-mode #body-content .qt-pos-tools>.qt-pos-tool{
 box-sizing:border-box;flex:0 0 auto;
 height:34px;min-height:34px;max-height:34px;
 padding:4px 10px;white-space:nowrap;border-radius:6px;
 font:700 11px "Segoe UI",Tahoma,Arial,sans-serif;
}
body.qt-desktop-mode #body-content .qt-pos-tools>.qt-pos-tool:nth-child(1){
 min-width:82px
}
body.qt-desktop-mode #body-content .qt-pos-tools>.qt-pos-tool:nth-child(2){
 min-width:58px
}
body.qt-desktop-mode #body-content .qt-pos-tools>.qt-pos-tool:nth-child(3),
body.qt-desktop-mode #body-content .qt-pos-tools>.qt-pos-tool:nth-child(4){
 min-width:82px
}
body.qt-desktop-mode #body-content .qt-pos-tools>.qt-pos-tool:disabled{
 opacity:.65;background:#edf0f4;color:#8793a3;cursor:not-allowed
}

/* Original posCategoryRowFrame: 46px frame, inner scroll viewport 38px,
   32px buttons with 58px min-width for "الكل", 86px for categories,
   three-pixel gap. Logical categories remain RTL/right-aligned and scroll
   horizontally; category queries are server-paged, never browser page-only. */
body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-category-frame{
 box-sizing:border-box;display:flex;align-items:center;flex:0 0 46px;
 height:46px;min-height:46px;max-height:46px;
 min-width:0;padding:4px 6px;direction:rtl;
 border:1px solid #d8e1eb;border-radius:8px;background:#f7f9fc;
}
body.qt-desktop-mode #body-content .qt-pos-category-frame>.qt-pos-category-scroll{
 box-sizing:border-box;display:flex;flex:1 1 auto;direction:rtl;
 align-items:center;justify-content:flex-start;gap:3px;
 height:38px;min-height:38px;max-height:38px;min-width:0;
 overflow-x:auto;overflow-y:hidden;
 padding:2px;scrollbar-width:thin;
}
body.qt-desktop-mode #body-content .qt-pos-category-scroll::-webkit-scrollbar{
 height:6px;background:#f0f0f0;border-radius:3px;
}
body.qt-desktop-mode #body-content .qt-pos-category-scroll::-webkit-scrollbar-thumb{
 background:#bdbdbd;border-radius:3px;min-width:30px;
}
body.qt-desktop-mode #body-content .qt-pos-category-pill{
 box-sizing:border-box;flex:0 0 auto;cursor:pointer;
 height:32px;min-height:32px;max-height:32px;
 min-width:86px;padding:0 16px;margin:0;
 color:#102844;background:#fff;
 border:1px solid #d1d1d6;border-radius:8px;
 font:700 13px "Segoe UI",Tahoma,Arial,sans-serif;
 white-space:nowrap;outline-offset:2px;
}
body.qt-desktop-mode #body-content .qt-pos-category-pill:first-child{min-width:58px}
body.qt-desktop-mode #body-content .qt-pos-category-pill.is-active{
 color:#fff;background:#06224a;border-color:#061f3e;
}
body.qt-desktop-mode #body-content .qt-pos-category-pill:hover:not(:disabled):not(.is-active){
 background:#e8f0f7;border-color:#244875
}
body.qt-desktop-mode #body-content .qt-pos-category-pill:focus-visible{
 outline:2px solid #244875
}
body.qt-desktop-mode #body-content .qt-pos-category-pill:disabled{
 opacity:.65;cursor:not-allowed
}
body.qt-desktop-mode #body-content .qt-pos-category-context{
 position:absolute;width:1px;height:1px;overflow:hidden;
 padding:0;margin:-1px;border:0;clip-path:inset(50%);
}
body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-catalog-heading[hidden]{
 display:none!important;
}
body.qt-desktop-mode #body-content .qt-pos-products-grid,
body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-products-grid{
 flex:1;min-height:0;align-content:start;
 grid-template-columns:repeat(auto-fill,132px);
 grid-auto-rows:170px;gap:5px;padding:4px;
 justify-content:start;direction:rtl;
 background:#fafafa;border:1px solid #d1d1d6;
 overflow-y:auto;overflow-x:hidden;scrollbar-width:thin
}

/* Source tile spacing: 7/3/7/5, centered product name (22px),
   106x84 photo placeholder and 26px price/stock footer. */
body.qt-desktop-mode #body-content .qt-pos-products-grid>.qt-pos-product-tile{
 box-sizing:border-box;display:flex;flex-direction:column;
 width:132px;min-width:132px;max-width:132px;
 height:170px;min-height:170px;max-height:170px;
 gap:3px;margin:0;padding:3px 7px 5px;
 background:#fff;border:1px solid #e3e8ef;border-radius:12px;
 color:#102844;overflow:hidden;text-align:center;justify-content:flex-start;
}
body.qt-desktop-mode #body-content .qt-pos-product-tile .qt-pos-product-name{
 box-sizing:border-box;display:block;flex:0 0 22px;height:22px;
 min-height:22px;max-height:22px;
 font:800 12px/22px "Segoe UI",Tahoma,Arial,sans-serif;
 color:#0f2342;direction:rtl;text-align:center;
 white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
body.qt-desktop-mode #body-content .qt-pos-product-tile .qt-pos-product-visual{
 box-sizing:border-box;display:flex;justify-content:center;align-items:center;
 flex:0 0 84px;width:106px;min-width:106px;max-width:106px;
 height:84px;min-height:84px;max-height:84px;
 align-self:center;background:#f6f8fb;border:1px solid #e0e7f0;
 border-radius:10px;color:#8a98aa;font:800 16px "Segoe UI",Tahoma,Arial,sans-serif;
}
body.qt-desktop-mode #body-content .qt-pos-product-tile .qt-pos-product-footer{
 box-sizing:border-box;display:flex;align-items:center;
 flex:0 0 26px;height:26px;min-height:26px;max-height:26px;
 margin-top:auto;gap:7px;flex-wrap:nowrap;min-width:0
}
body.qt-desktop-mode #body-content .qt-pos-product-tile .qt-pos-product-price{
 box-sizing:border-box;display:flex;align-items:center;justify-content:center;
 min-width:0;flex:1 1 0;height:26px;min-height:26px;max-height:26px;
 padding:0 3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
 background:#06224a;color:#fff;border:0;border-radius:7px;
 font:700 11px "Segoe UI",Tahoma,Arial,sans-serif;
}
body.qt-desktop-mode #body-content .qt-pos-product-tile .qt-pos-product-service{
 box-sizing:border-box;display:flex;align-items:center;justify-content:center;
 height:26px;min-height:26px;max-height:26px;
 min-width:0;max-width:45%;padding:0 3px;white-space:nowrap;
 font:700 10px "Segoe UI",Tahoma,Arial,sans-serif;
}

/* The Qt cart title is fixed 48px, with 38px product search.
   The lower invoice form remains in the cart, so native validation is kept. */
body.qt-desktop-mode #body-content .qt-pos-cart>.qt-pos-form>.qt-pos-cart-header{
 box-sizing:border-box;display:flex;align-items:center;flex-wrap:nowrap;
 height:48px;min-height:48px;max-height:48px;
 padding:4px 5px;gap:6px;direction:rtl;
 background:#061f3e;border:1px solid #102844;border-radius:10px;
 color:#fff;
}
body.qt-desktop-mode #body-content .qt-pos-cart-header .qt-pos-cart-search input{
 box-sizing:border-box;height:38px;min-height:38px;max-height:38px;
 min-width:90px;max-width:250px;
 padding:0 8px;border:1px solid #d1d1d6;border-radius:8px;
 background:#fff;color:#102844;
 font:700 12px "Segoe UI",Tahoma,Arial,sans-serif
}
/* Original cart totals minimum 40px; native submit/save+print 44px.
   Retain disabled temporary-save and authorization state. */
body.qt-desktop-mode #body-content .qt-pos-cart .qt-pos-form>.toolbar{
 box-sizing:border-box;min-height:40px;gap:8px;padding:5px 10px;
 align-items:center;background:#fff;border-top:1px solid #d8e1eb
}
body.qt-desktop-mode #body-content .qt-pos-cart .qt-pos-native-total{
 display:flex;align-items:center;justify-content:center;
 box-sizing:border-box;min-height:40px;
 padding:5px 8px;background:#244875;color:#fff;
 border:0;border-radius:6px;font:800 15px "Segoe UI",Tahoma,Arial,sans-serif;
}
body.qt-desktop-mode #body-content .qt-pos-cart .qt-pos-actions{
 box-sizing:border-box;display:flex;align-items:center;gap:8px;
 min-height:62px;padding:4px 10px 10px;flex-wrap:wrap;
 background:#fff;direction:rtl;
}
body.qt-desktop-mode #body-content .qt-pos-cart .qt-pos-actions>.button.primary{
 box-sizing:border-box;display:flex;align-items:center;justify-content:center;
 flex:1 1 auto;height:44px;min-height:44px;max-height:44px;
 padding:6px 10px;border-radius:6px;white-space:nowrap
}
body.qt-desktop-mode #body-content .qt-pos-cart .qt-pos-actions>.button[aria-label="إفراغ السلة وإلغاء مسودة البيع الحالية"]{
 box-sizing:border-box;min-width:105px;min-height:40px;height:40px;
 padding:5px 10px;border-radius:6px;flex:0 0 auto;
}
body.qt-desktop-mode #body-content .qt-pos-cart .qt-pos-actions>.qt-pos-tool{
 min-height:44px;height:44px;flex:0 0 auto;
}

/* Original "ملاحظات" area in POS is a compact multi-line edit (38-46px).
   Keep the extra Cloud tender/cash/warehouse fields visible and editable. */
body.qt-desktop-mode #body-content .qt-pos-cart .qt-pos-form>.form-grid textarea{
 box-sizing:border-box;min-height:38px;max-height:82px;
 resize:vertical;border:1px solid #d1d1d6;border-radius:6px;
 font:500 11px "Segoe UI",Tahoma,Arial,sans-serif;
}
@media(max-width:1100px){
 body.qt-desktop-mode #body-content .qt-pos-workspace{
  grid-template-columns:minmax(0,1fr);overflow:auto
 }
 body.qt-desktop-mode #body-content .qt-pos-cart{
  width:100%;max-width:none;min-width:0;
 }
}
@media(max-width:700px){
 body.qt-desktop-mode #body-content .qt-pos-products-grid{
  grid-template-columns:repeat(auto-fill,132px);
  justify-content:center;
 }
 body.qt-desktop-mode #body-content .qt-pos-cart>.qt-pos-form>.qt-pos-cart-header{
  height:auto;max-height:none;flex-wrap:wrap
 }
 body.qt-desktop-mode #body-content .qt-pos-tools,
 body.qt-desktop-mode #body-content .qt-pos-order-modes{
  overflow-x:auto
 }
}

/* Qt POSWindow._product_grid_columns() dynamically fits 132px tiles with a
 * 5px gap and 4px inner margins, but NEVER exceeds PRODUCT_GRID_COLUMNS=6.
 * Previous CSS auto-fill had no maximum and added 7+ columns on wide displays.
 * The CSS grid has 2px border + 8px horizontal padding, so threshold for
 * N columns is N*132 + (N-1)*5 + 10 = 137*N + 5.
 * Scoped to the desktop tenant POS: smaller viewport / mobile layout is left
 * unchanged. CSS container queries bind to the actual catalog width, not
 * the entire window (which also contains the sidebar and checkout cart).
 */
@media (min-width:1101px){
 body.qt-desktop-mode #body-content .qt-pos-catalog{
  container-name:qt-pos-catalog;
  container-type:inline-size;
 }
 body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-products-grid{
  grid-template-columns:132px;
 }
}
@container qt-pos-catalog (min-width:279px) and (max-width:415px){
 body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-products-grid{
  grid-template-columns:repeat(2,132px);
 }
}
@container qt-pos-catalog (min-width:416px) and (max-width:552px){
 body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-products-grid{
  grid-template-columns:repeat(3,132px);
 }
}
@container qt-pos-catalog (min-width:553px) and (max-width:689px){
 body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-products-grid{
  grid-template-columns:repeat(4,132px);
 }
}
@container qt-pos-catalog (min-width:690px) and (max-width:826px){
 body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-products-grid{
  grid-template-columns:repeat(5,132px);
 }
}
@container qt-pos-catalog (min-width:827px){
 body.qt-desktop-mode #body-content .qt-pos-catalog>.qt-pos-products-grid{
  grid-template-columns:repeat(6,132px);
 }
}
