/* 📱 Mobile UI Fixes - De Grillworstboer */
/* Specifieke fixes voor de geïdentificeerde mobile problemen */

/* ========================================
   1. MOBILE HEADER & NAVIGATION FIXES
   ======================================== */

/* Fixed header op mobile */
@media (max-width: 767px) {
  .nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    height: 56px;
    background-color: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  
  /* Voorkom overlap met hamburger menu */
  .nav .container {
    padding: 0 var(--space-sm);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  /* Hamburger menu styling */
  .nav-toggle {
    position: relative;
    z-index: 1200;
    min-width: 48px;
    min-height: 48px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-right: var(--space-sm);
    background: none;
    border: none;
    color: var(--white);
    font-size: var(--font-size-xl);
    cursor: pointer;
  }
  
  /* Brand tekst aanpassen */
  .nav-brand {
    font-size: var(--font-size-base);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
  }
  
  /* Body padding voor fixed header */
  body {
    padding-top: 56px;
  }
}

/* ========================================
   2. DASHBOARD CARDS & STATISTICS
   ======================================== */

/* Admin dashboard cards */
@media (max-width: 767px) {
  /* Enhanced Dashboard toggle */
  .dashboard-toggle {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
  }
  
  .dashboard-toggle .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Statistics grid - 2 columns op mobile */
  .admin-stats-grid,
  .grid.grid-cols-2.md\\:grid-cols-4 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-sm) !important;
  }
  
  /* Stat cards compacter maken */
  .admin-stat-card,
  .card .card-body.p-md {
    padding: var(--space-sm) !important;
    min-height: auto;
  }
  
  /* Kleinere tekst in stat cards */
  .text-3xl {
    font-size: var(--font-size-xl) !important;
  }
  
  .text-xs {
    font-size: 0.625rem !important;
    line-height: 1.2;
  }
  
  /* Voorraad waarschuwing box */
  .alert,
  .kritiek-voorraad {
    padding: var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
  }
}

/* ========================================
   3. SNELLE ACTIES SECTION
   ======================================== */

@media (max-width: 767px) {
  /* Snelle acties container */
  .snelle-acties {
    margin-bottom: var(--space-lg);
  }
  
  /* Button grid - 2x2 layout */
  .snelle-acties .grid,
  .card-body .grid.grid-cols-2.md\\:grid-cols-4 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-sm) !important;
  }
  
  /* Buttons full width in grid */
  .snelle-acties .btn {
    width: 100%;
    min-height: 48px;
    padding: var(--space-sm);
    font-size: var(--font-size-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  
  /* Icon boven tekst */
  .snelle-acties .btn span:first-child {
    font-size: var(--font-size-lg);
    margin-bottom: 2px;
  }
  
  /* Auto-update toggle */
  .auto-update-toggle {
    margin-top: var(--space-md);
    padding: var(--space-sm);
    background: var(--gray-100);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

/* ========================================
   4. KLANTEN & ORDERS PAGINA'S
   ======================================== */

@media (max-width: 767px) {
  /* Top action buttons */
  .page-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
  }
  
  .page-header .btn-group {
    display: flex;
    gap: var(--space-xs);
    width: 100%;
  }
  
  .page-header .btn {
    flex: 1;
    min-height: 44px;
    font-size: var(--font-size-sm);
    padding: var(--space-xs) var(--space-sm);
  }
  
  /* Search bar */
  .search-container {
    margin-bottom: var(--space-md);
  }
  
  .search-container input {
    width: 100%;
    padding: var(--space-sm);
    font-size: 16px; /* Voorkom zoom iOS */
  }
  
  /* Filter dropdowns */
  .filter-group {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
  }
  
  .filter-group select {
    flex: 1;
    padding: var(--space-sm);
    font-size: 16px;
    min-height: 44px;
  }
  
  /* Results count */
  .results-info {
    padding: var(--space-sm);
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    text-align: center;
    font-size: var(--font-size-sm);
  }
}

/* ========================================
   5. VOORRAAD PAGINA
   ======================================== */

@media (max-width: 767px) {
  /* Voorraad stats grid */
  .voorraad-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
  }
  
  .voorraad-stat {
    background: var(--white);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
  }
  
  .voorraad-stat-value {
    font-size: var(--font-size-lg);
    font-weight: bold;
    color: var(--primary);
  }
  
  .voorraad-stat-label {
    font-size: 0.625rem;
    color: var(--gray-600);
    margin-top: 2px;
  }
}

/* ========================================
   6. BOTTOM NAVIGATION ENHANCEMENT
   ======================================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs);
  color: var(--gray-600);
  text-decoration: none;
  transition: var(--transition);
  min-height: 56px;
  position: relative;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--primary);
}

.bottom-nav-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.bottom-nav-item span {
  font-size: 0.625rem;
  font-weight: 500;
}

/* ========================================
   7. MOBILE MENU SIDEBAR
   ======================================== */

.mobile-menu {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100%;
  background: var(--white);
  z-index: 1200;
  transition: left 0.3s ease;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  -webkit-transform: translateX(0);
  transform: translateX(0);
}

.mobile-menu.active {
  left: 0;
}

.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1150;
  display: none;
  pointer-events: none;
}

