import { Head, Link, usePage } from '@inertiajs/react';
import {
    ArrowDownToLine,
    ArrowRight,
    Banknote,
    Check,
    Eye,
    EyeOff,
    HandCoins,
    History,
    Inbox,
    PiggyBank,
    Plus,
    Send,
    ShieldAlert,
    ShieldCheck,
    TrendingUp,
} from 'lucide-react';
import type { LucideIcon } from 'lucide-react';
import { useEffect, useState } from 'react';
import CopyButton from '@/components/member/copy-button';
import DepositDialog from '@/components/member/deposit-dialog';
import ProgressBar from '@/components/member/progress-bar';
import StatusBadge from '@/components/member/status-badge';
import TransactionList from '@/components/member/transaction-list';
import { useBalanceVisibility } from '@/hooks/use-balance-visibility';
import { formatDate, formatNaira } from '@/lib/format';
import { cn } from '@/lib/utils';
import { dashboard } from '@/routes';
import {
    calculator as financingCalculator,
    create as financingCreate,
    index as financingIndex,
    show as financingShow,
} from '@/routes/financing';
import { show as kycShow } from '@/routes/kyc';
import {
    create as savingsCreate,
    index as savingsIndex,
    show as savingsShow,
} from '@/routes/savings';
import { index as transactionsIndex } from '@/routes/transactions';
import { create as transfersCreate } from '@/routes/transfers';
import type { SavingsPlanItem, TransactionItem } from '@/types';

type MonthActivity = {
    month: string;
    label: string;
    moneyIn: number;
    moneyOut: number;
};

type FinancingSummary = {
    id: number;
    reference: string;
    status: 'pending' | 'active';
    outstanding: number;
    instalmentCount: number;
    paidCount: number;
    nextInstalment: {
        dueDate: string;
        amount: number;
        isOverdue: boolean;
    } | null;
} | null;

type KycRequirement = {
    key: string;
    label: string;
    state: 'approved' | 'pending' | 'rejected' | 'missing';
};

type Props = {
    wallet: { accountNumber: string; balance: number };
    savings: {
        total: number;
        targetTotal: number;
        savedTowardTargets: number;
        activeCount: number;
        nextAutoSave: { date: string; amount: number; planName: string } | null;
        plans: SavingsPlanItem[];
    };
    financing: FinancingSummary;
    kycStatus: 'unverified' | 'pending' | 'verified' | 'rejected';
    kycRequirements: KycRequirement[];
    activity: MonthActivity[];
    recentTransactions: TransactionItem[];
};

const cardClasses = 'rounded-landing-lg border border-surface-200 bg-white';
const linkClasses =
    'inline-flex items-center gap-1 text-sm font-semibold text-brand hover:text-highlight-dark';

function greetingFor(hour: number): string {
    if (hour < 12) {
        return 'Good morning';
    }

    return hour < 17 ? 'Good afternoon' : 'Good evening';
}

const todayFormatter = new Intl.DateTimeFormat('en-NG', {
    weekday: 'long',
    day: 'numeric',
    month: 'long',
    year: 'numeric',
});

const walletPillClasses =
    'inline-flex items-center gap-1.5 rounded-landing bg-white/10 px-2.5 py-1 text-xs font-semibold text-white/90 ring-1 ring-white/15 transition-colors hover:bg-white/20 hover:text-white focus-visible:ring-2 focus-visible:ring-highlight focus-visible:outline-none';

const quickActionClasses =
    'flex min-h-14 flex-col items-center justify-center gap-1 rounded-landing px-1.5 py-2 text-center ring-1 ring-white/10 transition-colors';

const quickActionLiveClasses =
    'bg-white/9 text-white hover:bg-white/16 focus-visible:ring-2 focus-visible:ring-highlight focus-visible:outline-none';

function QuickAction({
    icon: Icon,
    label,
    href,
}: {
    icon: LucideIcon;
    label: string;
    href?: ReturnType<typeof savingsIndex>;
}) {
    const content = (
        <>
            <Icon className="size-4" />
            <span className="text-xs font-semibold">{label}</span>
            {!href && (
                <span className="rounded-full bg-white/10 px-1.5 text-[9px] leading-4 font-semibold text-white/60">
                    Soon
                </span>
            )}
        </>
    );

    return href ? (
        <Link
            href={href}
            className={cn(quickActionClasses, quickActionLiveClasses)}
        >
            {content}
        </Link>
    ) : (
        <div
            aria-disabled="true"
            className={cn(quickActionClasses, 'bg-white/4 text-white/50')}
        >
            {content}
        </div>
    );
}

