/* MOB365 V28 — final responsive safety layer.
   Keeps operational controls visible on short laptops and allows every suite
   to reflow instead of being clipped at fixed desktop dimensions. */

html, body { max-width: 100%; }

.m3-shell,
.cafe-pos-shell,
.ops-shell,
.pos-app-shell { width: 100%; max-width: 100vw; min-width: 0; }

.m3-shell *,
.cafe-pos-shell *,
.ops-shell *,
.pos-app-shell * { min-width: 0; box-sizing: border-box; }

/* Toolbars stay usable without making the entire page wider than the screen. */
.m3-top,
.cafe-commandbar,
.ops-topbar { max-width: 100%; }

.m3-actions,
.cafe-command-status,
.ops-top-actions {
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

/* Operations suites: desktop first, then 2-column and single-column reflow. */
.pharmacy-workspace,
.warehouse-workspace { min-width: 0; }

.pharmacy-workspace > *,
.warehouse-workspace > * { min-width: 0; }

@media (max-width: 1280px) {
  .pharmacy-v2 .pharmacy-workspace {
    grid-template-columns: minmax(330px, .9fr) minmax(430px, 1.1fr) !important;
    height: auto !important;
    overflow: visible !important;
  }
  .pharmacy-v2 .pharmacy-workspace > :last-child { grid-column: 1 / -1; }

  .warehouse-v2 .warehouse-workspace {
    grid-template-columns: minmax(270px, .72fr) minmax(480px, 1.28fr) !important;
    height: auto !important;
    overflow: visible !important;
  }
  .warehouse-v2 .warehouse-workspace > :last-child { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  html, body { overflow-x: hidden !important; overflow-y: auto !important; }

  .m3-top,
  .cafe-commandbar,
  .ops-topbar { flex-wrap: wrap !important; height: auto !important; }

  .m3-actions,
  .cafe-command-status,
  .ops-top-actions { width: 100%; justify-content: flex-start !important; }

  .pharmacy-v2 .pharmacy-workspace,
  .warehouse-v2 .warehouse-workspace {
    grid-template-columns: minmax(0, 1fr) !important;
    height: auto !important;
    overflow: visible !important;
  }

  .pharmacy-v2 .pharmacy-workspace > *,
  .warehouse-v2 .warehouse-workspace > * { grid-column: 1 !important; min-height: 360px; }

  .ops-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .warehouse-purpose { margin-inline: 8px !important; }
}

@media (max-width: 620px) {
  .ops-kpis { grid-template-columns: minmax(0, 1fr) !important; }
  .ops-top-actions .ops-btn,
  .m3-actions .m3-btn,
  .cafe-command-status .cafe-command-btn { min-height: 42px; }
}

/* Retail: preserve the full desktop POS, then reflow without horizontal loss. */
@media (max-width: 1180px) {
  .pos-app-shell .pos-layout.pos-layout-premium {
    grid-template-columns: 86px minmax(360px, 1fr) minmax(300px, .82fr) !important;
  }
  .pos-app-shell .pos-quick-actions { display: none !important; }
}

@media (max-width: 820px) {
  .pos-app-shell { height: auto !important; min-height: 100dvh; overflow: visible !important; }
  .pos-app-shell .pos-layout.pos-layout-premium {
    grid-template-columns: minmax(0, 1fr) !important;
    height: auto !important;
    overflow: visible !important;
  }
  .pos-app-shell .pos-sidebar { display: none !important; }
  .pos-app-shell .pos-products,
  .pos-app-shell .pos-cart { width: 100% !important; min-height: 520px !important; }
  .pos-system-strip { position: static !important; flex-wrap: wrap; }
}

/* Cafe: keep controls/table status visible on laptop heights. */
@media (min-width: 1101px) and (max-height: 850px) {
  .cafe-pos-shell { height: 100dvh !important; overflow: hidden !important; }
  .cafe-commandbar { min-height: 62px !important; padding-block: 6px !important; }
  .cafe-pos-grid { min-height: 0 !important; height: auto !important; overflow: hidden !important; }
  .cafe-panel { min-height: 0 !important; }
  .cafe-floor-map { min-height: 0 !important; overflow: auto !important; }
}

@media (max-width: 1100px) {
  .cafe-pos-shell { height: auto !important; min-height: 100dvh; overflow: visible !important; }
  .cafe-pos-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    height: auto !important;
    overflow: visible !important;
  }
  .cafe-tables-panel { grid-column: 1 / -1; min-height: 620px; }
  .cafe-order-panel { min-height: 560px; }
}

@media (max-width: 760px) {
  .cafe-pos-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .cafe-pos-grid > * { grid-column: 1 !important; }
  .cafe-tables-panel { min-height: 600px; }
}

/* Short screen density: reduce decorative spacing, never operational controls. */
@media (min-width: 901px) and (max-height: 760px) {
  .ops-kpis article { padding-block: 8px !important; }
  .warehouse-purpose { margin-block: 5px 7px !important; padding-block: 8px !important; }
  .warehouse-flow-nav { margin-block: 5px 7px !important; }
}
