/* CaloriesSnap - Professional Nav & PWA v2.20 */
/* Fixes: Larger bottom nav icons (normal app size) + PWA optimizations */

@media (max-width: 768px) {
  
  /* ===== LARGER BOTTOM NAVIGATION (LIKE OTHER APPS) ===== */
  
  .bottom-nav {
    display: flex !important;
    align-items: center !important;
    justify-content: space-evenly !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 70px !important; /* Increased from 65px */
    padding: 0 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
    background: white !important;
    border-top: 1px solid #e5e7eb !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08) !important;
    z-index: 98 !important;
  }
  
  /* ===== NAVIGATION ITEMS - NORMAL APP SIZE ===== */
  .nav-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 8px 6px !important; /* More padding */
    font-size: 11px !important; /* Increased from 9px */
    border: none !important;
    background: transparent !important;
    color: #9ca3af !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    max-width: 85px !important;
    gap: 4px !important; /* Space between icon and text */
  }
  
  /* ===== LARGER ICONS (NORMAL SIZE LIKE OTHER APPS) ===== */
  .nav-item i {
    font-size: 24px !important; /* Increased from 18px to 24px */
    margin-bottom: 0px !important;
    line-height: 1 !important;
  }
  
  /* ===== READABLE LABELS ===== */
  .nav-item span {
    font-size: 11px !important; /* Increased from 9px to 11px */
    font-weight: 500 !important;
    line-height: 1.2 !important;
  }
  
  /* Active nav item - prominent */
  .nav-item.active {
    color: #667eea !important;
  }
  
  .nav-item.active i {
    transform: scale(1.1) !important;
  }
  
  /* Tap feedback */
  .nav-item:active {
    transform: scale(0.95) !important;
    background: rgba(102, 126, 234, 0.05) !important;
    border-radius: 12px !important;
  }
  
  /* Center placeholder for FAB */
  .nav-item.nav-center {
    flex: 1 !important;
    max-width: 85px !important;
    pointer-events: none !important;
  }
  
  .nav-center-placeholder {
    width: 56px !important;
    height: 56px !important;
  }
  
  /* ===== FAB BUTTON - STABLE POSITION ===== */
  .floating-add-btn {
    position: fixed !important;
    bottom: 35px !important; /* Adjusted for taller nav */
    left: 50% !important;
    margin-left: -28px !important;
    transform: none !important;
    
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%) !important;
    border: 2px solid #667eea !important;
    color: #667eea !important;
    font-size: 26px !important;
    
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.35), 
                0 4px 12px rgba(0, 0, 0, 0.2),
                0 0 0 4px rgba(255, 255, 255, 0.9) !important;
    
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999 !important;
    transition: box-shadow 0.2s ease, opacity 0.2s ease !important;
    pointer-events: auto !important;
    cursor: pointer !important;
  }
  
  .floating-add-btn:active {
    transform: none !important;
    margin-left: -28px !important;
    left: 50% !important;
    opacity: 0.9 !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3), 
                0 2px 6px rgba(0, 0, 0, 0.15),
                0 0 0 4px rgba(255, 255, 255, 0.9) !important;
  }
  
  /* ===== PAGE CONTENT SPACING ===== */
  .page-content,
  #home-tab,
  #plan-tab,
  #stats-tab,
  #profile-tab,
  #settings-tab {
    padding-bottom: 95px !important; /* More space for taller nav + FAB */
  }
}

/* ===== PWA OPTIMIZATION ===== */

