import { createFileRoute } from "@tanstack/react-router";
import { Link2 } from "lucide-react";
import { LobbyShell, PageTitle, useToast, card } from "@/components/lotus/LobbyShell";

export const Route = createFileRoute("/invite")({
  head: () => ({
    meta: [
      { title: "Invite & Earn Cash – Lotus365 Demo" },
      { name: "description", content: "Share your Lotus365 referral code and earn ₹10 for every friend who joins." },
      { property: "og:title", content: "Invite & Earn Cash – Lotus365" },
      { property: "og:description", content: "Get ₹10 bonus for every friend who joins." },
      { property: "og:type", content: "website" },
      { name: "twitter:card", content: "summary" },
    ],
  }),
  component: InvitePage,
});

const CODE = "ZF483985";

function InvitePage() {
  const toast = useToast();
  const copy = (text: string, label: string) => { navigator.clipboard?.writeText(text).catch(() => {}); toast.show(`${label} copied!`); };
  return (
    <LobbyShell>
      {toast.node}
      <PageTitle a="INVITE &" b="EARN CASH" sub="Get ₹10 bonus for every friend who joins!" />
      <div className="mt-4 grid grid-cols-2 gap-2.5 px-3">
        <div className={`${card} py-5 text-center`}><p className="text-2xl font-extrabold">0</p><p className="mt-1 text-[10px] font-bold text-muted-foreground">FRIENDS JOINED</p></div>
        <div className={`${card} py-5 text-center`}><p className="text-2xl font-extrabold text-pill-blue">₹0.00</p><p className="mt-1 text-[10px] font-bold text-muted-foreground">TOTAL BONUS</p></div>
      </div>
      <div className={`mx-3 mt-3 flex items-center justify-between ${card} p-3`}>
        <div><p className="text-[10px] font-bold text-muted-foreground">YOUR REFERRAL CODE</p><p className="mt-1 text-xl font-extrabold tracking-wider text-gold">{CODE}</p></div>
        <button onClick={() => copy(CODE, "Referral code")} className="rounded-md bg-gold px-4 py-2 text-xs font-extrabold text-gold-foreground active:scale-95">COPY CODE</button>
      </div>
      <button onClick={() => copy(`${location.origin}/?ref=${CODE}`, "Invite link")} className="mx-3 mt-3 flex w-[calc(100%-1.5rem)] items-center justify-center gap-2 rounded-lg bg-gold py-3.5 text-xs font-extrabold text-gold-foreground active:scale-[.98]">
        <Link2 className="size-4" /> COPY INVITE LINK
      </button>
      <p className="px-3 pt-6 text-[11px] font-bold text-muted-foreground">RECENT REFERRALS</p>
      <div className={`mx-3 mt-3 ${card} py-4 text-center text-xs text-foreground/90`}>No referrals yet. Share your code to earn bonuses!</div>
    </LobbyShell>
  );
}
