import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import AppLayout from '@/layouts/app-layout';
import { type BreadcrumbItem } from '@/types';
import { Head } from '@inertiajs/react';
import { Users, BookOpen, ClipboardCheck, MessageSquareWarning, ArrowUpRight } from 'lucide-react';

const breadcrumbs: BreadcrumbItem[] = [
    {
        title: 'Dashboard',
        href: '/dashboard',
    },
];

interface DashboardProps {
    stats: {
        total_users: number;
        total_questions: number;
        total_surveys: number;
        total_reports: number;
    };
}

export default function Dashboard({ stats }: DashboardProps) {
    const statCards = [
        {
            title: 'Total Users',
            value: stats.total_users,
            icon: Users,
            description: 'Registered users on platform',
            color: 'text-blue-600',
            bg: 'bg-blue-100',
        },
        {
            title: 'Total Questions',
            value: stats.total_questions,
            icon: BookOpen,
            description: 'Questions in database',
            color: 'text-purple-600',
            bg: 'bg-purple-100',
        },
        {
            title: 'Total Surveys',
            value: stats.total_surveys,
            icon: ClipboardCheck,
            description: 'Active and inactive surveys',
            color: 'text-green-600',
            bg: 'bg-green-100',
        },
        {
            title: 'Question Reports',
            value: stats.total_reports,
            icon: MessageSquareWarning,
            description: 'Pending user reports',
            color: 'text-red-600',
            bg: 'bg-red-100',
        },
    ];

    return (
        <AppLayout breadcrumbs={breadcrumbs}>
            <Head title="Dashboard" />
            <div className="p-6 space-y-6">
                <div>
                    <h1 className="text-2xl font-bold tracking-tight">Overview</h1>
                    <p className="text-muted-foreground">Welcome back! Here's what's happening today.</p>
                </div>

                <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
                    {statCards.map((card) => (
                        <Card key={card.title} className="border-none shadow-sm overflow-hidden group hover:shadow-md transition-shadow">
                            <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
                                <CardTitle className="text-sm font-medium">{card.title}</CardTitle>
                                <div className={`p-2 rounded-lg ${card.bg}`}>
                                    <card.icon className={`h-4 w-4 ${card.color}`} />
                                </div>
                            </CardHeader>
                            <CardContent>
                                <div className="text-2xl font-bold">{card.value}</div>
                                <p className="text-xs text-muted-foreground mt-1">
                                    {card.description}
                                </p>
                                <div className="mt-4 flex items-center text-xs font-medium text-primary opacity-0 group-hover:opacity-100 transition-opacity">
                                    View details
                                    <ArrowUpRight className="ml-1 h-3 w-3" />
                                </div>
                            </CardContent>
                        </Card>
                    ))}
                </div>
            </div>
        </AppLayout>
    );
}
