'use client';
import { useState, useEffect } from 'react';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { motion, AnimatePresence } from 'framer-motion';
import {
LayoutDashboard,
FlaskConical,
Clock,
History,
Search,
Settings,
BookOpen,
ChevronRight,
LogOut,
Dna,
Menu,
} from 'lucide-react';
import { useAuth } from '@/contexts/auth';
import { ThemeToggle } from '@/components/ThemeToggle';
import { ErrorBoundary } from '@/components/ErrorBoundary';
import { TutorialWalkthrough } from '@/components/TutorialWalkthrough';
const NAV_ITEMS = [
{ href: '/dashboard', icon: LayoutDashboard, label: 'Dashboard' },
{ href: '/analyze', icon: FlaskConical, label: 'Analyze' },
{ href: '/retrieve', icon: Search, label: 'Retrieve' },
{ href: '/jobs', icon: Clock, label: 'Jobs' },
{ href: '/history', icon: History, label: 'History' },
{ href: '/learn', icon: BookOpen, label: 'Learn' },
{ href: '/settings', icon: Settings, label: 'Settings' },
] as const;
const labelVariants = {
hidden: { opacity: 0, width: 0, transition: { duration: 0.15 } },
show: { opacity: 1, width: 'auto', transition: { duration: 0.2, delay: 0.05 } },
};
function SidebarContent({
collapsed,
pathname,
user,
signOut,
}: {
collapsed: boolean;
pathname: string;
user: { email?: string | null } | null;
signOut: () => void;
}) {
return (
{!collapsed && (
Bio Nexus
)}
{user && !collapsed && (
{user.email ?? 'Guest session'}
)}
);
}
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
const pathname = usePathname();
const { user, signOut } = useAuth();
const [collapsed, setCollapsed] = useState(false);
const [mobileOpen, setMobileOpen] = useState(false);
useEffect(() => { setMobileOpen(false); }, [pathname]);
const sidebarBg = {
background: 'rgba(8, 8, 18, 0.75)',
borderRight: '1px solid rgba(100, 110, 180, 0.10)',
backdropFilter: 'blur(24px) saturate(160%)',
WebkitBackdropFilter: 'blur(24px) saturate(160%)',
};
return (
{mobileOpen && (
<>
setMobileOpen(false)}
/>
>
)}
);
}