/* Mobile PWA Enhancements CSS */

/* Touch-friendly interface improvements */
@media (max-width: 768px) {
  /* Larger touch targets */
  .btn, .btn-sm, .btn-lg {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }
  
  /* Enhanced navigation for mobile */
  .navbar-nav .nav-link {
    padding: 12px 16px;
    font-size: 1.1rem;
  }
  
  /* Better form controls */
  .form-control, .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Card improvements */
  .card {
    margin-bottom: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
  
  /* Table responsiveness */
  .table-responsive {
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  }
  
  /* Action button groups */
  .btn-group-vertical .btn {
    margin-bottom: 8px;
  }
  
  /* Enhanced spacing */
  .container-fluid {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* PWA App-like styling */
.pwa-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pwa-bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  background: white;
  border-top: 1px solid #dee2e6;
  padding: 8px 0;
  z-index: 1030;
  display: none;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
  .pwa-bottom-nav {
    display: flex !important;
  }
  
  body {
    padding-bottom: 80px !important; /* Increased space for bottom navigation */
  }
  
  /* Ensure main content doesn't overlap */
  .container-fluid,
  .container,
  main,
  #main-content {
    padding-bottom: 90px !important;
  }
}

.pwa-nav-item {
  flex: 1;
  text-align: center;
  padding: 8px;
  color: #6c757d;
  text-decoration: none;
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: color 0.2s;
}

.pwa-nav-item:hover,
.pwa-nav-item.active {
  color: #007bff;
  text-decoration: none;
}

.pwa-nav-item i {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

/* Pull-to-refresh indicator */
.pull-to-refresh {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  transition: top 0.3s ease;
  z-index: 1040;
}

.pull-to-refresh.active {
  top: 20px;
}

/* Gesture indicators */
.swipe-indicator {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
  font-size: 1.5rem;
  opacity: 0.6;
  animation: swipeHint 2s infinite;
}

@keyframes swipeHint {
  0%, 100% { transform: translateY(-50%) translateX(0); opacity: 0.6; }
  50% { transform: translateY(-50%) translateX(-8px); opacity: 1; }
}

/* Enhanced loading states */
.pwa-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  flex-direction: column;
}

.pwa-loading .spinner-border {
  margin-bottom: 16px;
}

/* Offline indicator */
.offline-indicator {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: #dc3545;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  z-index: 1040;
  display: none;
}

.offline-indicator.show {
  display: block;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { top: 0; opacity: 0; }
  to { top: 60px; opacity: 1; }
}

/* Install prompt styling */
.install-prompt {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1050;
  display: none;
}

.install-prompt.show {
  display: block;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { bottom: -100px; opacity: 0; }
  to { bottom: 20px; opacity: 1; }
}

/* Enhanced focus states for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus {
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
  border-color: #80bdff;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border-width: 2px;
  }
  
  .card {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .pwa-bottom-nav {
    background: #212529;
    border-top-color: #495057;
  }
  
  .pwa-nav-item {
    color: #adb5bd;
  }
  
  .pwa-nav-item:hover,
  .pwa-nav-item.active {
    color: #0d6efd;
  }
}

/* iOS App Specific Styles */
html.ios-app body {
  padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
}

html.ios-app .pwa-bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 9999 !important;
  background: white !important;
  border-top: 1px solid #dee2e6 !important;
  padding-bottom: env(safe-area-inset-bottom) !important;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
  display: flex !important;
}

/* Hide PWA install prompts in iOS app */
html.ios-app .pwa-install-banner,
html.ios-app .pwa-install-prompt,
html.ios-app .install-prompt {
  display: none !important;
}

/* Hide top navigation in iOS app since it's redundant */
html.ios-app .navbar:not(.pwa-bottom-nav) {
  display: none !important;
}

html.ios-app .container-fluid,
html.ios-app .container,
html.ios-app main,
html.ios-app #main-content {
  padding-top: 20px !important;
  padding-bottom: calc(90px + env(safe-area-inset-bottom)) !important;
}

/* Dark mode install prompt styling */
@media (prefers-color-scheme: dark) {
  .install-prompt {
    background: #212529;
    border-color: #495057;
    color: #f8f9fa;
  }
  
  .install-prompt .text-muted {
    color: #adb5bd !important;
  }
  
  .install-prompt .text-primary {
    color: #66b3ff !important;
  }
  
  .install-prompt .btn-outline-secondary {
    color: #adb5bd;
    border-color: #495057;
  }
  
  .install-prompt .btn-outline-secondary:hover {
    background: #495057;
    color: #f8f9fa;
  }
}