import React from 'react';
import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Box, Typography } from '@mui/material';

interface Props {
  open: boolean;
  onClose: () => void;
  onConfirm: () => void;
  title?: string;
  message?: string;
  loading?: boolean;
}

const ConfirmActionModal: React.FC<Props> = ({
  open,
  onClose,
  onConfirm,
  title = 'Are you sure?',
  message = '',
  loading = false
}) => {
  return (
    <Dialog
      open={open}
      onClose={onClose}
      maxWidth="xs"
      fullWidth
      PaperProps={{
        sx: {
          borderRadius: 3,
          p: 3,
          textAlign: 'center'
        }
      }}
    >
      <Box
        sx={{
          width: 64,
          height: 64,
          borderRadius: '50%',
          backgroundColor: '#f3e9fb',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
          margin: '0 auto',
          mb: 2
        }}
      >
        <svg width="64" height="64" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
          <circle cx="12" cy="12" r="12" fill="#fff" fillOpacity="0" />
          <path d="M9 12.5L11.2 14.7L15.5 10.4" stroke="#870099" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      </Box>

      <DialogTitle sx={{ p: 0, fontWeight: 600, fontSize: '1.125rem', mb: 1 }}>{title}</DialogTitle>

      {message && (
        <DialogContent sx={{ p: 0, mb: 2 }}>
          <Typography variant="body1" color="text.secondary">
            {message}
          </Typography>
        </DialogContent>
      )}

      <DialogActions sx={{ justifyContent: 'center', gap: 2, mt: 2, p: 0 }}>
        <Button onClick={onConfirm} variant="contained" sx={{ minWidth: 150, textTransform: 'none', bgcolor: '#870099', color: '#fff', '&:hover': { bgcolor: '#870099' } }} disabled={loading}>
          {loading ? 'Please wait...' : 'Proceed'}
        </Button>
        <Button onClick={onClose} variant="outlined" sx={{ minWidth: 150, textTransform: 'none' }} disabled={loading}>
          Cancel
        </Button>
      </DialogActions>
    </Dialog>
  );
};

export default ConfirmActionModal;
