/* CaloriesSnap - Final Perfect v2.18 */
/* Fixes: Perfect FAB centering + Larger milestone cards with readable text */

@media (max-width: 768px) {
  
  /* ===== FIX 1: PERFECT FAB CENTERING ===== */
  
  /* Bottom navigation - 4 actual nav items + 1 center space */
  .bottom-nav {
    display: flex !important;
    align-items: center !important;
    justify-content: space-evenly !important; /* Changed from space-around to space-evenly */
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 65px !important;
    padding: 0 !important; /* Remove padding for perfect spacing */
    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 - equal width */
  .nav-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 6px 4px !important;
    font-size: 9px !important;
    border: none !important;
    background: transparent !important;
    color: #9ca3af !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    max-width: 80px !important; /* Limit width for better spacing */
  }
  
  .nav-item i {
    font-size: 18px !important;
    margin-bottom: 2px !important;
  }
  
  .nav-item span {
    font-size: 9px !important;
    font-weight: 500 !important;
  }
  
  .nav-item.active {
    color: #667eea !important;
  }
  
  .nav-item:active {
    transform: scale(0.95) !important;
  }
  
  /* Center placeholder - same width as nav items */
  .nav-item.nav-center {
    flex: 1 !important;
    max-width: 80px !important;
    pointer-events: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .nav-center-placeholder {
    width: 56px !important;
    height: 56px !important;
    /* Invisible but reserves exact space */
  }
  
  /* ===== FAB BUTTON - PERFECTLY CENTERED ===== */
  
  .floating-add-btn {
    /* Position - Use calc to ensure perfect centering */
    position: fixed !important;
    bottom: 32px !important;
    left: 50% !important;
    margin-left: -28px !important; /* Exactly half of 56px width */
    transform: none !important; /* Remove transform to avoid sub-pixel issues */
    
    /* Size */
    width: 56px !important;
    height: 56px !important;
    
    /* Shape */
    border-radius: 50% !important;
    
    /* Background */
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%) !important;
    
    /* Border */
    border: 2px solid #667eea !important;
    
    /* Icon */
    color: #667eea !important;
    font-size: 26px !important;
    
    /* Shadow */
    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;
    
    /* Layout */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* Z-index */
    z-index: 999 !important;
    
    /* Transitions */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    
    /* Ensure clickable */
    pointer-events: auto !important;
    cursor: pointer !important;
  }
  
  /* FAB active state */
  .floating-add-btn:active {
    transform: scale(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;
  }
  
  /* ===== FIX 2: LARGER MILESTONE CARDS WITH READABLE TEXT ===== */
  
  /* Milestones grid - single column for mobile */
  .milestones-grid {
    display: grid !important;
    grid-template-columns: 1fr !important; /* Single column on mobile */
    gap: 12px !important;
  }
  
  /* Milestone card - much larger and more visible */
  .milestone-item {
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%) !important;
    border: 2px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 16px !important; /* Increased from small to 16px */
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
    min-height: 80px !important; /* Ensure minimum height */
    transition: all 0.3s ease !important;
    position: relative !important;
    overflow: hidden !important;
  }
  
  /* Achieved milestone - special styling */
  .milestone-item.achieved {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%) !important;
    border-color: #10b981 !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2) !important;
  }
  
  /* Milestone emoji - larger and prominent */
  .milestone-emoji {
    font-size: 48px !important; /* Increased from small to 48px */
    line-height: 1 !important;
    min-width: 60px !important;
    text-align: center !important;
  }
  
  /* Milestone content wrapper */
  .milestone-content {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }
  
  /* Milestone title - larger and readable */
  .milestone-title {
    font-size: 16px !important; /* Increased from small to 16px */
    font-weight: 600 !important;
    color: #1f2937 !important;
    line-height: 1.3 !important;
  }
  
  /* Milestone progress text - larger */
  .milestone-progress {
    font-size: 14px !important; /* Increased from small to 14px */
    color: #6b7280 !important;
    font-weight: 500 !important;
  }
  
  /* Progress bar container - larger and more visible */
  .milestone-progress-bar {
    width: 100% !important;
    height: 8px !important; /* Increased from 4px to 8px */
    background: #e5e7eb !important;
    border-radius: 4px !important;
    overflow: hidden !important;
    margin-top: 8px !important;
    position: relative !important;
  }
  
  /* Progress bar fill */
  .milestone-progress-fill {
    height: 100% !important;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%) !important;
    border-radius: 4px !important;
    transition: width 0.5s ease !important;
  }
  
  /* Achieved milestone progress bar */
  .milestone-item.achieved .milestone-progress-bar {
    background: #d1fae5 !important;
  }
  
  .milestone-item.achieved .milestone-progress-fill {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%) !important;
  }
  
  /* Achievement badge */
  .milestone-achievement-badge {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    background: #10b981 !important;
    color: white !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4) !important;
  }
  
  /* Hide badge on non-achieved milestones */
  .milestone-item:not(.achieved) .milestone-achievement-badge {
    display: none !important;
  }
  
  /* Tap feedback on milestone cards */
  .milestone-item:active {
    transform: scale(0.98) !important;
  }
  
  /* Stats section title with milestone */
  .stats-section h3 {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #1f2937 !important;
    margin-bottom: 12px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  
  /* Empty milestone state */
  .milestones-grid:empty::after {
    content: "Complete your first day to unlock milestones!" !important;
    display: block !important;
    text-align: center !important;
    padding: 40px 20px !important;
    color: #9ca3af !important;
    font-size: 14px !important;
  }
  
  /* Comparison grid - better layout */
  .comparison-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
  
  .comparison-item {
    background: #f9fafb !important;
    padding: 16px !important;
    border-radius: 10px !important;
    text-align: center !important;
    border: 1px solid #e5e7eb !important;
  }
  
  .comparison-label {
    font-size: 12px !important;
    color: #6b7280 !important;
    margin-bottom: 6px !important;
    font-weight: 500 !important;
  }
  
  .comparison-value {
    font-size: 20px !important;
    font-weight: 700 !important;
    color: #667eea !important;
  }
  
  .comparison-change {
    font-size: 12px !important;
    margin-top: 4px !important;
    font-weight: 600 !important;
  }
  
  .comparison-change.positive {
    color: #10b981 !important;
  }
  
  .comparison-change.negative {
    color: #ef4444 !important;
  }
  
  /* Insights list - better readability */
  .insights-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }
  
  .insight-item {
    background: #f9fafb !important;
    padding: 14px !important;
    border-radius: 10px !important;
    border-left: 4px solid #667eea !important;
    font-size: 14px !important;
    color: #374151 !important;
    line-height: 1.5 !important;
  }
  
  .insight-item.tip {
    border-left-color: #10b981 !important;
  }
  
  .insight-item.warning {
    border-left-color: #f59e0b !important;
  }
  
  /* Export button at bottom */
  .secondary-btn {
    width: 100% !important;
    padding: 14px !important;
    margin-top: 16px !important;
    margin-bottom: 16px !important;
    background: white !important;
    color: #667eea !important;
    border: 2px solid #667eea !important;
    border-radius: 10px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
  }
  
  .secondary-btn:active {
    transform: scale(0.98) !important;
    background: #667eea !important;
    color: white !important;
  }
}

