<x-admin-layout>
    <div class="min-h-screen bg-slate-50/50">
        <div class="max-w-6xl mx-auto px-6 sm:px-8 lg:px-10 py-12">

            <!-- Page Header -->
            <div class="mb-12">
                <h1 class="text-3xl font-black text-slate-900 tracking-tight">Vue d'ensemble</h1>
                <p class="text-slate-400 text-sm mt-2 font-medium">Suivi de l'activité de l'association Sénévalls.</p>
            </div>

            <!-- Stats Grid -->
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8 mb-16">

                <!-- Members Stat -->
                <div class="bg-white border border-slate-100 rounded-3xl p-8 shadow-sm hover:shadow-md transition-all hover:-translate-y-0.5 duration-200">
                    <div class="flex items-center justify-between mb-6">
                        <div class="w-12 h-12 rounded-2xl flex items-center justify-center" style="background-color: rgba(16, 185, 129, 0.12);">
                            <svg class="w-6 h-6" style="color: #10b981;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
                            </svg>
                        </div>
                        <span class="text-[11px] font-black uppercase tracking-widest px-3 py-1.5 rounded-full" style="color: #10b981; background-color: rgba(16, 185, 129, 0.08);">Actifs</span>
                    </div>
                    <p class="text-sm font-semibold text-slate-400 uppercase tracking-widest mb-2">Membres inscrits</p>
                    <h2 class="text-5xl font-black text-slate-900 tracking-tight">{{ number_format($totalMembers) }}</h2>
                </div>

                <!-- Projects Stat -->
                <div class="bg-white border border-slate-100 rounded-3xl p-8 shadow-sm hover:shadow-md transition-all hover:-translate-y-0.5 duration-200">
                    <div class="flex items-center justify-between mb-6">
                        <div class="w-12 h-12 rounded-2xl flex items-center justify-center" style="background-color: rgba(251, 191, 36, 0.12);">
                            <svg class="w-6 h-6" style="color: #fbbf24;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
                            </svg>
                        </div>
                        <span class="text-[11px] font-black uppercase tracking-widest px-3 py-1.5 rounded-full" style="color: #d97706; background-color: rgba(251, 191, 36, 0.1);">En cours</span>
                    </div>
                    <p class="text-sm font-semibold text-slate-400 uppercase tracking-widest mb-2">Projets actifs</p>
                    <h2 class="text-5xl font-black text-slate-900 tracking-tight">{{ number_format($activeProjects) }}</h2>
                </div>

                <!-- Contributions Stat -->
                <div class="bg-white border border-slate-100 rounded-3xl p-8 shadow-sm hover:shadow-md transition-all hover:-translate-y-0.5 duration-200">
                    <div class="flex items-center justify-between mb-6">
                        <div class="w-12 h-12 rounded-2xl flex items-center justify-center" style="background-color: rgba(239, 68, 68, 0.1);">
                            <svg class="w-6 h-6" style="color: #ef4444;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                            </svg>
                        </div>
                        <span class="text-[11px] font-black uppercase tracking-widest px-3 py-1.5 rounded-full" style="color: #ef4444; background-color: rgba(239, 68, 68, 0.08);">Total</span>
                    </div>
                    <p class="text-sm font-semibold text-slate-400 uppercase tracking-widest mb-2">Flux de cotisations</p>
                    <h2 class="text-4xl font-black text-slate-900 tracking-tight">{{ \App\Models\Setting::format($totalContributions) }}</h2>
                </div>
            </div>

            <!-- Financial Table Section -->
            <div class="bg-white border border-slate-100 rounded-3xl shadow-sm overflow-hidden">
                <div class="px-8 py-6 border-b border-slate-100 flex items-center justify-between">
                    <div>
                        <h3 class="text-base font-black text-slate-900 uppercase tracking-widest">Flux financier mensuel</h3>
                        <p class="text-xs text-slate-400 mt-1 font-medium">Résumé des 3 derniers mois</p>
                    </div>
                    <div class="w-2 h-2 rounded-full bg-amber-400 animate-pulse"></div>
                </div>

                <div class="overflow-x-auto">
                    <table class="min-w-full">
                        <thead>
                            <tr class="border-b border-slate-100">
                                <th class="px-8 py-4 text-left text-[11px] font-black text-slate-400 uppercase tracking-widest">Période</th>
                                <th class="px-8 py-4 text-center text-[11px] font-black text-slate-400 uppercase tracking-widest">Activités</th>
                                <th class="px-8 py-4 text-right text-[11px] font-black text-slate-400 uppercase tracking-widest">Montant Collecté</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse($last3MonthsData as $data)
                                <tr class="border-b border-slate-50 hover:bg-slate-50/80 transition-colors duration-150">
                                    <td class="px-8 py-5">
                                        <div class="font-bold text-slate-900 uppercase tracking-tight">{{ $data['label'] }}</div>
                                        <div class="text-[11px] text-slate-400 mt-0.5">Journal des opérations</div>
                                    </td>
                                    <td class="px-8 py-5 text-center">
                                        <span class="inline-flex items-center px-4 py-1.5 rounded-full text-[10px] font-black uppercase tracking-widest text-black"
                                            style="background-color: #fbbf24;">
                                            {{ $data['count'] ?? 0 }} TRANS.
                                        </span>
                                    </td>
                                    <td class="px-8 py-5 text-right">
                                        <span class="font-black text-slate-900 text-base tracking-tight">
                                            {{ \App\Models\Setting::format($data['amount']) }}
                                        </span>
                                    </td>
                                </tr>
                            @empty
                                <tr>
                                    <td colspan="3" class="px-8 py-16 text-center text-slate-400 text-sm font-medium">
                                        Aucune donnée enregistrée.
                                    </td>
                                </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>
            </div>

        </div>
    </div>
</x-admin-layout>