/* CaloriesSnap - Critical Fixes v2.16 */
/* Fixes: FAB alignment with nav + Activity calendar display */

@media (max-width: 768px) {
  
  /* ===== FIX 1: FAB BUTTON ALIGNMENT WITH BOTTOM NAV ===== */
  
  /* Bottom nav has 5 items with center placeholder for FAB */
  /* Layout: [Home] [Plan] [Center-Space] [Stats] [Settings] */
  /* FAB should sit in the center space above the nav */
  
  .bottom-nav {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-around !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(70px + env(safe-area-inset-bottom)) !important;
    background: white !important;
    border-top: 1px solid var(--border-color, #e5e7eb) !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08) !important;
    padding-top: 8px !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
    z-index: 98 !important;
  }
  
  .nav-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 6px 8px !important;
    font-size: 10px !important;
    border: none !important;
    background: transparent !important;
    color: #9ca3af !important;
    transition: color 0.2s ease !important;
  }
  
  .nav-item i {
    font-size: 22px !important;
    margin-bottom: 3px !important;
  }
  
  .nav-item.active {
    color: #667eea !important;
  }
  
  /* Center placeholder for FAB - make it same width as other nav items */
  .nav-item.nav-center {
    flex: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
  }
  
  .nav-center-placeholder {
    width: 60px !important;
    height: 60px !important;
    /* Invisible placeholder that reserves space */
  }
  
  /* FAB Button - positioned relative to viewport center */
  .floating-add-btn {
    /* Position */
    position: fixed !important;
    bottom: calc(45px + env(safe-area-inset-bottom)) !important; /* Raised to sit on nav */
    left: 50% !important;
    transform: translateX(-50%) !important;
    
    /* Size */
    width: 60px !important;
    height: 60px !important;
    
    /* Shape - Perfect circle */
    border-radius: 50% !important;
    
    /* Background - White gradient */
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%) !important;
    
    /* Border - Purple */
    border: 2px solid #667eea !important;
    
    /* Icon - Purple */
    color: #667eea !important;
    font-size: 28px !important;
    
    /* Shadow */
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3), 
                0 3px 10px rgba(0, 0, 0, 0.15) !important;
    
    /* Layout */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* Z-index - Above nav */
    z-index: 999 !important;
    
    /* Transitions */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    
    /* Remove animations */
    animation: none !important;
    
    /* Ensure clickable */
    pointer-events: auto !important;
    cursor: pointer !important;
  }
  
  /* FAB active state */
  .floating-add-btn:active {
    transform: translateX(-50%) scale(0.9) !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25), 
                0 2px 6px rgba(0, 0, 0, 0.1) !important;
  }
  
  /* FAB hover (for larger screens) */
  .floating-add-btn:hover {
    transform: translateX(-50%) scale(1.05) !important;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.35), 
                0 4px 12px rgba(0, 0, 0, 0.2) !important;
  }
  
  /* ===== FIX 2: ACTIVITY CALENDAR IN STATS PAGE ===== */
  
  /* Stats section container */
  .stats-section {
    background: white !important;
    border-radius: 12px !important;
    padding: 16px !important;
    margin-bottom: 16px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
  }
  
  .stats-section h3 {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin-bottom: 16px !important;
  }
  
  /* Streak Calendar Grid */
  .streak-calendar {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 6px !important;
    padding: 8px !important;
    background: #f9fafb !important;
    border-radius: 8px !important;
    min-height: 200px !important; /* Ensure minimum height */
  }
  
  /* Calendar Day Cell */
  .calendar-day {
    aspect-ratio: 1 !important;
    min-height: 32px !important;
    min-width: 32px !important;
    background: #e5e7eb !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    transition: all 0.2s ease !important;
  }
  
  /* Logged day - Green */
  .calendar-day.logged {
    background: #10b981 !important;
  }
  
  /* Day dot indicator */
  .day-dot {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background: white !important;
    opacity: 0 !important;
    transition: opacity 0.2s ease !important;
  }
  
  /* Show dot on logged days */
  .calendar-day.logged .day-dot {
    opacity: 1 !important;
  }
  
  /* Today marker */
  .calendar-day.today {
    border: 2px solid #667eea !important;
  }
  
  /* Calendar legend */
  .calendar-legend {
    display: flex !important;
    gap: 16px !important;
    margin-top: 12px !important;
    padding: 8px !important;
    font-size: 12px !important;
    color: #666 !important;
  }
  
  .legend-item {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }
  
  .legend-box {
    width: 16px !important;
    height: 16px !important;
    border-radius: 4px !important;
  }
  
  .legend-box.empty {
    background: #e5e7eb !important;
  }
  
  .legend-box.logged {
    background: #10b981 !important;
  }
  
  /* If calendar is empty, show a message */
  .streak-calendar:empty::after {
    content: "No activity data yet. Start logging to see your progress!" !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    color: #9ca3af !important;
    font-size: 14px !important;
    padding: 40px 20px !important;
    grid-column: 1 / -1 !important;
  }
  
  /* Ensure stats tab has proper spacing for nav */
  #stats-tab {
    padding-bottom: calc(90px + env(safe-area-inset-bottom)) !important;
  }
  
  /* Stats summary grid */
  .stats-summary-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  
  .summary-stat {
    background: #f9fafb !important;
    padding: 12px !important;
    border-radius: 8px !important;
    text-align: center !important;
  }
  
  .stat-label {
    font-size: 12px !important;
    color: #6b7280 !important;
    margin-bottom: 4px !important;
  }
  
  .stat-value {
    font-size: 20px !important;
    font-weight: 700 !important;
    color: #667eea !important;
  }
  
  /* Chart containers */
  .chart-container {
    background: white !important;
    border-radius: 12px !important;
    padding: 16px !important;
    margin-bottom: 16px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
  }
  
  .chart-container h3 {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin-bottom: 12px !important;
  }
  
  .chart-container canvas {
    max-height: 250px !important;
    width: 100% !important;
  }
  
  /* Time range buttons in stats header */
  .stats-time-range {
    display: flex !important;
    gap: 8px !important;
    justify-content: center !important;
    margin-top: 12px !important;
  }
  
  .time-range-btn {
    padding: 6px 16px !important;
    border-radius: 8px !important;
    border: 1px solid #e5e7eb !important;
    background: white !important;
    color: #6b7280 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
  }
  
  .time-range-btn.active {
    background: #667eea !important;
    color: white !important;
    border-color: #667eea !important;
  }
  
  .time-range-btn:hover {
    border-color: #667eea !important;
  }
}

