// components/common/ConfirmDialog.jsx
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faTriangleExclamation, faXmark } from "@fortawesome/free-solid-svg-icons";

export default function ConfirmDialog({
  open,
  title,
  description,
  confirmText = "Onayla",
  cancelText = "İptal",
  danger = false,
  onConfirm,
  onCancel,
}) {
  if (!open) return null;

  return (
    <div className="fixed inset-0 z-50 flex items-center justify-center p-4">
      <div className="absolute inset-0 bg-black/40" onClick={onCancel} />

      <div className="relative w-full max-w-md rounded-3xl border border-black/10 bg-white shadow-2xl">
        <div className="flex items-center justify-between px-6 py-4 border-b border-black/10">
          <div className="flex items-center gap-2">
            {danger && (
              <span className="text-red-600">
                <FontAwesomeIcon icon={faTriangleExclamation} />
              </span>
            )}
            <div className="text-lg font-extrabold text-black/85">{title}</div>
          </div>

          <button
            onClick={onCancel}
            className="h-10 w-10 rounded-2xl border border-black/10 bg-white hover:bg-black/[0.03] transition"
            aria-label="Kapat"
          >
            <FontAwesomeIcon icon={faXmark} />
          </button>
        </div>

        <div className="px-6 py-5 text-sm text-black/60">{description}</div>

        <div className="px-6 pb-6 flex items-center justify-end gap-2">
          <button
            onClick={onCancel}
            className="rounded-2xl border border-black/10 bg-white px-4 py-2.5 text-sm font-semibold text-black/70 hover:bg-black/[0.03] transition"
          >
            {cancelText}
          </button>
          <button
            onClick={onConfirm}
            className={[
              "rounded-2xl px-4 py-2.5 text-sm font-semibold text-white transition active:scale-[0.99]",
              danger
                ? "bg-red-600 hover:bg-red-700"
                : "bg-gradient-to-r from-[#e04a3b] to-[#ff6a5e] hover:brightness-[1.02]",
            ].join(" ")}
          >
            {confirmText}
          </button>
        </div>
      </div>
    </div>
  );
}