import React from 'react';
import { CheckCircle, XCircle, BarChart3, TrendingUp, AlertCircle } from 'lucide-react';
import { ModerationAnalytics as ModerationAnalyticsType } from '@/services/AdminService';

interface ModerationAnalyticsProps {
    data: ModerationAnalyticsType;
}

export function ModerationAnalytics({ data }: ModerationAnalyticsProps) {
    return (
        <div className="space-y-6">
            <div className="grid grid-cols-1 md:grid-cols-3 gap-4">
                {/* Processed Stats */}
                <div className="bg-white p-6 rounded-2xl border border-slate-100 shadow-sm">
                    <div className="flex items-center justify-between mb-4">
                        <div className="p-2 bg-blue-50 rounded-lg">
                            <BarChart3 className="w-5 h-5 text-blue-600" />
                        </div>
                        <span className="text-xs font-medium text-slate-400">TODAY</span>
                    </div>
                    <div className="text-3xl font-bold text-slate-900">{data.processedToday}</div>
                    <p className="text-sm text-slate-500 mt-1">Total Jobs Processed</p>
                    <div className="mt-4 flex items-center gap-4 text-sm">
                        <div className="flex items-center gap-1 text-emerald-600">
                            <CheckCircle className="w-4 h-4" /> {data.approvedToday}
                        </div>
                        <div className="flex items-center gap-1 text-red-600">
                            <XCircle className="w-4 h-4" /> {data.rejectedToday}
                        </div>
                    </div>
                </div>

                {/* Rejection Trends */}
                <div className="md:col-span-2 bg-white p-6 rounded-2xl border border-slate-100 shadow-sm">
                    <div className="flex items-center justify-between mb-6">
                        <h3 className="text-sm font-semibold text-slate-700 flex items-center gap-2">
                            <AlertCircle className="w-4 h-4 text-orange-500" />
                            Top Rejection Categories (Last 30 Days)
                        </h3>
                    </div>

                    <div className="space-y-4">
                        {data.rejectionCategories.length > 0 ? (
                            data.rejectionCategories.map((item, idx) => (
                                <div key={idx} className="space-y-1">
                                    <div className="flex justify-between text-xs font-medium">
                                        <span className="text-slate-600 capitalize">{item.category.replace(/_/g, ' ')}</span>
                                        <span className="text-slate-900">{item.count} jobs</span>
                                    </div>
                                    <div className="h-2 w-full bg-slate-100 rounded-full overflow-hidden">
                                        <div
                                            className="h-full bg-orange-400 rounded-full transition-all duration-1000"
                                            style={{ width: `${(item.count / data.rejectedToday) * 100}%` }}
                                        />
                                    </div>
                                </div>
                            ))
                        ) : (
                            <div className="h-[120px] flex items-center justify-center text-sm text-slate-400 italic">
                                No rejection data available for the selected period.
                            </div>
                        )}
                    </div>
                </div>
            </div>

            {/* Throughput Goal (Mockup) */}
            <div className="bg-gradient-to-r from-blue-600 to-indigo-700 rounded-2xl p-6 text-white overflow-hidden relative">
                <div className="relative z-10 flex flex-col md:flex-row md:items-center justify-between gap-6">
                    <div>
                        <h4 className="text-lg font-bold">Moderation Throughput</h4>
                        <p className="text-blue-100 text-sm mt-1">You've processed {data.processedToday} jobs today. Keep up the high quality standards.</p>
                    </div>
                    <div className="flex items-center gap-4">
                        <div className="text-right">
                            <div className="text-2xl font-bold italic">{(data.processedToday / 20 * 100).toFixed(0)}%</div>
                            <div className="text-[10px] uppercase tracking-wider text-blue-200">Daily Target (20)</div>
                        </div>
                        <div className="w-16 h-16 rounded-full border-4 border-white/20 flex items-center justify-center">
                            <TrendingUp className="w-8 h-8 text-blue-100" />
                        </div>
                    </div>
                </div>
                {/* Decorative circles */}
                <div className="absolute -right-10 -bottom-10 w-40 h-40 bg-white/10 rounded-full blur-3xl"></div>
                <div className="absolute -left-10 -top-10 w-40 h-40 bg-white/5 rounded-full blur-2xl"></div>
            </div>
        </div>
    );
}