function StatCard({
    title,
    icon: Icon,
    tone,
    children,
    footer,
}: {
    title: string;
    icon: LucideIcon;
    tone: string;
    children: React.ReactNode;
    footer?: React.ReactNode;
}) {
    return (
        <section
            className={cn(
                cardClasses,
                'flex items-center gap-3 p-3.5 shadow-landing-sm sm:p-4',
            )}
        >
            <div className="min-w-0 flex-1">
                <h2 className="text-[11px] font-semibold tracking-widest text-ink-400 uppercase">
                    {title}
                </h2>
                <div className="mt-1.5">{children}</div>
                {footer && <div className="mt-2.5">{footer}</div>}
            </div>
            <span
                className={cn(
                    'flex size-10 shrink-0 items-center justify-center rounded-landing sm:size-11',
                    tone,
                )}
            >
                <Icon className="size-5" />
            </span>
        </section>
    );
}

function ActivityChart({
    activity,
    emptyAction,
}: {
    activity: MonthActivity[];
    emptyAction?: React.ReactNode;
}) {
    const totalIn = activity.reduce((sum, month) => sum + month.moneyIn, 0);
    const totalOut = activity.reduce((sum, month) => sum + month.moneyOut, 0);
    const net = totalIn - totalOut;

    const peak = Math.max(
        1,
        ...activity.flatMap((month) => [month.moneyIn, month.moneyOut]),
    );
    const hasData = activity.some(
        (month) => month.moneyIn > 0 || month.moneyOut > 0,
    );

    return (
        <section className={cn(cardClasses, 'p-4')}>
            <div className="flex flex-wrap items-start justify-between gap-3">
                <div>
                    <h2 className="font-display text-base font-semibold text-ink">
                        Money in and out
                    </h2>
                    <p className="text-sm text-ink-400">Last 6 months</p>
                </div>
                <div className="flex gap-4 text-xs text-ink-500">
                    <span className="flex items-center gap-1.5">
                        <span className="size-2.5 rounded-full bg-highlight" />
                        Money in
                    </span>
                    <span className="flex items-center gap-1.5">
                        <span className="size-2.5 rounded-full bg-brand" />
                        Money out
                    </span>
                </div>
            </div>

            <dl className="mt-3 grid grid-cols-3 gap-2 rounded-landing bg-surface-50 p-2.5 text-center sm:gap-3">
                <div className="min-w-0">
                    <dt className="text-[11px] font-medium text-ink-400">
                        Money in
                    </dt>
                    <dd className="truncate text-sm font-semibold text-highlight-dark tabular-nums">
                        {formatNaira(totalIn)}
                    </dd>
                </div>
                <div className="min-w-0 border-x border-surface-200">
                    <dt className="text-[11px] font-medium text-ink-400">
                        Money out
                    </dt>
                    <dd className="truncate text-sm font-semibold text-ink tabular-nums">
                        {formatNaira(totalOut)}
                    </dd>
                </div>
                <div className="min-w-0">
                    <dt className="text-[11px] font-medium text-ink-400">
                        Net
                    </dt>
                    <dd
                        className={cn(
                            'truncate text-sm font-semibold tabular-nums',
                            net < 0 ? 'text-red-700' : 'text-ink',
                        )}
                    >
                        {net < 0 ? '−' : ''}
                        {formatNaira(Math.abs(net))}
                    </dd>
                </div>
            </dl>

            {hasData ? (
                <div
                    className="mt-3 grid h-28 grid-cols-6 items-end gap-2 sm:h-32 sm:gap-3"
                    role="img"
                    aria-label={`Money in and out over the last six months: ${activity
                        .map(
                            (month) =>
                                `${month.label} in ${formatNaira(month.moneyIn)}, out ${formatNaira(month.moneyOut)}`,
                        )
                        .join('; ')}`}
                >
                    {activity.map((month) => (
                        <div
                            key={month.month}
                            className="flex h-full flex-col items-center gap-2"
                        >
                            <div className="flex w-full flex-1 items-end justify-center gap-1">
                                <div
                                    title={`In: ${formatNaira(month.moneyIn)}`}
                                    className="w-full max-w-4 rounded-t bg-highlight"
                                    style={{
                                        height: `${Math.max(2, (month.moneyIn / peak) * 100)}%`,
                                    }}
                                />
                                <div
                                    title={`Out: ${formatNaira(month.moneyOut)}`}
                                    className="w-full max-w-4 rounded-t bg-brand"
                                    style={{
                                        height: `${Math.max(2, (month.moneyOut / peak) * 100)}%`,
                                    }}
                                />
                            </div>
                            <span className="text-xs text-ink-400">
                                {month.label}
                            </span>
                        </div>
                    ))}
                </div>
            ) : (
                <div className="flex h-28 flex-col items-center justify-center gap-3 text-center sm:h-32">
                    <p className="text-sm text-ink-400">
                        No activity yet. Your monthly totals will appear here.
                    </p>
                    {emptyAction}
                </div>
            )}
        </section>
    );
}

