import { useEffect, useCallback, type ReactNode } from 'react' import { X } from 'lucide-react' import { cn } from '@/lib/utils' interface ModalProps { isOpen: boolean onClose: () => void title: string children: ReactNode /** Optional footer content that stays fixed at bottom (doesn't scroll) */ footer?: ReactNode size?: 'sm' | 'md' | 'lg' | 'xl' } export function Modal({ isOpen, onClose, title, children, footer, size = 'md' }: ModalProps) { // Close on Escape key const handleKeyDown = useCallback( (e: KeyboardEvent) => { if (e.key === 'Escape') { onClose() } }, [onClose] ) useEffect(() => { if (isOpen) { document.addEventListener('keydown', handleKeyDown) document.body.style.overflow = 'hidden' } return () => { document.removeEventListener('keydown', handleKeyDown) document.body.style.overflow = '' } }, [isOpen, handleKeyDown]) if (!isOpen) return null const sizeClasses = { sm: 'max-w-sm', md: 'max-w-md', lg: 'max-w-full sm:max-w-lg', xl: 'max-w-full sm:max-w-4xl', } return (