/* ==========================================================================
   InvoiceFlow — Responsive Breakpoints & Mobile Adaptations
   ========================================================================== */

/* Breakpoints:
   - Large Desktop: >= 1280px
   - Laptop / Standard Desktop: <= 1024px
   - Tablet / Medium Screen: <= 992px
   - Tablet Small: <= 768px
   - Mobile Large / Phablet: <= 576px
   - Mobile Medium: <= 480px
   - Mobile Small: <= 375px
   - Mobile Micro (iPhone SE / Galaxy Fold): <= 320px
   ========================================================================== */

/* Global Anti-Overflow Container Protection */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* ==========================================================================
   Laptop & Medium Desktop (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

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

  .auth-split-container {
    grid-template-columns: 1fr;
  }

  .auth-brand-side {
    display: none;
  }
}

@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    width: 280px;
  }

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

  .app-main {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    padding-bottom: 74px; /* Space for bottom navigation */
  }

  .mobile-toggle-btn {
    display: flex;
    position: static;
    transform: none;
    flex-shrink: 0;
    margin-right: 12px;
    z-index: 10;
  }

  .top-nav {
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    text-align: left;
    z-index: 90;
  }

  .top-nav-left {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: static;
    min-width: 0;
  }

  .greeting-wrapper {
    text-align: left;
    min-width: 0;
    overflow: hidden;
  }

  .greeting-title {
    font-size: 0.95rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
  }

  .greeting-subtitle {
    font-size: 0.7rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin-top: 2px;
  }

  /* Hide header logout on mobile */
  .top-nav-right {
    display: none !important;
  }

  .live-clock-pill {
    display: none;
  }

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

  .page-container {
    margin-top: 64px;
    padding: 16px 14px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  /* Banner Action Card mobile optimization */
  .banner-action-card {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 18px 16px !important;
    gap: 16px !important;
  }

  .banner-action-buttons {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .banner-action-buttons .btn {
    width: 100% !important;
  }

  /* Pending Approval Queue Card mobile optimization */
  .pending-queue-card {
    padding: 18px 16px !important;
  }

  .queue-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .queue-title-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  .queue-header .btn {
    width: 100% !important;
  }

  .queue-item {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 14px 16px !important;
    gap: 12px !important;
  }

  .queue-item-meta {
    width: 100% !important;
    gap: 12px !important;
  }

  .queue-customer {
    white-space: normal !important;
  }

  .queue-product {
    white-space: normal !important;
    line-height: 1.35 !important;
    margin-top: 2px !important;
  }

  .queue-item-actions {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding-top: 10px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
  }

  .queue-item-actions .btn {
    min-width: 90px !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  .form-grid-full {
    grid-column: span 1;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-full {
    grid-column: span 1;
  }

  /* Keep table structure intact with smooth horizontal touch-scrolling */
  .data-table-wrapper {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .table-search-box {
    width: 100%;
    min-width: auto;
  }

  .filter-pills {
    overflow-x: auto;
    width: 100%;
  }

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

  .hero-preview-container {
    margin-top: 30px;
  }

  /* Form actions mobile optimization */
  .form-actions-bar {
    display: flex !important;
    flex-direction: column-reverse !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .form-actions-bar .btn {
    width: 100% !important;
    justify-content: center !important;
    white-space: normal !important;
    text-align: center !important;
    padding: 12px 16px !important;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

@media (max-width: 480px) {
  .page-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .modal-dialog {
    margin: 12px;
    width: calc(100% - 24px);
  }

  .btn-lg {
    padding: 12px 20px;
    font-size: 0.95rem;
  }

  .invoice-actions-bar {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .invoice-actions-bar .btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 9px 6px !important;
    font-size: 0.75rem !important;
    white-space: normal !important;
    text-align: center !important;
    line-height: 1.2 !important;
  }
}

/* Mobile Sidebar Backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 95;
}

.sidebar-overlay.active {
  display: block;
}