export default function Dashboard({
    wallet,
    savings,
    financing,
    kycStatus,
    kycRequirements,
    activity,
    recentTransactions,
}: Props) {
    const { auth } = usePage().props;
    const [isBalanceHidden, toggleBalance] = useBalanceVisibility();
    const [now, setNow] = useState<Date | null>(null);
    const isVerified = kycStatus === 'verified';
    const approvedRequirements = kycRequirements.filter(
        (requirement) => requirement.state === 'approved',
    ).length;
    const savingsProgress =
        savings.targetTotal > 0
            ? Math.min(
                  100,
                  Math.floor(
                      (savings.savedTowardTargets * 100) / savings.targetTotal,
                  ),
              )
            : 0;
    const depositButton = (
        <DepositDialog
            accountNumber={wallet.accountNumber}
            accountName={auth.user.name}
        >
            <button
                type="button"
                className="inline-flex items-center gap-1.5 rounded-full bg-brand px-4 py-2 text-sm font-semibold text-white hover:bg-brand-hover focus-visible:ring-2 focus-visible:ring-highlight focus-visible:outline-none"
            >
                <ArrowDownToLine className="size-4" />
                Deposit
            </button>
        </DepositDialog>
    );
    const firstName = auth.user.name.trim().split(/\s+/)[0] ?? auth.user.name;

    useEffect(() => setNow(new Date()), []);

    return (
        <>
            <Head title="Dashboard" />

            <div className="flex flex-1 flex-col gap-3 p-3 font-body text-ink sm:gap-4 sm:p-5">
                <header className="flex flex-wrap items-end justify-between gap-4">
                    <div>
                        <p className="text-xs text-ink-400">
                            {now ? todayFormatter.format(now) : ' '}
                        </p>
                        <h1 className="mt-0.5 font-display text-lg font-semibold tracking-[-0.015em] sm:text-xl">
                            {now ? greetingFor(now.getHours()) : 'Hello'},{' '}
                            {firstName}
                        </h1>
                        <p className="mt-1 text-sm text-ink-500">
                            Here's where your money stands today.
                        </p>
                    </div>
                    {isVerified && (
                        <Link
                            href={savingsCreate()}
                            className="inline-flex items-center gap-1.5 rounded-full bg-brand px-3.5 py-1.5 text-sm font-semibold text-white hover:bg-brand-hover"
                        >
                            <Plus className="size-4" />
                            New savings plan
                        </Link>
                    )}
                </header>

                {!isVerified && (
                    <Link
                        href={kycShow()}
                        className="flex items-center gap-3 rounded-landing-lg border border-amber-200 bg-amber-50 px-4 py-2.5 text-amber-900 hover:bg-amber-100"
                    >
                        <ShieldAlert className="size-5 shrink-0" />
                        <span className="flex-1 text-sm">
                            <strong className="font-semibold">
                                {kycStatus === 'pending'
                                    ? 'Your documents are under review.'
                                    : 'Verify your identity'}
                            </strong>{' '}
                            {kycStatus === 'pending'
                                ? 'We will notify you when it is done.'
                                : 'to unlock savings, financing and investments.'}
                        </span>
                        <ArrowRight className="size-4 shrink-0" />
                    </Link>
                )}

                <section
                    aria-label="Wallet"
                    className="relative overflow-hidden rounded-landing-lg bg-linear-to-br from-brand to-brand-dark p-4 text-white shadow-landing sm:p-5"
                >
                    <div
                        aria-hidden="true"
                        className="pointer-events-none absolute -top-24 -right-20 size-72 rounded-full bg-white/5"
                    />
                    <div
                        aria-hidden="true"
                        className="pointer-events-none absolute -right-16 -bottom-28 size-64 rounded-full bg-[radial-gradient(circle,rgb(20_160_152/0.28),transparent_65%)]"
                    />

                    <div className="relative flex items-center justify-between gap-3">
                        <p className="text-sm text-white/75">Account balance</p>
                        <div className="flex shrink-0 gap-1.5 sm:gap-2">
                            <button
                                type="button"
                                onClick={toggleBalance}
                                aria-pressed={isBalanceHidden}
                                className={walletPillClasses}
                            >
                                {isBalanceHidden ? (
                                    <Eye className="size-4" />
                                ) : (
                                    <EyeOff className="size-4" />
                                )}
                                {isBalanceHidden ? 'Show' : 'Hide'}
                            </button>
                            <Link
                                href={transactionsIndex()}
                                className={walletPillClasses}
                            >
                                <History className="size-4" />
                                History
                            </Link>
                        </div>
                    </div>
                    <p className="relative mt-1 font-display text-2xl font-semibold tracking-[-0.02em] wrap-break-word tabular-nums sm:text-3xl">
                        {isBalanceHidden
                            ? '₦ ••••••'
                            : formatNaira(wallet.balance)}
                    </p>

                    <div className="relative mt-3 rounded-landing border border-white/15 bg-white/7 p-3 sm:p-4">
                        <p className="text-[11px] font-semibold tracking-[0.14em] text-white/60 uppercase">
                            Your wallet account
                        </p>
                        <p className="mt-1.5 text-sm font-semibold text-white/90">
                            Smart Save wallet
                        </p>
                        <div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-2">
                            <span className="font-mono text-xl font-semibold tracking-[0.08em] tabular-nums sm:text-2xl">
                                {wallet.accountNumber}
                            </span>
                            <CopyButton
                                value={wallet.accountNumber}
                                label="Copy"
                                className="bg-white/10 text-white ring-1 ring-white/20 hover:bg-white/20"
                            />
                        </div>
                        <p className="mt-1 text-sm text-white/80">
                            {auth.user.name}
                        </p>
                        <p className="mt-2 flex flex-col gap-x-2 gap-y-0.5 text-sm text-white/70 sm:flex-row sm:flex-wrap sm:items-center">
                            {isVerified ? (
                                <span className="inline-flex items-center gap-1 font-medium text-emerald-300">
                                    <Check className="size-3.5" />
                                    Verified
                                </span>
                            ) : (
                                <Link
                                    href={kycShow()}
                                    className="inline-flex items-center gap-1 font-medium text-amber-300 hover:text-amber-200"
                                >
                                    <ShieldAlert className="size-3.5" />
                                    Not verified
                                </Link>
                            )}
                            <span
                                aria-hidden="true"
                                className="hidden sm:inline"
                            >
                                •
                            </span>
                            <span>Bank transfer funding is coming soon</span>
                        </p>
                    </div>

                    <div className="relative mt-3 grid grid-cols-3 gap-2 sm:grid-cols-5">
                        <DepositDialog
                            accountNumber={wallet.accountNumber}
                            accountName={auth.user.name}
                        >
                            <button
                                type="button"
                                className={cn(
                                    quickActionClasses,
                                    quickActionLiveClasses,
                                )}
                            >
                                <ArrowDownToLine className="size-4" />
                                <span className="text-xs font-semibold">
                                    Deposit
                                </span>
                            </button>
                        </DepositDialog>
                        <QuickAction
                            icon={Send}
                            label="Transfer"
                            href={transfersCreate()}
                        />
                        <QuickAction
                            icon={PiggyBank}
                            label="Save"
                            href={savingsIndex()}
                        />
                        <QuickAction
                            icon={HandCoins}
                            label="Financing"
                            href={financingIndex()}
                        />
                        <QuickAction
                            icon={Banknote}
                            label="Loan"
                            href={financingCreate()}
                        />
                    </div>
                </section>

                <div className="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3">
                    <StatCard
                        title="Total savings"
                        icon={PiggyBank}
                        tone="bg-highlight-faint text-highlight-dark"
                        footer={
                            <Link href={savingsIndex()} className={linkClasses}>
                                View plans <ArrowRight className="size-3.5" />
                            </Link>
                        }
                    >
                        <p className="font-display text-xl font-semibold tabular-nums">
                            {formatNaira(savings.total)}
                        </p>
                        <p className="mt-0.5 flex items-center gap-1 truncate text-sm text-highlight-dark">
                            <TrendingUp className="size-3.5 shrink-0" />
                            {savings.activeCount} active{' '}
                            {savings.activeCount === 1 ? 'plan' : 'plans'}
                            {savings.activeCount > 0 &&
                                ` · ${savingsProgress}% of target`}
                        </p>
                    </StatCard>

                    <StatCard
                        title="Active financing"
                        icon={HandCoins}
                        tone="bg-brand-faint text-brand"
                        footer={
                            <Link
                                href={
                                    financing
                                        ? financingShow(financing.id)
                                        : financingIndex()
                                }
                                className={linkClasses}
                            >
                                {financing ? 'View details' : 'See options'}{' '}
                                <ArrowRight className="size-3.5" />
                            </Link>
                        }
                    >
                        <p className="font-display text-xl font-semibold tabular-nums">
                            {formatNaira(
                                financing?.status === 'active'
                                    ? financing.outstanding
                                    : 0,
                            )}
                        </p>
                        <p
                            className={cn(
                                'mt-0.5 truncate text-sm',
                                financing?.nextInstalment?.isOverdue
                                    ? 'text-red-700'
                                    : 'text-ink-400',
                            )}
                        >
                            {financing?.status === 'pending'
                                ? `Application ${financing.reference} under review`
                                : financing?.nextInstalment
                                  ? `${financing.paidCount} of ${financing.instalmentCount} paid · ${financing.nextInstalment.isOverdue ? 'overdue' : 'next'} ${formatDate(financing.nextInstalment.dueDate)}`
                                  : 'Transparent financing'}
                        </p>
                    </StatCard>

                    <StatCard
                        title="Verification"
                        icon={isVerified ? ShieldCheck : ShieldAlert}
                        tone={
                            isVerified
                                ? 'bg-highlight-faint text-highlight-dark'
                                : 'bg-amber-50 text-amber-700'
                        }
                        footer={
                            !isVerified && (
                                <Link href={kycShow()} className={linkClasses}>
                                    {kycStatus === 'pending'
                                        ? 'Check status'
                                        : 'Verify now'}{' '}
                                    <ArrowRight className="size-3.5" />
                                </Link>
                            )
                        }
                    >
                        <StatusBadge
                            tone={
                                isVerified
                                    ? 'success'
                                    : kycStatus === 'rejected'
                                      ? 'failed'
                                      : 'pending'
                            }
                        >
                            {
                                {
                                    verified: 'Verified',
                                    pending: 'Under review',
                                    rejected: 'Action needed',
                                    unverified: 'Not verified',
                                }[kycStatus]
                            }
                        </StatusBadge>
                        <p className="mt-1.5 truncate text-sm text-ink-400">
                            {isVerified
                                ? 'Account fully verified'
                                : `${approvedRequirements} of ${kycRequirements.length} steps approved`}
                        </p>
                    </StatCard>
                </div>

                <div className="grid grid-cols-1 gap-3 sm:gap-4 lg:grid-cols-3">
                    <div className="flex min-w-0 flex-col gap-3 sm:gap-4 lg:col-span-2">
                        <ActivityChart
                            activity={activity}
                            emptyAction={depositButton}
                        />

                        <section className={cn(cardClasses, 'overflow-hidden')}>
                            <div className="flex items-center justify-between px-4 py-3">
                                <h2 className="font-display text-base font-semibold text-ink">
                                    Recent transactions
                                </h2>
                                {recentTransactions.length > 0 && (
                                    <Link
                                        href={transactionsIndex()}
                                        className={linkClasses}
                                    >
                                        View all
                                    </Link>
                                )}
                            </div>
                            {recentTransactions.length === 0 ? (
                                <div className="flex flex-col items-center border-t border-surface-100 px-5 py-6 text-center">
                                    <Inbox className="size-6 text-ink-200" />
                                    <p className="mt-2 text-sm font-medium text-ink-700">
                                        No transactions yet
                                    </p>
                                    <p className="mt-1 max-w-xs text-sm text-ink-400">
                                        Deposits, savings and repayments will
                                        show here.
                                    </p>
                                </div>
                            ) : (
                                <div className="border-t border-surface-100">
                                    <TransactionList
                                        transactions={recentTransactions}
                                    />
                                </div>
                            )}
                        </section>
                    </div>

                    <div className="flex min-w-0 flex-col gap-3 sm:gap-4">
                        <section className={cn(cardClasses, 'p-4')}>
                            <div className="flex items-center justify-between">
                                <h2 className="font-display text-base font-semibold text-ink">
                                    Savings plans
                                </h2>
                                {isVerified && (
                                    <Link
                                        href={savingsCreate()}
                                        className={linkClasses}
                                    >
                                        <Plus className="size-3.5" />
                                        New
                                    </Link>
                                )}
                            </div>
                            {savings.plans.length === 0 ? (
                                <div className="flex flex-col items-center py-5 text-center">
                                    <PiggyBank className="size-6 text-ink-200" />
                                    <p className="mt-2 text-sm text-ink-400">
                                        Start your first savings plan.
                                    </p>
                                    <Link
                                        href={
                                            isVerified
                                                ? savingsCreate()
                                                : kycShow()
                                        }
                                        className="mt-4 inline-flex items-center rounded-full bg-brand px-4 py-2 text-sm font-semibold text-white hover:bg-brand-hover"
                                    >
                                        {isVerified
                                            ? 'Create a plan'
                                            : 'Verify to start'}
                                    </Link>
                                </div>
                            ) : (
                                <ul className="mt-3 grid gap-3">
                                    {savings.plans.map((plan) => (
                                        <li key={plan.id}>
                                            <Link
                                                href={savingsShow(plan.id)}
                                                className="block rounded-landing p-1 hover:bg-surface-50"
                                            >
                                                <div className="flex items-baseline justify-between gap-3">
                                                    <p className="truncate text-sm font-semibold text-ink">
                                                        {plan.name}
                                                    </p>
                                                    <p className="shrink-0 text-xs text-ink-400">
                                                        {plan.progress}%
                                                    </p>
                                                </div>
                                                <p className="mb-2 text-xs text-ink-400">
                                                    {formatNaira(plan.balance)}{' '}
                                                    of{' '}
                                                    {formatNaira(
                                                        plan.targetAmount,
                                                    )}
                                                </p>
                                                <ProgressBar
                                                    value={plan.progress}
                                                    label={`${plan.name} progress`}
                                                />
                                                <p className="mt-1.5 text-xs text-ink-400">
                                                    {formatNaira(
                                                        plan.contributionAmount,
                                                    )}{' '}
                                                    {plan.frequencyLabel.toLowerCase()}
                                                    {plan.autoDebit &&
                                                    plan.nextDebitOn
                                                        ? ` · next ${formatDate(plan.nextDebitOn)}`
                                                        : ` · matures ${formatDate(plan.maturityDate)}`}
                                                </p>
                                            </Link>
                                        </li>
                                    ))}
                                </ul>
                            )}
                        </section>

                        {!financing && (
                            <section className="rounded-landing-lg bg-linear-to-br from-brand to-brand-dark p-4 text-white">
                                <span className="flex size-8 items-center justify-center rounded-landing-sm bg-white/10 text-highlight">
                                    <HandCoins className="size-4" />
                                </span>
                                <h2 className="mt-3 font-display text-base font-semibold">
                                    Need financing?
                                </h2>
                                <p className="mt-1 text-sm leading-relaxed text-white/70">
                                    Transparent Murabaha, Ijarah, Musharakah and
                                    Qard Hasan financing for equipment, stock
                                    and emergencies.
                                </p>
                                <Link
                                    href={
                                        isVerified
                                            ? financingCreate()
                                            : kycShow()
                                    }
                                    className="mt-4 flex w-full items-center justify-center rounded-full bg-highlight px-4 py-2.5 text-sm font-semibold text-white hover:bg-highlight-dark focus-visible:ring-2 focus-visible:ring-white focus-visible:outline-none"
                                >
                                    {isVerified
                                        ? 'Apply now'
                                        : 'Verify to apply'}
                                </Link>
                                <Link
                                    href={financingCalculator()}
                                    className="mt-2 flex items-center justify-center gap-1 text-sm font-medium text-white/80 hover:text-white"
                                >
                                    Estimate my repayments{' '}
                                    <ArrowRight className="size-3.5" />
                                </Link>
                            </section>
                        )}
                    </div>
                </div>
            </div>
        </>
    );
}

Dashboard.layout = {
    breadcrumbs: [
        {
            title: 'Dashboard',
            href: dashboard(),
        },
    ],
};
