import React from 'react';
import { AlertTriangle, X } from 'lucide-react';

interface LeaveConfirmModalProps {
  open: boolean;
  onClose: () => void;
  onConfirm: () => void;
}

export function LeaveConfirmModal({ open, onClose, onConfirm }: LeaveConfirmModalProps) {
  if (!open) return null;

  return (
    <div className="vm-modal-backdrop" role="presentation" onClick={onClose}>
      <div
        className="vm-modal vm-modal-sm"
        role="dialog"
        aria-modal="true"
        aria-labelledby="sm-leave-title"
        onClick={(event) => event.stopPropagation()}
      >
        <header className="vm-modal-header">
          <h2 id="sm-leave-title">确认离开</h2>
          <button type="button" className="vm-modal-close" onClick={onClose} aria-label="关闭">
            <X size={18} aria-hidden />
          </button>
        </header>
        <div className="sm-modal-body">
          <div className="sm-modal-alert">
            <AlertTriangle size={18} aria-hidden />
            <div>
              <p>当前表单尚未保存，确定要离开吗？</p>
              <p className="sm-modal-sub">离开后已填写内容将不会保留。</p>
            </div>
          </div>
        </div>
        <footer className="vm-modal-footer">
          <button type="button" className="vm-btn vm-btn-ghost" onClick={onClose}>继续编辑</button>
          <button type="button" className="vm-btn vm-btn-primary" onClick={onConfirm}>确认离开</button>
        </footer>
      </div>
    </div>
  );
}
