import { Head } from '@inertiajs/react';
import PublicLayout from '@/Layouts/PublicLayout';
import Card from '@/Components/UI/Card';
import Button from '@/Components/UI/Button';

interface AlumniSpotlight {
    id: number;
    name: string;
    certification_title: string | null;
    institute: string | null;
    issued_at: string | null;
}

const pathway = [
    { label: 'Enrol', description: 'Join a Professional Certification Programme within any Institute.' },
    { label: 'Complete', description: 'Finish every required course and competency-based assessment.' },
    { label: 'Certify', description: 'Earn your Professional Certification upon capstone approval.' },
    { label: 'Join the Network', description: 'Alumni status and Network access are granted automatically, free of charge.' },
];

export default function Index({
    spotlights,
    stats,
}: {
    spotlights: AlumniSpotlight[];
    stats: { total_alumni: number; certifications_issued: number };
}) {
    return (
        <PublicLayout>
            <Head title="Alumni Network" />

            <section className="mx-auto max-w-5xl px-6 pb-10 pt-16 lg:px-margin-page">
                <p className="text-label-caps text-accent-gold">JGCP Alumni Network</p>
                <h1 className="text-institutional-header mt-4 text-on-surface">A Global Community of Certified Leaders</h1>
                <p className="text-body-lg mt-4 max-w-2xl text-on-surface-variant">
                    Every graduate of a Jolax Global Certification Programme automatically joins the Alumni
                    Network — a free, permanent recognition of achievement, distinct from any future paid
                    membership tier.
                </p>

                <div className="mt-8 flex gap-10">
                    <div>
                        <p className="text-3xl font-semibold text-on-surface">{stats.total_alumni}</p>
                        <p className="text-label-caps text-on-surface-variant">Alumni Members</p>
                    </div>
                    <div>
                        <p className="text-3xl font-semibold text-on-surface">{stats.certifications_issued}</p>
                        <p className="text-label-caps text-on-surface-variant">Certifications Issued</p>
                    </div>
                </div>
            </section>

            <section className="bg-jgcp-navy py-section-gap text-white">
                <div className="mx-auto max-w-5xl px-6 lg:px-margin-page">
                    <h2 className="text-institute-title text-white">From Enrolment to Alumni Status</h2>
                    <div className="mt-10 grid gap-8 md:grid-cols-4">
                        {pathway.map((step, index) => (
                            <div key={step.label}>
                                <div className="flex h-9 w-9 items-center justify-center rounded-full bg-accent-gold text-sm font-semibold text-jgcp-navy">
                                    {index + 1}
                                </div>
                                <p className="mt-3 font-semibold text-white">{step.label}</p>
                                <p className="mt-1 text-sm text-white/60">{step.description}</p>
                            </div>
                        ))}
                    </div>
                </div>
            </section>

            <section className="mx-auto max-w-5xl px-6 py-section-gap lg:px-margin-page">
                <h2 className="text-institute-title text-on-surface">Alumni Spotlight</h2>
                <p className="text-body-md mt-2 max-w-2xl text-on-surface-variant">
                    A showcase of Alumni who have opted in to appear in the public directory.
                </p>

                <div className="mt-8 grid gap-6 md:grid-cols-3">
                    {spotlights.map((alum) => (
                        <Card key={alum.id}>
                            <p className="text-label-caps text-accent-gold">Alumni Member</p>
                            <h3 className="text-course-title mt-2 text-on-surface">{alum.name}</h3>
                            <p className="mt-1 text-sm text-on-surface-variant">{alum.certification_title}</p>
                            <p className="mt-4 text-xs text-on-surface-variant">
                                {alum.institute} · Certified {alum.issued_at}
                            </p>
                        </Card>
                    ))}

                    {spotlights.length === 0 && (
                        <Card className="md:col-span-3">
                            <p className="text-body-md text-on-surface-variant">
                                No Alumni have opted into the public directory yet. Alumni status remains private
                                by default until a graduate chooses to appear here.
                            </p>
                        </Card>
                    )}
                </div>

                <div className="mt-10 text-center">
                    <Button href={route('institutes.index')} variant="primary">
                        Begin Your Path to Certification
                    </Button>
                </div>
            </section>
        </PublicLayout>
    );
}
