import type { ReactNode } from "react";
import { cn } from "@/pages/app/components/ui";

/**
 * A confirmation popup rendered as a dimmed page (normal flow) with a
 * centered card — used for the investor counter-offer confirmations.
 */
export default function ConfirmCard({
  title,
  children,
  confirmLabel,
  cancelLabel,
  confirmTone = "primary",
  onConfirm,
  onCancel,
}: {
  title: string;
  children?: ReactNode;
  confirmLabel: string;
  cancelLabel: string;
  confirmTone?: "primary" | "danger";
  onConfirm: () => void;
  onCancel: () => void;
}) {
  return (
    <div className="absolute inset-0 z-[60] flex items-center justify-center px-6">
      <div onClick={onCancel} className="absolute inset-0 bg-foreground-950/45" />
      <div className="relative w-full max-w-[340px] rounded-[22px] bg-background-50 p-5 animate-fade-in">
        <h3 className="text-[16px] font-bold text-foreground-950 text-center">{title}</h3>
        {children}
        <div className="mt-5 space-y-2.5">
          <button
            type="button"
            onClick={onConfirm}
            className={cn(
              "w-full h-[52px] rounded-[14px] text-[14px] font-semibold cursor-pointer whitespace-nowrap active:scale-[0.98] transition-transform",
              confirmTone === "danger"
                ? "border border-danger-200 bg-danger-50 text-danger-700 hover:bg-danger-100"
                : "bg-primary-500 text-background-50 hover:bg-primary-600",
            )}
          >
            {confirmLabel}
          </button>
          <button
            type="button"
            onClick={onCancel}
            className="w-full h-[52px] rounded-[14px] text-[14px] font-semibold text-foreground-900 border border-background-300 hover:bg-background-200 cursor-pointer whitespace-nowrap"
          >
            {cancelLabel}
          </button>
        </div>
      </div>
    </div>
  );
}