/* ===== TABLET ADJUSTMENTS ===== */
@media (min-width: 481px) and (max-width: 768px) {
  
  /* Milestones in 2 columns on tablet */
  .milestones-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  /* Smaller emoji on tablet */
  .milestone-emoji {
    font-size: 40px !important;
  }
}

/* ===== DESKTOP ADJUSTMENTS ===== */
@media (min-width: 769px) {
  
  /* FAB on desktop */
  .floating-add-btn {
    bottom: 40px !important;
    left: 50% !important;
    margin-left: -28px !important;
  }
  
  /* Milestones in 4 columns on desktop */
  .milestones-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
  }
  
  /* Vertical layout on desktop */
  .milestone-item {
    flex-direction: column !important;
    text-align: center !important;
    padding: 20px !important;
  }
  
  .milestone-emoji {
    font-size: 56px !important;
  }
}

/* ===== DARK THEME SUPPORT ===== */
body.dark-theme .milestone-item {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%) !important;
  border-color: #374151 !important;
}

body.dark-theme .milestone-item.achieved {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 100%) !important;
  border-color: #10b981 !important;
}

body.dark-theme .milestone-title {
  color: white !important;
}

body.dark-theme .milestone-progress {
  color: #9ca3af !important;
}

body.dark-theme .milestone-progress-bar {
  background: #374151 !important;
}

body.dark-theme .comparison-item {
  background: #1f2937 !important;
  border-color: #374151 !important;
}

body.dark-theme .comparison-label {
  color: #9ca3af !important;
}

body.dark-theme .comparison-value {
  color: #818cf8 !important;
}

body.dark-theme .insight-item {
  background: #1f2937 !important;
  color: #d1d5db !important;
}

body.dark-theme .secondary-btn {
  background: #1f2937 !important;
  border-color: #818cf8 !important;
  color: #818cf8 !important;
}

body.dark-theme .secondary-btn:active {
  background: #818cf8 !important;
  color: white !important;
}

/* ===== PERFORMANCE ===== */
.milestone-item,
.comparison-item,
.insight-item {
  will-change: transform !important;
  backface-visibility: hidden !important;
}
