/* ============================================================================
   TMK WMS V2 — TABLET / IPAD LAYOUT CSS (STRICTLY 744px – 1023.98px)
   Loaded via media="(min-width: 744px) and (max-width: 1023.98px)"
   Covers iPad Mini (744px), iPad 9/10/11 (768–820px), iPad Air 11" (820px),
   iPad Pro 11" Portrait (834px), Android Tablets, & Large Phones in Landscape.
   ZERO overlap with Mobile (<= 743.98px) or PC (>= 1024px). ZERO !important.
   ============================================================================ */

.app-shell {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  transition: grid-template-columns var(--dur-base) var(--ease-out);
}

.app-shell--sidebar-expanded {
  grid-template-columns: 236px minmax(0, 1fr);
}

.mobile-bottom-nav,
.mobile-menu-trigger {
  display: none;
}

/* Collapsible Touch-Friendly Icon Rail Sidebar */
.desktop-sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: var(--z-sidebar);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: max(var(--sp-3), env(safe-area-inset-top, 12px)) var(--sp-2) max(var(--sp-3), env(safe-area-inset-bottom, 12px));
  gap: var(--sp-3);
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.app-shell--sidebar-expanded .sidebar-header {
  justify-content: space-between;
  padding: 0 var(--sp-2);
}

.app-shell:not(.app-shell--sidebar-expanded) .brand-text,
.app-shell:not(.app-shell--sidebar-expanded) .sidebar-nav-label,
.app-shell:not(.app-shell--sidebar-expanded) .sidebar-section-title,
.app-shell:not(.app-shell--sidebar-expanded) .sidebar-footer-text,
.app-shell:not(.app-shell--sidebar-expanded) .sidebar-dept-box {
  display: none;
}

.sidebar-nav {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sidebar-nav-btn {
  position: relative;
  width: 100%;
  min-height: 46px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.app-shell--sidebar-expanded .sidebar-nav-btn {
  justify-content: flex-start;
}

.sidebar-nav-btn--active {
  background-color: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.sidebar-nav-badge {
  margin-left: auto;
}

.app-shell:not(.app-shell--sidebar-expanded) .sidebar-nav-badge {
  position: absolute;
  top: 4px;
  right: 6px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Right Content Column */
.workspace-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  height: calc(58px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) var(--sp-4) 0;
  background-color: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.topbar-search-trigger {
  min-height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
}

.topbar-search-kbd,
.topbar-user-meta {
  display: none;
}

.main-content {
  flex: 1 1 auto;
  padding: var(--sp-4) var(--sp-5);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* iPad / Tablet Adaptive Grids */
.kpi-grid,
.workflow-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid--2,
.two-col-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}

.form-grid--3 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
}

.photo-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* iPad Mini (744–819px): 2 spacious product columns so buttons & steppers never crush */
.store-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

.floating-cart-bar {
  left: 94px;
  right: var(--sp-5);
  bottom: max(var(--sp-4), env(safe-area-inset-bottom, 16px));
  width: auto;
}

.app-shell--sidebar-expanded .floating-cart-bar {
  left: 256px;
}

.has-floating-cart {
  padding-bottom: 88px;
}

.desktop-cart-col {
  display: none;
}

.toast-stack {
  right: var(--sp-5);
  bottom: var(--sp-5);
}

/* iPad Air (820px) & iPad Pro 11" Portrait (834px+) */
@media (min-width: 820px) {
  .store-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .app-shell--sidebar-expanded .store-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .kpi-grid,
  .workflow-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Hybrid Touch Comfort for ALL iPads & Android Tablets */
@media (pointer: coarse) {
  .btn,
  .input,
  .select,
  .tab-btn,
  .cat-chip,
  .sidebar-nav-btn {
    min-height: 46px;
  }

  .qty-stepper-btn {
    height: 42px;
  }
}

/* Rotated Large Phones in Landscape (e.g., iPhone 15/16 Pro Max 844-932 x 390-430) */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar {
    height: 48px;
  }

  .main-content {
    padding: var(--sp-3) var(--sp-4);
  }

  .floating-cart-bar {
    bottom: 10px;
    padding: 9px 14px;
  }
}
