import { Link } from '@inertiajs/react';
import { ArrowRight, HandCoins, PiggyBank, Sprout } from 'lucide-react';
import type { LucideIcon } from 'lucide-react';
import Reveal from '@/components/landing/reveal';
import SectionHeading from '@/components/landing/section-heading';
import { cn } from '@/lib/utils';
import { register } from '@/routes';

type Product = {
    anchor: string;
    icon: LucideIcon;
    name: string;
    summary: string;
    options: readonly string[];
    callToAction: string;
    isFeatured?: boolean;
};

const products: Product[] = [
    {
        anchor: 'savings',
        icon: PiggyBank,
        name: 'Goal-based savings',
        summary:
            'Set money aside for school fees, Hajj, the next farming season or a rainy day. Automatic contributions keep you consistent without the effort.',
        options: [
            'Wadiah',
            'Mudarabah',
            'Agro Savings',
            'Hajj Fund',
            'Back-to-School',
            'Muqayadah',
            'General',
        ],
        callToAction: 'Start saving',
    },
    {
        anchor: 'financing',
        icon: HandCoins,
        name: 'Transparent financing',
        summary:
            'Get the equipment, vehicle or asset you need at a fixed, agreed price — with a repayment plan built around your income, not a growing interest rate.',
        options: ['Murabaha', 'Musharaka', 'Ijara'],
        callToAction: 'Apply for financing',
        isFeatured: true,
    },
    {
        anchor: 'investments',
        icon: Sprout,
        name: 'Ethical investments',
        summary:
            'Pool your funds with other members in transparent, asset-backed opportunities and share in the profit they actually generate.',
        options: ['Member pools', 'Profit sharing', 'Asset-backed'],
        callToAction: 'Explore investments',
    },
];

export default function ProductsSection() {
    return (
        <section
            id="products"
            aria-labelledby="products-heading"
            className="bg-white px-5 py-20 sm:px-6 lg:px-10 lg:py-28"
        >
            <div className="mx-auto w-full max-w-6xl">
                <SectionHeading
                    id="products-heading"
                    eyebrow="What we offer"
                    title="Everything you need to save, borrow and grow."
                    description="Three simple products, one dashboard — each structured on transparent principles so you always know what you pay and what you earn."
                />

                <ul className="mt-14 grid gap-6 lg:grid-cols-3">
                    {products.map((product, index) => {
                        const Icon = product.icon;
                        const isFeatured = product.isFeatured === true;

                        return (
                            <li
                                key={product.anchor}
                                id={product.anchor}
                                className="scroll-mt-24"
                            >
                                <Reveal
                                    delay={index * 120}
                                    className={cn(
                                        'flex h-full flex-col rounded-landing-xl border p-7 lg:p-8',
                                        isFeatured
                                            ? 'border-brand bg-brand text-white shadow-landing-xl'
                                            : 'border-surface-200 bg-canvas',
                                    )}
                                >
                                    <span
                                        className={cn(
                                            'flex size-12 items-center justify-center rounded-landing',
                                            isFeatured
                                                ? 'bg-white/10 text-highlight'
                                                : 'bg-white text-brand shadow-landing-sm',
                                        )}
                                    >
                                        <Icon
                                            className="size-6"
                                            aria-hidden="true"
                                        />
                                    </span>

                                    <h3
                                        className={cn(
                                            'mt-6 font-display text-2xl font-semibold',
                                            isFeatured
                                                ? 'text-white'
                                                : 'text-ink',
                                        )}
                                    >
                                        {product.name}
                                    </h3>
                                    <p
                                        className={cn(
                                            'mt-3 text-[15px] leading-[1.7]',
                                            isFeatured
                                                ? 'text-white/75'
                                                : 'text-ink-500',
                                        )}
                                    >
                                        {product.summary}
                                    </p>

                                    <ul className="mt-6 flex flex-wrap gap-2">
                                        {product.options.map((option) => (
                                            <li
                                                key={option}
                                                className={cn(
                                                    'rounded-full px-3 py-1 text-xs font-medium',
                                                    isFeatured
                                                        ? 'bg-white/10 text-white/90'
                                                        : 'border border-surface-200 bg-white text-ink-700',
                                                )}
                                            >
                                                {option}
                                            </li>
                                        ))}
                                    </ul>

                                    <Link
                                        href={register()}
                                        className={cn(
                                            'mt-auto inline-flex items-center gap-2 pt-8 text-sm font-semibold transition-colors',
                                            isFeatured
                                                ? 'text-highlight hover:text-white'
                                                : 'text-brand hover:text-highlight-dark',
                                        )}
                                    >
                                        {product.callToAction}
                                        <ArrowRight
                                            className="size-4"
                                            aria-hidden="true"
                                        />
                                    </Link>
                                </Reveal>
                            </li>
                        );
                    })}
                </ul>
            </div>
        </section>
    );
}
