/* Mobile Layout Styles */

/* ============================================
   MOBILE-FIRST BASE (All mobile devices)
   ============================================ */
@media (max-width: 768px) {
  /* Optimized container padding */
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Touch-friendly button sizing (minimum 44px touch target) */
  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.9375rem;
    min-height: 44px;
  }

  .btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    min-height: 44px;
  }

  /* Cards with better mobile spacing */
  .card {
    margin-bottom: 1rem;
    border-radius: 0.75rem;
  }

  .card-body {
    padding: 1rem;
  }

  /* Full-width tables scroll horizontally */
  .table-responsive {
    border: none;
    margin: 0 -1rem;
    padding: 0 1rem;
  }

  /* ==========================================
     MOBILE NAVIGATION IMPROVEMENTS
     ========================================== */

  /* Mobile nav items more touch-friendly */
  .navbar-nav .nav-link {
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    margin: 0.125rem 0;
  }

  .navbar-nav .nav-link:active {
    background-color: rgba(var(--bels-primary-rgba), 0.1);
  }

  /* Mobile dropdown improvements */
  .mobile-dropdown {
    min-width: 200px;
  }

  .mobile-dropdown .dropdown-item {
    padding: 0.75rem 1rem;
  }

  /* ==========================================
     MOBILE FORM IMPROVEMENTS
     ========================================== */

  /* Larger form inputs for easier touch */
  .form-control,
  .form-select {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    min-height: 48px;
  }

  /* Form labels with better spacing */
  .form-label {
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
  }

  /* Input groups touch-friendly */
  .input-group-text {
    padding: 0.75rem 1rem;
  }

  /* Date inputs on mobile - ensure proper sizing */
  input[type="date"],
  input[type="datetime-local"],
  input[type="time"] {
    min-width: 140px;
  }

  /* Smaller date inputs when in compact groups */
  .input-group-sm input[type="date"],
  .input-group-sm input[type="datetime-local"] {
    min-height: 38px;
    padding: 0.375rem 0.5rem;
  }

  /* ==========================================
     MOBILE CARDS & LISTS
     ========================================== */

  /* Route assignments mobile optimizations */
  .route-header-mobile {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .route-info-mobile {
    order: 1;
  }

  .route-actions-mobile {
    order: 2;
    align-self: stretch;
  }

  .route-actions-mobile .btn {
    width: 100%;
    justify-content: center;
  }

  /* Store cards mobile layout */
  .store-grid-mobile .col-12 {
    margin-bottom: 0.75rem;
  }

  .store-card-mobile .card-body {
    padding: 1rem;
  }

  /* Badge spacing on mobile */
  .badge-mobile {
    margin-top: 0.5rem;
    align-self: flex-start;
  }

  /* List groups touch-friendly */
  .list-group-item {
    padding: 1rem;
    border-left: none;
    border-right: none;
  }

  /* ==========================================
     MOBILE PAGE HEADERS
     ========================================== */

  /* Page header stacking on mobile */
  .page-header-mobile {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .page-header-mobile h1 {
    font-size: 1.5rem;
    margin-bottom: 0;
  }

  .page-header-mobile .btn {
    width: 100%;
  }

  /* ==========================================
     MOBILE ACTION BUTTONS
     ========================================== */

  /* Fixed bottom action bar for important actions */
  .mobile-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: var(--bels-white);
    border-top: 1px solid var(--bels-border);
    box-shadow: 0 -4px 12px rgba(var(--bels-shadow-rgb), 0.1);
    z-index: 1030;
  }

  .mobile-action-bar .btn {
    width: 100%;
  }

  /* Add bottom padding to body when action bar is present */
  body:has(.mobile-action-bar) main {
    padding-bottom: 5rem;
  }

  /* ==========================================
     MOBILE STATS & METRICS
     ========================================== */

  /* Horizontal scrolling stat cards */
  .stat-cards-mobile {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 0.5rem;
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .stat-cards-mobile > .card {
    flex: 0 0 75%;
    scroll-snap-align: start;
    margin-bottom: 0;
  }

  .stat-cards-mobile::-webkit-scrollbar {
    height: 4px;
  }

  .stat-cards-mobile::-webkit-scrollbar-thumb {
    background: var(--bels-border);
    border-radius: 2px;
  }

  /* ==========================================
     MOBILE MODALS
     ========================================== */

  /* Full-width modals on mobile */
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  .modal-content {
    border-radius: 1rem;
  }

  .modal-header,
  .modal-footer {
    padding: 1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  /* Bottom sheet style modal */
  .modal-bottom-sheet .modal-dialog {
    margin: 0;
    max-width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }

  .modal-bottom-sheet .modal-content {
    border-radius: 1.5rem 1.5rem 0 0;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* ==========================================
     MOBILE ALERTS & TOASTS
     ========================================== */

  .alert {
    padding: 1rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
  }

  /* Toast positioning for mobile */
  .toast-container {
    padding: 1rem;
  }

  .toast {
    max-width: calc(100vw - 2rem);
  }
}

/* ============================================
   EXTRA SMALL DEVICES (phones in portrait)
   ============================================ */
@media (max-width: 375px) {
  .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .card-body {
    padding: 0.875rem;
  }

  /* Very compact buttons */
  .btn-xs-compact {
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
  }

  /* Hide less important text */
  .d-xs-none {
    display: none;
  }

  /* Stack horizontal button groups */
  .btn-group:not(.btn-group-vertical) {
    flex-direction: column;
    width: 100%;
  }

  .btn-group:not(.btn-group-vertical) .btn {
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
    width: 100%;
  }
}

/* ============================================
   LANDSCAPE MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
  /* Reduce vertical spacing in landscape */
  .card {
    margin-bottom: 0.75rem;
  }

  .card-body {
    padding: 0.75rem;
  }

  /* Navbar more compact in landscape */
  .navbar {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
  }

  /* Two-column layout for cards in landscape */
  .mobile-grid-landscape {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

/* ============================================
   iOS SAFE AREA SUPPORT
   ============================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-action-bar {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }

  body:has(.mobile-action-bar) main {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom));
  }

  .modal-bottom-sheet .modal-content {
    padding-bottom: env(safe-area-inset-bottom);
  }
}