'use client';

import React from 'react';
import Modal from '@/components/ui/Modal';
import Button from '@/components/ui/Button';

interface AdminModalProps {
  isOpen: boolean;
  onClose: () => void;
  onSubmit?: () => void;
  title: string;
  children: React.ReactNode;
  submitLabel?: string;
  cancelLabel?: string;
  loading?: boolean;
  size?: 'sm' | 'md' | 'lg' | 'xl';
  danger?: boolean;
}

export default function AdminModal({
  isOpen,
  onClose,
  onSubmit,
  title,
  children,
  submitLabel = 'Guardar',
  cancelLabel = 'Cancelar',
  loading = false,
  size = 'md',
  danger = false,
}: AdminModalProps) {
  return (
    <Modal isOpen={isOpen} onClose={onClose} title={title} size={size}>
      <div className="space-y-6">
        {children}
        <div className="flex items-center justify-end gap-3 pt-4 border-t border-white/5">
          <Button variant="ghost" size="md" onClick={onClose} disabled={loading}>
            {cancelLabel}
          </Button>
          {onSubmit && (
            <Button
              variant={danger ? 'danger' : 'primary'}
              size="md"
              onClick={onSubmit}
              loading={loading}
            >
              {submitLabel}
            </Button>
          )}
        </div>
      </div>
    </Modal>
  );
}
