import { Badge, Btn, cn } from "@/pages/app/components/ui";

export interface BlockingItem {
  icon: string;
  title: string;
  badgeLabel: string;
  badgeTone: "warn" | "danger" | "neutral";
}

/**
 * "لا يمكن حذف حسابك حاليًا" — blocking-items modal shown instead of the plain
 * delete confirmation when the investor still has unfinished deals, unpaid
 * commitments, or an open dispute.
 *
 * Visual language matches the existing delete-account confirmation modal:
 * white card, 24px radius, centered circular icon, bold centered title,
 * gray centered body, off-white (#F7F7F4) inner surfaces, stacked buttons.
 * Nothing here is destructive, so a soft-yellow warning tone is used (no red icon).
 */
export default function DeleteBlockedModal({
  items,
  body,
  primaryLabel,
  onPrimary,
  onDismiss,
  helperText = "الطلبات الملغاة أو المرفوضة أو المكتملة لا تمنع الحذف.",
}: {
  items: BlockingItem[];
  body: string;
  primaryLabel: string;
  onPrimary: () => void;
  onDismiss: () => void;
  helperText?: string;
}) {
  return (
    <div className="w-full max-w-[344px] max-h-[calc(100dvh-3rem)] overflow-y-auto no-scrollbar rounded-[24px] bg-background-100 p-6">
      {/* Warning icon — soft yellow circle, no red */}
      <div className="w-16 h-16 rounded-full bg-secondary-100 flex items-center justify-center mx-auto mb-4">
        <i className="ri-alert-line text-[30px] text-secondary-800 leading-none" />
      </div>

      <h3 className="text-[17px] font-bold text-foreground-950 text-center leading-relaxed">
        لا يمكن حذف حسابك حاليًا
      </h3>
      <p className="text-[12.5px] text-foreground-600 text-center mt-2 leading-relaxed">{body}</p>

      {/* Blocking items block — off-white surface, 16px radius */}
      <div className="mt-5 rounded-[16px] bg-background-50 border border-background-200 overflow-hidden">
        <div className="px-4 pt-3.5 pb-3">
          <h4 className="text-[13px] font-bold text-foreground-950">
            العناصر المعلّقة ({items.length})
          </h4>
        </div>
        <div className="border-t border-background-200 divide-y divide-background-200">
          {items.map((item) => (
            <button
              key={item.title}
              type="button"
              className="w-full px-3.5 py-3 flex items-start gap-3 text-right cursor-pointer hover:bg-background-100 transition-colors"
            >
              <span className="w-9 h-9 rounded-[10px] bg-background-100 border border-background-200 flex items-center justify-center shrink-0">
                <i className={cn(item.icon, "text-[18px] text-foreground-950 leading-none")} />
              </span>
              <span className="flex-1 min-w-0">
                <span className="block text-[13px] font-semibold text-foreground-950 leading-snug">
                  {item.title}
                </span>
                <Badge tone={item.badgeTone} className="mt-1.5">
                  {item.badgeLabel}
                </Badge>
              </span>
              <i className="ri-arrow-left-s-line text-[20px] text-foreground-400 leading-none shrink-0 mt-1" />
            </button>
          ))}
        </div>
      </div>

      {/* Stacked buttons */}
      <div className="mt-5 flex flex-col gap-2.5">
        <Btn full onClick={onPrimary}>
          {primaryLabel}
        </Btn>
        <Btn variant="secondary" full onClick={onDismiss}>
          حسنًا
        </Btn>
      </div>

      <p className="text-[11px] text-foreground-500 text-center mt-4 leading-relaxed">{helperText}</p>
    </div>
  );
}