.mobile-menu-overlay.active {
  display: block;
  pointer-events: auto;
}

/* Fix for admin pages - hide overlay if no mobile menu exists */
body.admin-layout .mobile-menu-overlay {
  display: none !important;
}

.mobile-menu-header {
  padding: var(--space-md);
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-close {
  background: none;
  border: none;
  color: var(--white);
  font-size: var(--font-size-xl);
  padding: var(--space-xs);
}

.mobile-menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-menu-item {
  border-bottom: 1px solid var(--gray-200);
}

.mobile-menu-link {
  display: flex;
  align-items: center;
  padding: var(--space-md);
  color: var(--gray-900);
  text-decoration: none;
  transition: var(--transition);
}

.mobile-menu-link:hover,
.mobile-menu-link.active {
  background: var(--gray-100);
  color: var(--primary);
}

.mobile-menu-icon {
  font-size: var(--font-size-lg);
  margin-right: var(--space-md);
  width: 24px;
  text-align: center;
}

/* ========================================
   8. GENERAL MOBILE IMPROVEMENTS
   ======================================== */

@media (max-width: 767px) {
  /* Consistent button styling */
  .btn {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    border-radius: var(--radius-md);
  }
  
  /* Full width buttons on mobile */
  .btn-block-mobile {
    width: 100%;
    display: block;
  }
  
  /* Card spacing */
  .card {
    margin-bottom: var(--space-md);
    border-radius: var(--radius-md);
  }
  
  .card-header {
    padding: var(--space-md);
    font-size: var(--font-size-base);
  }
  
  .card-body {
    padding: var(--space-md);
  }
  
  /* Table scrolling */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(var(--space-md) * -1);
    padding: 0 var(--space-md);
  }
  
  /* Hide non-essential columns on mobile */
  .hide-mobile {
    display: none !important;
  }
  
  /* Modals full screen on mobile */
  .modal {
    padding: 0;
  }
  
  .modal-content {
    border-radius: 0;
    height: 100vh;
    margin: 0;
    max-width: 100%;
  }
  
  /* Touch feedback */
  .btn:active,
  .bottom-nav-item:active,
  .mobile-menu-link:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
}

/* ========================================
   9. TOGGLE SWITCH COMPONENT
   ======================================== */

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-400);
  transition: 0.3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Bigger touch target on mobile */
@media (max-width: 767px) {
  .switch {
    width: 56px;
    height: 28px;
  }
  
  .slider:before {
    height: 22px;
    width: 22px;
  }
  
  input:checked + .slider:before {
    transform: translateX(28px);
  }
}

/* ========================================
   10. PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Hardware acceleration for animations */
.mobile-menu,
.nav,
.bottom-nav {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   11. MOBILE BOTTOM NAV FIX
   ======================================== */

/* Ensure mobile bottom nav is always visible on mobile */
@media (max-width: 768px) {
  /* Fix the mobile bottom navigation visibility and positioning */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 56px !important;
    z-index: 1000 !important;
    background: #2b2b2b !important;
    border-top: 1px solid #353535 !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
  }

  /* Ensure content doesn't hide behind bottom nav */
  body.admin-layout {
    padding-bottom: 56px !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
    height: auto !important;
  }

  /* Make sure admin content has proper padding */
  .admin-content {
    padding-bottom: 80px !important; /* Extra padding for scrolling comfort */
    min-height: calc(100vh - 56px) !important;
    overflow-y: auto !important;
  }

  /* Ensure main element doesn't have conflicting height */
  .admin-main {
    height: auto !important;
    min-height: calc(100vh - 56px) !important;
    overflow-y: visible !important;
  }

  /* Fix any potential scrolling issues */
  html, body {
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }
}

/* Hide mobile nav on desktop */
@media (min-width: 769px) {
  .mobile-bottom-nav {
    display: none !important;
  }
}