/* ==========================================================================
   ApexPOS - Mobile-First & Real Native App Experience
   Breakpoints, Sticky Filters, Bottom Sheet & Native Mobile Bottom Bar
   ========================================================================== */

/* Prevent mobile horizontal shift & optimize tap actions */
html, body {
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* --------------------------------------------------------------------------
   Native Mobile Bottom Navigation Bar
   (Visible on mobile/tablet < 992px, fixed at the bottom of the screen)
   -------------------------------------------------------------------------- */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #ffffff;
  border-top: 1px solid var(--pos-border);
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.05);
  z-index: 1030;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0;
  color: var(--pos-text-muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  gap: 0.2rem;
  transition: all 0.15s ease;
  user-select: none;
}

.mobile-nav-item i {
  font-size: 1.25rem;
  line-height: 1;
}

.mobile-nav-item:hover,
.mobile-nav-item:focus {
  color: var(--pos-primary);
}

.mobile-nav-item.active {
  color: var(--pos-primary);
}

.mobile-nav-item.active i {
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Mobile Floating Cart Summary Bar
   (Floats above the bottom nav when items are added to cart)
   -------------------------------------------------------------------------- */
.mobile-cart-bottom-bar {
  display: none;
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  left: 0.85rem;
  right: 0.85rem;
  background: var(--pos-surface-dark);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.35), 0 4px 10px -2px rgba(15, 23, 42, 0.2);
  z-index: 1035;
  align-items: center;
  justify-content: space-between;
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.mobile-cart-bottom-bar.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.mobile-cart-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-cart-icon-badge {
  position: relative;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.mobile-cart-icon-badge .badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--pos-danger);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--pos-surface-dark);
}

.mobile-cart-pricing {
  display: flex;
  flex-direction: column;
}

.mobile-cart-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mobile-cart-total {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}

.btn-open-mobile-cart {
  background: var(--pos-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  transition: transform 0.1s ease, background 0.15s ease;
}

.btn-open-mobile-cart:active {
  transform: scale(0.96);
  background: var(--pos-primary-hover);
}

/* --------------------------------------------------------------------------
   Mobile Cart Bottom Sheet (Offcanvas Bottom Drawer)
   -------------------------------------------------------------------------- */
.mobile-cart-bottom-sheet {
  height: 84vh !important;
  max-height: 88vh !important;
  border-top-left-radius: 24px !important;
  border-top-right-radius: 24px !important;
  border: none !important;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.25) !important;
}

.sheet-grabber-bar {
  width: 44px;
  height: 5px;
  background: #cbd5e1;
  border-radius: 9999px;
  margin: 0.6rem auto 0.2rem;
  cursor: pointer;
}

.mobile-cart-body {
  display: flex;
  flex-direction: column;
  height: calc(100% - 20px);
  overflow: hidden;
  padding: 0 !important;
}

.mobile-cart-body .pos-cart-items-wrapper {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.85rem 1rem;
}

.mobile-cart-body .pos-cart-footer {
  padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.05);
  background: #ffffff;
}

/* Touch-optimized mobile cart cards & stepper */
.mobile-cart-body .cart-item-row {
  padding: 0.85rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--pos-border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.mobile-cart-body .cart-item-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.mobile-cart-body .cart-item-unit-price {
  font-size: 0.78rem;
  color: var(--pos-text-muted);
}

.mobile-cart-body .cart-qty-stepper {
  background: var(--pos-surface-body);
  border: 1px solid var(--pos-border);
  border-radius: 8px;
  padding: 2px;
}

.mobile-cart-body .cart-qty-btn {
  width: 32px;
  height: 32px;
  font-size: 0.95rem;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.mobile-cart-body .cart-qty-value {
  min-width: 28px;
  font-size: 0.9rem;
  font-weight: 700;
}

.mobile-cart-body .cart-item-total {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--pos-primary);
}

.mobile-cart-body .cart-item-remove-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--pos-danger-subtle);
  color: var(--pos-danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.4rem;
}

/* --------------------------------------------------------------------------
   Breakpoint: Large Tablets (max-width: 1199.98px)
   -------------------------------------------------------------------------- */
