'use client'; import { useState, useEffect } from 'react'; import { createPortal } from 'react-dom'; import dynamic from 'next/dynamic'; import { FiLayout, FiX } from 'react-icons/fi'; import { clsx } from 'clsx'; // Lazy load RightSidebar since it's only visible on lg+ screens const RightSidebar = dynamic(() => import('./right-sidebar').then(mod => ({ default: mod.RightSidebar })), { ssr: false, }); const RightSidebarContent = dynamic(() => import('./right-sidebar').then(mod => ({ default: mod.RightSidebarContent })), { ssr: false, }); export function SidebarLayout({ children }: { children: React.ReactNode }) { const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false); const [mounted, setMounted] = useState(false); useEffect(() => setMounted(true), []); useEffect(() => { if (mobileSidebarOpen) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = ''; } return () => { document.body.style.overflow = ''; }; }, [mobileSidebarOpen]); const mobileDrawer = mounted && createPortal( <> {/* Backdrop */}