/* PWA Install Banner - Prominent */
.pwa-install-banner {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  padding: 12px 16px !important;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
  z-index: 1000 !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  animation: slideDown 0.3s ease !important;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-install-banner.hidden {
  display: none !important;
}

.banner-content {
  flex: 1 !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

.banner-icon {
  font-size: 32px !important;
  line-height: 1 !important;
}

.banner-text {
  flex: 1 !important;
}

.banner-text strong {
  display: block !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  margin-bottom: 2px !important;
}

.banner-text p {
  font-size: 12px !important;
  opacity: 0.9 !important;
  margin: 0 !important;
}

.install-btn {
  background: white !important;
  color: #667eea !important;
  border: none !important;
  padding: 8px 16px !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  white-space: nowrap !important;
}

.install-btn:active {
  transform: scale(0.95) !important;
  background: #f3f4f6 !important;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2) !important;
  border: none !important;
  color: white !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  font-size: 20px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.2s ease !important;
}

.close-btn:active {
  background: rgba(255, 255, 255, 0.3) !important;
}

/* PWA Standalone Mode Detection */
@media (display-mode: standalone) {
  .pwa-install-banner {
    display: none !important; /* Hide banner in standalone */
  }
  
  /* Show that it's running as PWA */
  body::before {
    content: '' !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 2px !important;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%) !important;
    z-index: 10000 !important;
  }
}

/* iOS PWA Support */
@supports (-webkit-touch-callout: none) {
  .bottom-nav {
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    height: calc(70px + env(safe-area-inset-bottom)) !important;
  }
  
  .page-content,
  #home-tab,
  #plan-tab,
  #stats-tab,
  #profile-tab,
  #settings-tab {
    padding-bottom: calc(95px + env(safe-area-inset-bottom)) !important;
  }
}

/* ===== TABLET ADJUSTMENTS ===== */
@media (min-width: 481px) and (max-width: 768px) {
  
  .nav-item {
    max-width: 100px !important;
  }
  
  .nav-item i {
    font-size: 26px !important;
  }
  
  .nav-item span {
    font-size: 12px !important;
  }
}

/* ===== DESKTOP ADJUSTMENTS ===== */
@media (min-width: 769px) {
  
  /* Hide PWA banner on desktop (use browser install prompt) */
  .pwa-install-banner {
    top: auto !important;
    bottom: 20px !important;
    left: 20px !important;
    right: auto !important;
    max-width: 400px !important;
    border-radius: 12px !important;
  }
  
  .floating-add-btn {
    bottom: 40px !important;
  }
}

/* ===== DARK THEME SUPPORT ===== */
body.dark-theme .bottom-nav {
  background: #1f2937 !important;
  border-top-color: #374151 !important;
}

body.dark-theme .nav-item {
  color: #9ca3af !important;
}

body.dark-theme .nav-item.active {
  color: #818cf8 !important;
}

body.dark-theme .nav-item:active {
  background: rgba(129, 140, 248, 0.1) !important;
}

body.dark-theme .floating-add-btn {
  background: linear-gradient(135deg, #374151 0%, #1f2937 100%) !important;
  border-color: #818cf8 !important;
  color: #818cf8 !important;
  box-shadow: 0 8px 24px rgba(129, 140, 248, 0.35), 
              0 4px 12px rgba(0, 0, 0, 0.3),
              0 0 0 4px rgba(31, 41, 55, 0.9) !important;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Prevent layout shifts */
.bottom-nav,
.nav-item,
.floating-add-btn {
  contain: layout style paint !important;
}

/* GPU acceleration */
.nav-item,
.floating-add-btn,
.pwa-install-banner {
  will-change: transform !important;
  transform: translateZ(0) !important;
  backface-visibility: hidden !important;
}

/* Smooth transitions */
.nav-item i {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Touch optimization */
.nav-item,
.floating-add-btn,
.install-btn,
.close-btn {
  -webkit-tap-highlight-color: transparent !important;
  touch-action: manipulation !important;
}

/* Prevent double-tap zoom on buttons */
button {
  touch-action: manipulation !important;
}

/* ===== ACCESSIBILITY ===== */

/* Focus visible for keyboard navigation */
.nav-item:focus-visible,
.floating-add-btn:focus-visible {
  outline: 3px solid #667eea !important;
  outline-offset: 2px !important;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .nav-item {
    border: 1px solid currentColor !important;
  }
  
  .floating-add-btn {
    border-width: 3px !important;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .nav-item,
  .floating-add-btn,
  .pwa-install-banner {
    transition: none !important;
    animation: none !important;
  }
}

/* ===== LOADING STATE ===== */

/* Show loading indicator while PWA initializes */
body:not(.pwa-ready) .bottom-nav {
  opacity: 0 !important;
  pointer-events: none !important;
}

body.pwa-ready .bottom-nav {
  opacity: 1 !important;
  animation: fadeIn 0.3s ease !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