@media (max-width: 1199.98px) {
  .pos-cart-panel {
    width: 340px;
    min-width: 340px;
    max-width: 340px;
    flex: 0 0 340px;
  }

  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.85rem;
  }

  .product-img-box {
    aspect-ratio: 4 / 3;
    height: auto;
  }
}

/* --------------------------------------------------------------------------
   Breakpoint: Tablets Portrait & Mobile (< 992px)
   Native App Ergonomics When Scrolling
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  :root {
    --topbar-height: 58px;
  }

  /* Real Native App Shell on POS Terminal Screen */
  html.pos-page,
  body.pos-screen,
  body:has(.pos-billing-container) {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  .pos-screen .app-wrapper,
  body:has(.pos-billing-container) .app-wrapper {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* Full-width responsive main area on mobile (< 992px) */
  .app-main {
    flex: 1;
    min-width: 0;
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .pos-screen .app-main,
  body:has(.pos-billing-container) .app-main {
    height: 100%;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Sidebar behaves as offcanvas drawer */
  .app-sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--pos-shadow-lg);
  }

  .app-sidebar.show-mobile {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1038;
  }

  .sidebar-backdrop.show {
    display: block;
  }

  /* Show native mobile bottom navigation bar */
  .mobile-bottom-nav {
    display: flex;
  }

  /* Topbar Mobile Styles */
  .app-topbar {
    padding: 0 0.85rem;
    height: var(--topbar-height);
    flex-shrink: 0;
  }

  .topbar-clock {
    display: none;
  }

  /* Hide Desktop Cart Panel */
  .pos-cart-panel.desktop-only {
    display: none !important;
  }

  /* Enable Floating Cart Bar */
  .mobile-cart-bottom-bar {
    display: flex;
  }

  /* ------------------------------------------------------------------------
     POS Billing Container on Mobile:
     Header stays pinned directly under the topbar,
     while product catalog is the ONLY momentum touch scrolling container!
     ------------------------------------------------------------------------ */
  .pos-billing-container {
    flex: 1;
    height: calc(100dvh - var(--topbar-height));
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0;
  }

  /* Pinned Search & Category Header (static flex child under topbar) */
  .pos-catalog-header {
    flex-shrink: 0;
    position: relative;
    top: auto;
    z-index: 10;
    background: #ffffff;
    border-bottom: 1px solid var(--pos-border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    padding: 0.65rem 0.85rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .pos-search-barcode-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .pos-search-input-group {
    position: relative;
    flex: 1;
  }

  .pos-search-input-group input {
    padding: 0.55rem 0.85rem 0.55rem 2.35rem;
    font-size: 16px; /* 16px prevents automatic iOS Safari zoom on tap */
  }

  .pos-search-input-group i {
    left: 0.75rem;
  }

  .pos-shortcut-badge {
    display: none; /* Hide desktop F2 shortcut on touch devices */
  }

  /* Smooth horizontal scrolling category chips */
  .pos-categories-nav {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding-bottom: 0.25rem;
    margin-bottom: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .pos-categories-nav::-webkit-scrollbar {
    display: none;
  }

  .category-chip {
    padding: 0.42rem 0.85rem;
    font-size: 0.8rem;
    flex-shrink: 0;
    white-space: nowrap;
    border-radius: 9999px;
  }

  .category-chip:active {
    transform: scale(0.95);
  }

  .pos-subcategories-nav {
    padding-bottom: 0.2rem;
    -webkit-overflow-scrolling: touch;
  }

  .pos-subcategories-nav::-webkit-scrollbar {
    display: none;
  }

  .subcategory-chip {
    padding: 0.3rem 0.65rem;
    font-size: 0.74rem;
    flex-shrink: 0;
    white-space: nowrap;
    border-radius: 9999px;
  }

  .subcategory-chip:active {
    transform: scale(0.95);
  }

  /* Product Grid: THE ONLY VERTICAL SCROLLING CONTAINER ON POS SCREEN */
  .pos-products-grid-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 0.75rem 0.75rem calc(140px + env(safe-area-inset-bottom, 0px));
  }

  /* Tablets & foldables (576px - 991.98px): responsive multi-column grid */
  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
    gap: 0.75rem;
  }

  /* Mobile Product Card */
  .pos-product-card {
    padding: 0.65rem;
    border-radius: var(--radius-md);
    box-shadow: var(--pos-shadow-xs);
    min-width: 0;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }

  .pos-product-card:active {
    transform: scale(0.98);
    border-color: var(--pos-primary);
  }

  .product-img-box {
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    margin-bottom: 0.45rem;
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
  }

  .product-stock-tag {
    max-width: calc(100% - 12px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.62rem;
    padding: 0.15rem 0.35rem;
  }

  .product-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
  }

  .product-category-name {
    font-size: 0.65rem;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .product-title {
    font-size: 0.825rem;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 0.25rem;
    min-height: 2.1em;
    height: auto;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
  }

  .product-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    padding-top: 0.25rem;
    min-width: 0;
  }

  .product-price {
    font-size: 0.925rem;
    font-weight: 700;
    color: var(--pos-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .product-add-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--pos-primary-subtle);
    color: var(--pos-primary);
    font-size: 0.85rem;
    pointer-events: none;
  }

  /* ------------------------------------------------------------------------
     Universal Mobile Layout & Common Components (< 992px)
     Covers: Dashboard, Orders, Products, Categories, Customers, Reports, Settings
     ------------------------------------------------------------------------ */
  .content-wrapper {
    padding: 1rem 0.85rem calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow-x: hidden;
  }

  /* Card Ergonomics */
  .pos-card {
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  }

  .pos-card-header {
    padding: 0.85rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .pos-card-body {
    padding: 1rem;
  }

  /* Responsive Metric / KPI Cards */
  .metric-card {
    padding: 0.9rem 1rem;
    border-radius: var(--radius-md);
    gap: 0.5rem;
  }

  .metric-label {
    font-size: 0.72rem;
    margin-bottom: 0.2rem;
  }

  .metric-value {
    font-size: 1.35rem;
    line-height: 1.2;
  }

  .metric-icon-box {
    width: 42px;
    height: 42px;
    font-size: 1.15rem;
    border-radius: var(--radius-sm);
  }

  .metric-badge {
    font-size: 0.68rem;
    padding: 0.15rem 0.45rem;
    margin-top: 0.3rem;
  }

  /* Universal Touch-Friendly Data Tables */
  .pos-table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    margin-bottom: 0;
    border-radius: var(--radius-sm);
    /* Subtle touch scroll edge shadows */
    background-image: 
      linear-gradient(to right, #ffffff, rgba(255, 255, 255, 0)),
      linear-gradient(to left, #ffffff, rgba(255, 255, 255, 0)),
      radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, 0.08), rgba(0, 0, 0, 0)),
      radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, 0.08), rgba(0, 0, 0, 0));
    background-position: 0 0, 100% 0, 0 0, 100% 0;
    background-repeat: no-repeat;
    background-color: #ffffff;
    background-size: 35px 100%, 35px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
  }

  .pos-table {
    min-width: 680px;
    width: 100%;
  }

  .pos-table th {
    padding: 0.65rem 0.75rem !important;
    font-size: 0.72rem !important;
    white-space: nowrap !important;
  }

  .pos-table td {
    padding: 0.75rem 0.75rem !important;
    font-size: 0.82rem !important;
    white-space: nowrap !important;
  }

  .pos-table td .d-flex {
    white-space: normal;
  }

  /* Select2 Mobile Fit */
  .select2-container {
    width: 100% !important;
    max-width: 100% !important;
  }

  .select2-container .select2-selection--single {
    height: 40px !important;
    padding: 0.35rem 0.6rem !important;
    font-size: 0.88rem !important;
  }

  .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px !important;
    right: 8px !important;
  }

  /* Universal Mobile Toast Positioning (Top) */
  .pos-toast-container {
    top: max(0.85rem, env(safe-area-inset-top, 10px)) !important;
    bottom: auto !important;
    left: 0.85rem !important;
    right: 0.85rem !important;
    align-items: center !important;
  }

  .pos-toast {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* ------------------------------------------------------------------------
     Module: Dashboard (/dashboard) Mobile Styles
     ------------------------------------------------------------------------ */
  .dashboard-welcome-heading {
    font-size: 1.25rem !important;
  }

  /* ------------------------------------------------------------------------
     Module: Orders & History (/orders) Mobile Styles
     ------------------------------------------------------------------------ */
  #orders-table {
    min-width: 780px !important;
  }

  /* ------------------------------------------------------------------------
     Module: Products & Inventory (/products) Mobile Styles
     ------------------------------------------------------------------------ */
  .product-image-upload-zone {
    padding: 0.85rem !important;
  }

  .variant-item-row {
    padding: 0.75rem !important;
  }

  /* ------------------------------------------------------------------------
     Module: Categories (/categories) Mobile Styles
     ------------------------------------------------------------------------ */
  .category-icon-box {
    width: 32px !important;
    height: 32px !important;
    font-size: 1rem !important;
  }

  /* ------------------------------------------------------------------------
     Module: Customers (/customers) Mobile Styles
     ------------------------------------------------------------------------ */
  #customer-search-form {
    width: 100% !important;
  }

  /* ------------------------------------------------------------------------
     Module: Reports (/reports) Mobile Styles
     ------------------------------------------------------------------------ */
  .reports-period-pills {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
    scrollbar-width: none !important;
    gap: 0.25rem !important;
    padding: 0.25rem !important;
  }

  .reports-period-pills::-webkit-scrollbar {
    display: none !important;
  }

  .reports-period-pills .nav-item {
    flex: 0 0 auto !important;
  }

  .reports-period-pills .nav-link {
    white-space: nowrap !important;
    padding: 0.35rem 0.65rem !important;
    font-size: 0.78rem !important;
  }

  /* ------------------------------------------------------------------------
     Module: Settings & Terminal Hardware (/settings) Mobile Styles
     ------------------------------------------------------------------------ */
  .store-settings-hero {
    padding: 1.15rem 1rem !important;
    border-radius: var(--radius-md) !important;
    gap: 0.85rem !important;
  }

  .store-hero-left {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }

  .store-hero-avatar {
    width: 46px !important;
    height: 46px !important;
    font-size: 1.35rem !important;
  }

  .store-hero-title {
    font-size: 1.15rem !important;
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
  }

  .store-hero-meta {
    font-size: 0.75rem !important;
    gap: 0.4rem !important;
  }

  .store-hero-actions {
    width: 100% !important;
    flex-direction: row !important;
    gap: 0.5rem !important;
  }

  .store-hero-actions .btn {
    flex: 1 !important;
    justify-content: center !important;
    padding: 0.4rem 0.65rem !important;
    font-size: 0.78rem !important;
  }

  /* Settings Sticky Swipeable Tab Bar on Mobile */
  .settings-nav-card {
    position: sticky !important;
    top: var(--topbar-height, 58px) !important;
    z-index: 1015 !important;
    background: #ffffff !important;
    padding: 0.35rem !important;
    margin-bottom: 1rem !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
    border: 1px solid var(--pos-border) !important;
  }

  #settings-pills {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    gap: 0.35rem !important;
    padding-bottom: 2px !important;
    scrollbar-width: none !important;
  }

  #settings-pills::-webkit-scrollbar {
    display: none !important;
  }

  .settings-nav-pill {
    flex: 0 0 auto !important;
    width: auto !important;
    white-space: nowrap !important;
    padding: 0.5rem 0.8rem !important;
    margin-bottom: 0 !important;
    font-size: 0.8rem !important;
    gap: 0.4rem !important;
    border-radius: var(--radius-sm) !important;
  }

  .settings-nav-pill .pill-icon {
    width: 24px !important;
    height: 24px !important;
    font-size: 0.9rem !important;
  }

  .settings-nav-pill small {
    display: none !important;
  }

  .settings-content-card {
    border-radius: var(--radius-md) !important;
    margin-bottom: 1rem !important;
  }

  .settings-card-header {
    padding: 0.9rem 1rem !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }

  .settings-card-body {
    padding: 1rem !important;
  }

  .receipt-paper-wrapper {
    padding: 1rem 0.5rem !important;
    overflow-x: auto !important;
  }

  .receipt-paper-preview {
    max-width: 100% !important;
  }

  .settings-save-bar {
    position: sticky !important;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
    flex-direction: column !important;
    gap: 0.65rem !important;
    padding: 0.75rem 1rem !important;
    align-items: stretch !important;
    z-index: 1025 !important;
  }

  .settings-save-bar .btn {
    width: 100% !important;
    justify-content: center !important;
  }
}


