/* WASFA installed-app (standalone window) only. Linked with media="(display-mode: standalone)". */
html.pwa-boot .sidebar,html.pwa-boot .main-content{transition:none!important}
@media (max-width:1250px){
  .rxed-left{width:200px}
  .rxed-right{width:380px}
  .rxed-center{min-width:240px}
  .rxed-wrap{overflow-x:auto}
  .apix-prod-card{min-width:140px}
}
/* POS on narrow screens / phone app: the open cart drawer keeps a transform, which makes it the containing
   block of the position:fixed item-options popover (popover shifted right and clipped). Remove it while open. */
@media (max-width:900px){
  body.pos-cart-open .pos-cart{transform:none!important}
}

/* Login pages (doctor/clinic/seller/staff/driver/admin) on narrow screens: hide promo panel, form full width */
@media (max-width:760px){
  body > .left:not(:has(form)),body > .right:not(:has(form)){display:none}
  body > .left:has(form){width:100%;max-width:520px;margin:0 auto;flex:1 1 auto;padding:32px 24px}
  body > .right:has(form){width:100%;max-width:none;flex:1 1 auto;padding:32px 24px}
}

/* rxautofit: generic responsive helpers, installed app only (this file is linked with media="(display-mode: standalone)").
   The classes pwa-ts / pwa-fit are added by app.js only on narrow windows. */
table.pwa-ts{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
.pwa-fit{max-width:100%!important;min-width:0!important;box-sizing:border-box!important}
img,video,canvas{max-width:100%}
@media (max-width:700px){
  [style*="grid-template-columns:repeat("],[style*="grid-template-columns: repeat("]{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))!important}
  input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px}
  pre,code{white-space:pre-wrap;word-break:break-word}
}

/* rxwrxphone: doctor Write Rx product grid on phones / small windows (the page forces 4 columns with !important and has no phone rules).
   Selectors are more specific than the page's own #prodGrid rules so they win regardless of stylesheet order. */
@media (max-width:700px){
  #prodGrid.prod-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important}
  #prodGrid.prod-grid.brand-mode{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  #prodGrid.prod-grid.list-mode{grid-template-columns:minmax(0,1fr)!important}
  #prodGrid .mcard{padding:10px;min-width:0}
  #prodGrid .mc-pill{height:92px;margin-bottom:8px;padding:6px}
  #prodGrid .mc-name{font-size:13px;overflow-wrap:break-word}
  #prodGrid .mc-sub{font-size:11px;overflow-wrap:break-word}
  #prodGrid .mc-foot{flex-wrap:wrap;gap:6px}
  #prodGrid .mc-add,#prodGrid .mc-added{padding:6px 10px}
}
@media (min-width:701px) and (max-width:1000px){
  #prodGrid.prod-grid:not(.list-mode):not(.brand-mode){grid-template-columns:repeat(3,minmax(0,1fr))!important}
}

/* rxwrxlist: Write Rx LIST view in narrow windows. The row (pill | name | category | price+Add) gets a 2-line layout:
   pill on the left, name over category, price + Add on the right. */
@media (max-width:1000px){
  #prodGrid.prod-grid.list-mode{grid-template-columns:minmax(0,1fr)!important}
  #prodGrid.prod-grid.list-mode .mcard{display:grid;grid-template-columns:52px minmax(0,1fr) auto;grid-template-areas:"pill name foot" "pill sub foot";column-gap:10px;row-gap:2px;align-items:center;padding:10px 12px}
  #prodGrid.prod-grid.list-mode .mc-pill{grid-area:pill}
  #prodGrid.prod-grid.list-mode .mc-name{grid-area:name;font-size:13px}
  #prodGrid.prod-grid.list-mode .mc-sub{grid-area:sub;margin:0;min-height:0;font-size:11px}
  #prodGrid.prod-grid.list-mode .mc-foot{grid-area:foot;flex-direction:column;align-items:flex-end;gap:4px;padding-top:0;margin-top:0}
}

/* rxwrxtabs: doctor Write Rx page in narrow installed-app windows: Patient / Products / Rx tabs (same design as the admin Write Rx page).
   The tab bar and the data-pwa-tab attribute on .wrx are created by app.js only when the window is <= 1000px wide. */
.pwa-wtabs{display:grid;grid-template-columns:1fr 1fr 1fr;background:#fff;border-bottom:2px solid #e2e8f0;position:sticky;top:0;z-index:50}
.pwa-wtab{padding:11px 8px;font-size:.78rem;font-weight:700;color:#64748b;border:0;border-bottom:3px solid transparent;border-right:1px solid #f1f5f9;cursor:pointer;background:none;display:flex;align-items:center;justify-content:center;gap:5px;font-family:inherit}
.pwa-wtab:last-child{border-right:none}
.pwa-wtab.active{color:#4f46e5;border-bottom-color:#6366f1;background:#eef2ff}
.pwa-wtab .badge{background:#f97316;color:#fff;border-radius:10px;padding:1px 6px;font-size:9px}
.wrx[data-pwa-tab]{flex-direction:column!important;height:auto!important;min-height:calc(100vh - 100px);overflow:visible!important}
.wrx[data-pwa-tab] .wrx-left,.wrx[data-pwa-tab] .wrx-body{width:100%!important;min-width:0!important;flex:1 1 auto!important;border:0!important;box-shadow:none!important}
.wrx[data-pwa-tab] .wrx-left,.wrx[data-pwa-tab] .wrx-body{display:none!important}
.wrx[data-pwa-tab] .wrx-resizer{display:none!important}
.wrx[data-pwa-tab] .wrx-centre,.wrx[data-pwa-tab] .wrx-right{display:none!important;width:100%!important;min-width:0!important;flex:1 1 auto!important;border:0!important;box-shadow:none!important}
.wrx[data-pwa-tab="patient"] .wrx-left{display:block!important}
.wrx[data-pwa-tab="products"] .wrx-body,.wrx[data-pwa-tab="rx"] .wrx-body{display:flex!important}
.wrx[data-pwa-tab="products"] .wrx-centre,.wrx[data-pwa-tab="rx"] .wrx-right{display:flex!important}

/* rxdocpres: doctor My Prescriptions table in narrow installed-app windows: keep a readable width and scroll sideways inside the card
   (the page uses a fixed layout with percentage columns inside an overflow:hidden card, so the columns collided). */
@media (max-width:1100px){
  .rx-card{overflow-x:auto!important;-webkit-overflow-scrolling:touch}
  table.rxt{min-width:960px}
  table.rxt th,table.rxt td{padding-left:10px;padding-right:10px}
}

/* rxdocsales: doctor My Sales filter form in narrow installed-app windows (<=720px): 2 columns instead of 4,
   so the date, filter and RX ID boxes keep a usable width. KPI cards go 2 per row only on phone widths. */
@media (max-width:720px){
  form.filt .row{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  form.filt .row>div{min-width:0}
  form.filt .row>div[style*="span 3"]{grid-column:1/-1!important}
  form.filt .row>div[style*="align-items:end"]{grid-column:1/-1}
  form.filt input,form.filt select{min-width:0;box-sizing:border-box}
}
@media (max-width:480px){
  .kpi-row{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}
