"use client";

import { X, AlertTriangle } from "lucide-react";

interface DeleteAvenantModalProps {
  isOpen: boolean;
  onClose: () => void;
  onConfirm: () => void;
  numeroAvenant: string;
  isDeleting: boolean;
}

export default function DeleteAvenantModal({
  isOpen,
  onClose,
  onConfirm,
  numeroAvenant,
  isDeleting,
}: DeleteAvenantModalProps) {
  if (!isOpen) return null;

  return (
    <div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
      <div className="bg-white rounded-xl shadow-xl max-w-md w-full p-6 space-y-4">
        {/* Header */}
        <div className="flex items-start justify-between">
          <div className="flex items-center gap-3">
            <div className="w-10 h-10 rounded-full bg-red-100 flex items-center justify-center">
              <AlertTriangle className="h-5 w-5 text-red-600" />
            </div>
            <div>
              <h2 className="text-lg font-semibold text-slate-900">
                Supprimer l'avenant
              </h2>
              <p className="text-sm text-slate-600">
                Avenant {numeroAvenant}
              </p>
            </div>
          </div>
          <button
            onClick={onClose}
            disabled={isDeleting}
            className="p-1 hover:bg-slate-100 rounded transition-colors disabled:opacity-50"
          >
            <X className="h-5 w-5 text-slate-500" />
          </button>
        </div>

        {/* Message */}
        <div className="bg-red-50 border border-red-200 rounded-lg p-4">
          <p className="text-sm text-red-800">
            Êtes-vous sûr de vouloir supprimer cet avenant ? Cette action est{" "}
            <strong>irréversible</strong>.
          </p>
          <p className="text-sm text-red-700 mt-2">
            Le PDF associé sera également supprimé du stockage S3.
          </p>
        </div>

        {/* Actions */}
        <div className="flex gap-3">
          <button
            onClick={onClose}
            disabled={isDeleting}
            className="flex-1 px-4 py-2 border border-slate-300 text-slate-700 rounded-lg hover:bg-slate-50 transition-colors disabled:opacity-50"
          >
            Annuler
          </button>
          <button
            onClick={onConfirm}
            disabled={isDeleting}
            className="flex-1 px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
          >
            {isDeleting ? "Suppression..." : "Supprimer"}
          </button>
        </div>
      </div>
    </div>
  );
}
