import { useApp } from "@/pages/app/AppContext";
import { BackHeader, Badge, Btn } from "@/pages/app/components/ui";
import { fmt } from "@/pages/app/components/biz/BizUI";
import { coinvestments } from "@/mocks/dshnBusiness";
import { bizCoinvestSnapshot } from "@/mocks/dshnBizDeals";
import { bizOpportunities } from "@/mocks/dshnBizOwner";

/** Closed co-investment — awaiting committed investors' payments (sections 2.11 / 2.12). */
export default function BizCoinvestClosed() {
  const { goBack, navigate } = useApp();
  const op = bizOpportunities[0];
  const { collected, target } = bizCoinvestSnapshot;

  return (
    <div className="min-h-full flex flex-col bg-background-50">
      <BackHeader title="الاستثمار التشاركي" onBack={goBack} action={<Badge tone="neutral">مغلقة</Badge>} />

      <div className="flex-1 px-4 py-5 space-y-4">
        <div className="rounded-[20px] bg-background-100 border border-background-200 p-4">
          <p className="text-[14px] font-bold text-foreground-950">{op.category}</p>
          <p className="text-[12px] text-foreground-600 mt-1">مغلقة - بانتظار دفع الملتزمين</p>

          <div className="grid grid-cols-2 gap-2.5 mt-3">
            <div className="rounded-[12px] bg-background-200/70 p-2.5">
              <p className="text-[10px] text-foreground-600">المبلغ المجموع</p>
              <p className="text-[13px] font-bold text-foreground-950 mt-0.5">{fmt(collected)} ر.س</p>
            </div>
            <div className="rounded-[12px] bg-background-200/70 p-2.5">
              <p className="text-[10px] text-foreground-600">المبلغ المستهدف</p>
              <p className="text-[13px] font-bold text-foreground-950 mt-0.5">{fmt(target)} ر.س</p>
            </div>
          </div>

          <div className="mt-3 rounded-[14px] bg-secondary-50 border border-secondary-200 px-3.5 py-3 flex items-center justify-between">
            <span className="text-[11.5px] text-foreground-700">عدد المستثمرين الملتزمين</span>
            <span className="text-[15px] font-bold text-foreground-950">{coinvestments.length}</span>
          </div>
        </div>

        <div className="rounded-[16px] bg-background-100 border border-background-200 p-4 flex items-start gap-2.5">
          <i className="ri-information-line text-[17px] text-foreground-500 leading-none mt-0.5" />
          <p className="text-[11.5px] text-foreground-600 leading-relaxed">
            تابع دفعات المستثمرين وثبّت استلامها بعد التحقق من الإثبات.
          </p>
        </div>
      </div>

      <div className="sticky bottom-0 z-30 px-4 py-4 bg-background-50 border-t border-background-200/70">
        <Btn full onClick={() => navigate("bizCoinvestPayments")}>
          <i className="ri-wallet-3-line text-[17px] leading-none" />
          دفعات المستثمرين
        </Btn>
      </div>
    </div>
  );
}