/* =====================================================
   MOBILE RESPONSIVE STYLES
   Breakpoints: mobile < 768px | tablet 768–1023px | desktop 1024px+
   ===================================================== */

/* ── Sidebar Drawer (mobile overlay) ─────────────────── */
#app-sidebar {
  transition: transform 0.3s ease, width 0.3s ease, box-shadow 0.3s ease;
}

@media (max-width: 1023px) {
  #app-sidebar {
    transform: translateX(-100%);
    width: 280px !important;
    z-index: 50 !important;
  }
  #app-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.55);
  }
  #app-shell-content {
    margin-left: 0 !important;
  }
}

/* ── Mobile Backdrop ──────────────────────────────────── */
#mobile-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 49;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Header responsive ────────────────────────────────── */
@media (max-width: 767px) {
  #global-search-wrapper {
    display: none !important;
  }
  .header-org-name {
    display: none !important;
  }
  .header-org-chevron {
    display: none !important;
  }
  .header-page-desc {
    display: none !important;
  }
}

/* ── Generic table → card pattern ────────────────────── */
@media (max-width: 767px) {
  .mobile-table-wrapper {
    display: none;
  }
  .mobile-card-list {
    display: block;
  }
}
@media (min-width: 768px) {
  .mobile-table-wrapper {
    display: block;
  }
  .mobile-card-list {
    display: none;
  }
}

/* ── Card list item styles ────────────────────────────── */
.mobile-card {
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid hsl(var(--border) / 0.5);
  background: hsl(var(--card));
}
.mobile-card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
}
.mobile-card-label {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  min-width: 80px;
}
.mobile-card-value {
  color: hsl(var(--foreground));
  text-align: right;
  word-break: break-word;
}
.mobile-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid hsl(var(--border) / 0.3);
  flex-wrap: wrap;
}

/* ── Touch-friendly tap targets ──────────────────────── */
@media (max-width: 1023px) {
  .nav-item {
    min-height: 44px;
  }
  button, a[href], [role="button"] {
    -webkit-tap-highlight-color: transparent;
  }
}

/* ── Overflow helpers ─────────────────────────────────── */
@media (max-width: 767px) {
  .mobile-scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Prevent modal overflow on small screens */
  .modal-scroll {
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Form responsive stacking ─────────────────────────── */
@media (max-width: 639px) {
  .form-grid-2 {
    grid-template-columns: 1fr !important;
  }
  .form-grid-3 {
    grid-template-columns: 1fr !important;
  }
}

/* ── POS layout ───────────────────────────────────────── */
@media (max-width: 1023px) {
  #pos-layout {
    flex-direction: column !important;
  }
  #pos-product-panel {
    width: 100% !important;
    flex-shrink: unset !important;
  }
  #pos-cart-panel {
    width: 100% !important;
    flex-shrink: unset !important;
    max-height: 50vh;
  }
}

/* ── Purchase Order 3-panel layout ───────────────────── */
@media (max-width: 1023px) {
  #po-layout {
    flex-direction: column !important;
  }
  #po-left-panel,
  #po-right-panel {
    width: 100% !important;
    flex-shrink: unset !important;
  }
}

/* ── Employee / Rental detail panel ──────────────────── */
@media (max-width: 1023px) {
  .detail-sidebar {
    width: 100% !important;
    flex-shrink: unset !important;
    position: static !important;
  }
  .detail-layout {
    flex-direction: column !important;
  }
}

/* ── Payroll filter inputs ────────────────────────────── */
@media (max-width: 767px) {
  .payroll-filter-row {
    flex-direction: column !important;
  }
  .payroll-filter-row input,
  .payroll-filter-row select {
    width: 100% !important;
  }
}

/* ── Modals on mobile ─────────────────────────────────── */
@media (max-width: 639px) {
  [class*="max-w-"][class*="rounded-lg"],
  [class*="max-w-"][class*="rounded-xl"],
  [class*="max-w-"][class*="rounded-2xl"] {
    margin-left: 0.75rem;
    margin-right: 0.75rem;
    max-width: calc(100vw - 1.5rem) !important;
  }
}

/* ── Scrollbar (mobile) ───────────────────────────────── */
@media (max-width: 767px) {
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
}
