'use client';

import { usePathname, useRouter } from 'next/navigation';
import { BottomNavigation, BottomNavigationAction, Paper } from '@mui/material';
import {
  Home,
  Timeline,
  Chat,
  Insights,
  Settings,
} from '@mui/icons-material';

export const TabBar = () => {
  const router = useRouter();
  const pathname = usePathname();

  const tabs = [
    { label: 'Home', icon: <Home />, value: '/' },
    { label: 'Track', icon: <Timeline />, value: '/track' },
    { label: 'AI Chat', icon: <Chat />, value: '/ai-assistant' },
    { label: 'Insights', icon: <Insights />, value: '/insights' },
    { label: 'Settings', icon: <Settings />, value: '/settings' },
  ];

  return (
    <Paper
      component="nav"
      aria-label="Primary navigation"
      sx={{
        position: 'fixed',
        bottom: 0,
        left: 0,
        right: 0,
        zIndex: 1000,
      }}
      elevation={3}
    >
      <BottomNavigation
        value={pathname}
        onChange={(event, newValue) => {
          router.push(newValue);
        }}
        showLabels
        sx={{
          height: 64,
          '& .MuiBottomNavigationAction-root': {
            minWidth: 60,
            '&.Mui-selected': {
              color: 'primary.main',
            },
          },
        }}
      >
        {tabs.map((tab) => (
          <BottomNavigationAction
            key={tab.value}
            label={tab.label}
            icon={tab.icon}
            value={tab.value}
          />
        ))}
      </BottomNavigation>
    </Paper>
  );
};
