/**
 * BIG ZAINT — Customer Responsive Optimizations
 * Breakpoints: 320px, 360px, 480px, 640px, 860px, 1024px, 1280px, 1440px
 */

/* =========================================================================
   1. Large Tablets & Small Laptops (<= 1024px)
   ========================================================================= */
@media (max-width: 1024px) {
  .c-shell-sidebar {
    width: 230px;
  }

  .c-shell-body,
  .c-shell-container {
    padding: 1.25rem 1rem 2.5rem;
    gap: 1.25rem;
  }
}

/* =========================================================================
   2. Mobile Viewports (<= 860px)
   Header, Sidebar, Bottom Nav, Padding Overhauls
   ========================================================================= */
@media (max-width: 860px) {
  /* Switch from Desktop Header to Mobile Header */
  .c-header {
    display: none !important;
  }

  .c-mobile-header {
    display: flex !important;
  }

  /* Hide Desktop Sidebar */
  .c-shell-sidebar {
    display: none !important;
  }

  .c-shell-body,
  .c-shell-container {
    padding: 1rem 0.875rem 2rem;
  }

  /* Show Unified Customer Mobile Bottom Navigation */
  .c-bottom-nav {
    display: block !important;
  }

  body.customer-app,
  .customer-app-has-bottom-nav {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Grid Layouts Stack Gracefully */
  .c-grid-dashboard-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  /* Cart & Checkout Grid Stacking on Mobile */
  .c-cart-grid,
  .c-checkout-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  /* Quick Services Grid on Tablet/Mobile */
  .c-grid-services {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.65rem !important;
  }

  .c-order-card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }
}

/* Address & Service Grid Stacking on Mid-to-Small Mobile */
@media (max-width: 480px) {
  .c-grid-services {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .c-grid-dashboard-stats {
    grid-template-columns: 1fr !important;
  }

  .c-address-grid {
    grid-template-columns: 1fr !important;
  }
}

/* =========================================================================
   3. Small Mobile Devices (<= 640px)
   Sticky CTAs, Full Width Modals, Single Column Layouts
   ========================================================================= */
@media (max-width: 640px) {
  .c-h1 { font-size: 1.375rem !important; }
  .c-h2 { font-size: 1.2rem !important; }
  .c-h3 { font-size: 1.05rem !important; }

  /* Modals as Modern Bottom Sheets */
  .c-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .c-modal-dialog {
    max-width: 100%;
    border-radius: var(--c-radius-lg) var(--c-radius-lg) 0 0;
    transform: translateY(100%);
    max-height: 88vh;
  }

  .c-modal-overlay.is-open .c-modal-dialog {
    transform: translateY(0);
  }

  /* Mobile Sticky Bottom CTA Bar (Cart & Checkout) */
  .c-mobile-sticky-bar {
    display: flex !important;
    position: fixed;
    bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    background-color: #ffffff;
    border-top: 1px solid var(--c-border);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
    padding: 0.75rem 1rem;
    z-index: 980;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  /* Buttons on forms stack to full width */
  .c-form-actions-mobile-stack {
    flex-direction: column !important;
    width: 100%;
  }

  .c-form-actions-mobile-stack .c-btn {
    width: 100%;
  }

  /* Order details table / grid turns into flex cards */
  .c-responsive-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Order Card Mobile Stacking */
  .c-order-item-body {
    flex-direction: column !important;
    gap: 0.875rem !important;
  }

  .c-order-item-actions {
    width: 100% !important;
    margin-left: 0 !important;
    align-items: stretch !important;
    border-top: 1px dashed var(--c-border);
    padding-top: 0.75rem !important;
  }

  .c-order-price-box {
    text-align: left !important;
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: baseline !important;
    margin-bottom: 0.5rem !important;
  }

  .c-order-btn-group {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }

  .c-order-btn-group .c-btn {
    width: 100% !important;
    justify-content: center !important;
  }

  .c-toast-container {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    max-width: none;
  }
}

/* Filter Tab Active Style */
.filter-tab.active {
  background-color: var(--c-primary) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(12, 53, 120, 0.20) !important;
}

/* Horizontal Containment Safeguards */
.customer-app,
.c-shell-layout,
.c-shell-main {
  max-width: 100vw;
  box-sizing: border-box;
}

/* =========================================================================
   4. Extra Small Phones (320px - 375px)
   ========================================================================= */
@media (max-width: 375px) {
  .c-shell-body {
    padding: 0.75rem 0.5rem 1.5rem;
  }

  .c-grid-dashboard-stats {
    grid-template-columns: 1fr !important;
  }

  .c-btn {
    padding: 0.5rem 0.875rem;
    font-size: var(--c-fs-sm);
  }

  .c-bnav-item {
    font-size: 10px;
  }
  
  .c-bnav-item i {
    font-size: 1rem;
  }
}
