import { useEffect } from 'react' import { createPortal } from 'react-dom' import { X, AlertTriangle } from 'lucide-react' import { useLanguage } from '../i18n/LanguageContext' export default function Modal({ isOpen, onClose, title, children, size = 'md', // Confirmation mode props isConfirm = false, confirmText, cancelText, onConfirm, danger = false, }) { const { t } = useLanguage() // Default translations const finalConfirmText = confirmText || (danger ? t('common.delete') : t('common.save')) const finalCancelText = cancelText || t('common.cancel') useEffect(() => { if (isOpen) { document.body.style.overflow = 'hidden' } else { document.body.style.overflow = '' } return () => { document.body.style.overflow = '' } }, [isOpen]) if (!isOpen) return null const sizeClasses = { sm: 'max-w-md', md: 'max-w-lg', lg: 'max-w-2xl', xl: 'max-w-4xl', } // Confirmation dialog if (isConfirm) { return createPortal(