/* ===== DESKTOP ADJUSTMENTS ===== */
@media (min-width: 769px) {
  
  /* FAB centered on desktop too */
  .floating-add-btn {
    position: fixed !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: 40px !important;
  }
  
  .floating-add-btn:active {
    transform: translateX(-50%) scale(0.95) !important;
  }
  
  .floating-add-btn:hover {
    transform: translateX(-50%) scale(1.05) !important;
  }
  
  /* Calendar looks better on desktop with more columns */
  .streak-calendar {
    grid-template-columns: repeat(7, 1fr) !important;
    max-width: 600px !important;
    margin: 0 auto !important;
  }
}

/* ===== DARK THEME SUPPORT ===== */
body.dark-theme .stats-section {
  background: #1f2937 !important;
}

body.dark-theme .stats-section h3 {
  color: white !important;
}

body.dark-theme .streak-calendar {
  background: #111827 !important;
}

body.dark-theme .calendar-day {
  background: #374151 !important;
}

body.dark-theme .calendar-day.logged {
  background: #10b981 !important;
}

body.dark-theme .summary-stat {
  background: #111827 !important;
}

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

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

body.dark-theme .chart-container {
  background: #1f2937 !important;
}

body.dark-theme .chart-container h3 {
  color: white !important;
}

body.dark-theme .time-range-btn {
  background: #374151 !important;
  color: #9ca3af !important;
  border-color: #4b5563 !important;
}

body.dark-theme .time-range-btn.active {
  background: #667eea !important;
  color: white !important;
  border-color: #667eea !important;
}

body.dark-theme .bottom-nav {
  background: #1f2937 !important;
  border-top-color: #374151 !important;
}