/* --------------------------------------------------------------------------
   Breakpoint: Small Phones (max-width: 575.98px)
   -------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
  /* Compact Topbar on Mobile */
  .app-topbar {
    padding: 0 0.65rem;
    gap: 0.4rem;
  }

  .topbar-left {
    gap: 0.45rem;
    min-width: 0;
    flex-shrink: 1;
  }

  .topbar-right {
    gap: 0.4rem;
    min-width: 0;
    flex-shrink: 0;
  }

  .topbar-register-badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.72rem;
    white-space: nowrap;
    gap: 0.35rem;
  }

  .btn-topbar-held {
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem !important;
    white-space: nowrap;
  }

  #btn-fullscreen-toggle {
    display: none !important;
  }

  .btn-topbar-action {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  .btn-sidebar-toggle {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .pos-products-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.6rem;
  }

  .pos-product-card {
    padding: 0.55rem;
  }

  .product-img-box {
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    margin-bottom: 0.35rem;
  }

  .product-stock-tag {
    max-width: calc(100% - 10px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.6rem;
    padding: 0.12rem 0.35rem;
    bottom: 5px;
    left: 5px;
  }

  .product-cart-badge {
    width: 20px;
    height: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    top: 5px;
    right: 5px;
  }

  .product-title {
    font-size: 0.8rem;
    line-height: 1.25;
    min-height: 2.1em;
    height: auto;
  }

  .product-price {
    font-size: 0.88rem;
  }

  .product-add-btn {
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
    font-size: 0.8rem;
    pointer-events: none;
  }

  .category-chip {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
  }

  .payment-methods-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .payment-method-card {
    padding: 0.65rem 0.25rem;
  }

  .payment-method-card i {
    font-size: 1.15rem;
  }

  .payment-method-card span {
    font-size: 0.72rem;
  }

  .payment-modal-due-value {
    font-size: 1.75rem;
  }

  .btn-cash-preset {
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
  }

  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  .modal-body {
    padding: 1rem 0.85rem !important;
  }

  /* Metric cards on small phones: compact and readable */
  .metric-card {
    padding: 0.75rem 0.85rem !important;
  }

  .metric-value {
    font-size: 1.25rem !important;
  }

  .metric-icon-box {
    width: 38px !important;
    height: 38px !important;
    font-size: 1.05rem !important;
  }

  /* Compact card headers on small phones */
  .pos-card-header {
    padding: 0.75rem 0.85rem !important;
  }

  .pos-card-header .pos-card-title {
    font-size: 0.9rem !important;
  }

  .pos-card-body {
    padding: 0.85rem !important;
  }

  /* Buttons inside toolbars and headers */
  .pos-card-header .btn,
  .topbar-right .btn {
    font-size: 0.78rem !important;
    padding: 0.35rem 0.6rem !important;
  }

  /* Settings hero on small phones */
  .store-settings-hero {
    padding: 1rem 0.75rem !important;
  }

  .store-hero-actions {
    flex-direction: column !important;
  }

  .store-hero-actions .btn {
    width: 100% !important;
  }
}

/* --------------------------------------------------------------------------
   Breakpoint: Extra Small Phones (< 380px)
   -------------------------------------------------------------------------- */
@media (max-width: 379.98px) {
  .pos-products-grid {
    gap: 0.45rem;
  }

  .pos-products-grid-wrapper {
    padding: 0.5rem 0.5rem calc(140px + env(safe-area-inset-bottom, 0px));
  }

  .pos-product-card {
    padding: 0.45rem;
  }

  .product-title {
    font-size: 0.75rem;
  }

  .product-price {
    font-size: 0.825rem;
  }

  .payment-methods-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
