import React, { useRef, useState } from 'react'; import { Outlet, NavLink, useNavigate, useLocation } from 'react-router-dom'; import { useAuth } from '../context/AuthContext'; import { LayoutDashboard, Map, Calendar, LogOut, User, Home, MessageSquare } from 'lucide-react'; import Chatbot from './Chatbot'; // Rainbow Sidebar Item Component const SidebarItem = ({ to, icon: Icon, label }) => { const divRef = useRef(null); const [position, setPosition] = useState({ x: 0, y: 0 }); const [opacity, setOpacity] = useState(0); const handleMouseMove = (e) => { if (!divRef.current) return; const div = divRef.current; const rect = div.getBoundingClientRect(); setPosition({ x: e.clientX - rect.left, y: e.clientY - rect.top }); }; const handleFocus = () => setOpacity(1); const handleBlur = () => setOpacity(0); const handleMouseEnter = () => setOpacity(1); const handleMouseLeave = () => setOpacity(0); return ( `relative flex items-center space-x-3 px-4 py-3 rounded-xl transition-all duration-300 group overflow-hidden mb-1 ${isActive ? 'text-zinc-900 dark:text-white bg-black/5 dark:bg-white/5 shadow-sm dark:shadow-black/10' : 'text-zinc-500 hover:text-zinc-900 dark:hover:text-white bg-transparent hover:bg-black/5 dark:hover:bg-white/5' }` } > {/* Rainbow Border Layer - Only visible on Hover (opacity controlled by state) */}
{/* Inner Mask (The "Button" surface) */}
0 ? 'bg-zinc-50 dark:bg-[#121214]' : 'bg-transparent' }`} /> {/* Content (Z-index to sit above the mask) */}
{label}
{/* Active Indicator Dot */}
`absolute right-2 w-1.5 h-1.5 rounded-full bg-zinc-900 dark:bg-white transition-all duration-300 ${isActive ? 'opacity-100 scale-100' : 'opacity-0 scale-0'}`} /> ); }; const Layout = () => { const { user, logout } = useAuth(); const navigate = useNavigate(); const location = useLocation(); const handleLogout = () => { logout(); navigate('/login'); }; // Determine standard layout vs full screen for Landing/Login const isPublic = ['/', '/login'].includes(location.pathname); if (isPublic) { return ; } return (
{/* Sidebar */} {/* Enhanced glassmorphism with light/dark support */} {/* Main Content */}
); }; export default Layout;