<x-app-layout>
    <x-slot name="header">
        <div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
            <div>
                <p class="text-xs font-black tracking-widest text-[#15db00] uppercase">SaaS Central Command</p>
                <h2 class="mt-1 font-black text-2xl text-slate-900 tracking-tight leading-tight">
                    {{ __('Dashboard Admin') }}
                </h2>
            </div>
            <div class="text-xs text-slate-700 bg-white px-4 py-2.5 rounded-xl border border-slate-200 font-bold shadow-sm flex items-center gap-2">
                Server Status: <span class="text-[#15db00] font-black animate-pulse flex items-center gap-1.5"><span class="w-2 h-2 rounded-full bg-[#15db00]"></span> Live Platform</span>
            </div>
        </div>
    </x-slot>

    <div class="py-10 bg-slate-100/70 min-h-screen">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-8">

            <!-- Hero Banner -->
            <div class="relative overflow-hidden bg-slate-900 rounded-3xl shadow-xl border border-slate-800">
                <div class="absolute inset-0 bg-gradient-to-br from-[#15db00]/15 via-slate-900 to-indigo-950/40"></div>
                <div class="absolute -top-24 -right-24 w-72 h-72 rounded-full bg-[#15db00]/10 blur-3xl"></div>
                <div class="absolute -bottom-32 -left-16 w-72 h-72 rounded-full bg-indigo-500/10 blur-3xl"></div>
                <div class="relative z-10 p-8 md:p-10">
                    <div class="max-w-3xl">
                        <div class="flex flex-wrap items-center gap-3 mb-4">
                            <span class="inline-flex items-center px-3.5 py-1 rounded-full text-xs font-black bg-[#15db00]/15 text-[#15db00] border border-[#15db00]/30 tracking-wider uppercase">
                                System Overview
                            </span>
                            <span class="inline-flex items-center px-3.5 py-1 rounded-full text-xs font-bold bg-white/5 text-slate-300 border border-white/10 tracking-wider">
                                {{ now()->translatedFormat('l, d F Y') }}
                            </span>
                        </div>
                        <h1 class="text-2xl md:text-3xl font-black text-white tracking-tight leading-tight">
                            Selamat Datang Kembali, <span class="text-transparent bg-clip-text bg-gradient-to-r from-[#15db00] to-emerald-300">{{ Auth::user()->name }}</span> 👋
                        </h1>
                        <p class="mt-3 text-slate-300 leading-relaxed text-sm md:text-base font-medium max-w-2xl">
                            Sistem manajemen database terpusat Anda berjalan optimal. Pantau pertumbuhan pelaku UMKM, kelola data perusahaan, dan pantau arus keuangan dari panel kendali utama ini.
                        </p>
                        <div class="mt-6 flex flex-wrap gap-3">
                            <a href="{{ route('umkm.create') }}" class="inline-flex items-center gap-2 px-5 py-2.5 bg-[#15db00] hover:bg-[#12c400] text-slate-900 text-xs font-black rounded-xl transition-all duration-200 shadow-lg shadow-[#15db00]/25 active:scale-[0.98]">
                                <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
                                </svg>
                                <span>Input Data Baru</span>
                            </a>
                            <a href="{{ route('umkm.index') }}" class="inline-flex items-center gap-2 px-5 py-2.5 bg-white/10 hover:bg-white/20 text-white text-xs font-black rounded-xl border border-white/15 transition-all duration-200 active:scale-[0.98]">
                                <span>Kelola Data UMKM</span>
                                <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" stroke-width="3" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3" />
                                </svg>
                            </a>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Stat Cards -->
            <div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-5">
                <div class="bg-white rounded-2xl p-6 shadow-sm border border-slate-200 relative overflow-hidden group hover:shadow-md transition-shadow duration-300">
                    <div class="absolute top-0 right-0 w-24 h-24 bg-[#15db00]/5 rounded-full blur-2xl group-hover:bg-[#15db00]/10 transition-colors"></div>
                    <div class="relative flex items-start justify-between">
                        <div>
                            <p class="text-xs font-bold tracking-wider text-slate-500 uppercase">Total Data UMKM</p>
                            <p class="mt-2 text-3xl font-black text-slate-900 tracking-tight">{{ number_format($totalUmkm, 0, ',', '.') }}</p>
                            <p class="mt-1.5 text-[11px] font-semibold text-slate-400">Usaha terdaftar di sistem</p>
                        </div>
                        <div class="w-12 h-12 rounded-xl bg-[#15db00]/10 text-[#15db00] flex items-center justify-center shadow-sm">
                            <svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4" />
                            </svg>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-2xl p-6 shadow-sm border border-slate-200 relative overflow-hidden group hover:shadow-md transition-shadow duration-300">
                    <div class="absolute top-0 right-0 w-24 h-24 bg-emerald-500/5 rounded-full blur-2xl group-hover:bg-emerald-500/10 transition-colors"></div>
                    <div class="relative flex items-start justify-between">
                        <div>
                            <p class="text-xs font-bold tracking-wider text-slate-500 uppercase">Total Pemasukan</p>
                            <p class="mt-2 text-3xl font-black text-emerald-600 tracking-tight">{{ $totalPemasukan > 0 ? 'Rp ' . number_format($totalPemasukan, 0, ',', '.') : 'Rp 0' }}</p>
                            <p class="mt-1.5 text-[11px] font-semibold text-slate-400">Total pembayaran user SaaS CASHEV</p>
                        </div>
                        <div class="w-12 h-12 rounded-xl bg-emerald-50 text-emerald-600 flex items-center justify-center shadow-sm">
                            <svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M2.25 8.25c0-1.244 1.008-2.25 2.25-2.25h15c1.242 0 2.25 1.006 2.25 2.25v7.5c0 1.242-1.008 2.25-2.25 2.25h-15c-1.242 0-2.25-1.006-2.25-2.25v-7.5zm0 1.5h19.5m-13.5 4.5h7.5" />
                            </svg>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-2xl p-6 shadow-sm border border-slate-200 relative overflow-hidden group hover:shadow-md transition-shadow duration-300">
                    <div class="absolute top-0 right-0 w-24 h-24 bg-[#15db00]/5 rounded-full blur-2xl group-hover:bg-[#15db00]/10 transition-colors"></div>
                    <div class="relative flex items-start justify-between">
                        <div>
                            <p class="text-xs font-bold tracking-wider text-slate-500 uppercase">Terisi Via Frontend</p>
                            <p class="mt-2 text-3xl font-black text-slate-900 tracking-tight">{{ number_format($terisiFrontend, 0, ',', '.') }}</p>
                            <p class="mt-1.5 text-[11px] font-semibold text-slate-400">Data UMKM dari aplikasi React.js</p>
                        </div>
                        <div class="w-12 h-12 rounded-xl bg-[#15db00]/10 text-[#15db00] flex items-center justify-center shadow-sm">
                            <svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m-18.432 0A8.959 8.959 0 013 12c0-1.605.42-3.113 1.157-4.418" />
                            </svg>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-2xl p-6 shadow-sm border border-slate-200 relative overflow-hidden group hover:shadow-md transition-shadow duration-300">
                    <div class="absolute top-0 right-0 w-24 h-24 bg-amber-500/5 rounded-full blur-2xl group-hover:bg-amber-500/10 transition-colors"></div>
                    <div class="relative flex items-start justify-between">
                        <div>
                            <p class="text-xs font-bold tracking-wider text-slate-500 uppercase">Input Manual</p>
                            <p class="mt-2 text-3xl font-black text-slate-900 tracking-tight">{{ number_format($inputManual, 0, ',', '.') }}</p>
                            <p class="mt-1.5 text-[11px] font-semibold text-slate-400">Data UMKM dari form admin</p>
                        </div>
                        <div class="w-12 h-12 rounded-xl bg-amber-50 text-amber-600 flex items-center justify-center shadow-sm">
                            <svg class="w-6 h-6" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125m-16.5.833v3.75m14.25-3.75v3.75" />
                            </svg>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Main Content Grid -->
            <div class="grid grid-cols-1 xl:grid-cols-3 gap-6">

                <!-- Recent UMKM Table -->
                <div class="xl:col-span-2 bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden">
                    <div class="px-6 py-5 border-b border-slate-100 flex items-center justify-between">
                        <div>
                            <h3 class="font-black text-lg text-slate-900 tracking-tight">Data UMKM Terbaru</h3>
                            <p class="text-xs font-medium text-slate-400 mt-0.5">5 entri terakhir yang masuk ke sistem</p>
                        </div>
                        <a href="{{ route('umkm.index') }}" class="inline-flex items-center gap-1.5 text-xs font-bold text-[#15db00] hover:text-[#12c400] transition-colors">
                            Lihat Semua
                            <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3" />
                            </svg>
                        </a>
                    </div>

                    @if ($recentUmkms->isEmpty())
                        <div class="py-16 px-6 flex flex-col items-center text-center">
                            <div class="w-16 h-16 bg-slate-100 rounded-2xl flex items-center justify-center text-slate-400 mb-4">
                                <svg class="w-8 h-8" fill="none" stroke="currentColor" stroke-width="1.8" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z" />
                                </svg>
                            </div>
                            <h4 class="text-sm font-bold text-slate-900">Belum Ada Data UMKM</h4>
                            <p class="mt-1 text-xs text-slate-500 max-w-sm leading-relaxed">
                                Data yang masuk dari aplikasi React.js atau input manual admin akan tampil di sini.
                            </p>
                            <a href="{{ route('umkm.create') }}" class="mt-5 inline-flex items-center gap-2 px-4 py-2.5 bg-[#15db00] hover:bg-[#12c400] text-slate-900 text-xs font-black rounded-xl transition-all duration-200 shadow-lg shadow-[#15db00]/20 active:scale-[0.98]">
                                <svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
                                </svg>
                                Tambah Data Pertama
                            </a>
                        </div>
                    @else
                        <div class="overflow-x-auto">
                            <table class="min-w-full divide-y divide-slate-100">
                                <thead>
                                    <tr class="bg-slate-50/80">
                                        <th scope="col" class="px-6 py-3 text-left text-[10px] font-black uppercase tracking-wider text-slate-400">Perusahaan</th>
                                        <th scope="col" class="px-6 py-3 text-left text-[10px] font-black uppercase tracking-wider text-slate-400">Jenis Usaha</th>
                                        <th scope="col" class="px-6 py-3 text-left text-[10px] font-black uppercase tracking-wider text-slate-400">Pemilik</th>
                                        <th scope="col" class="px-6 py-3 text-right text-[10px] font-black uppercase tracking-wider text-slate-400">Modal Awal</th>
                                    </tr>
                                </thead>
                                <tbody class="divide-y divide-slate-50">
                                    @foreach ($recentUmkms as $umkm)
                                        <tr class="hover:bg-slate-50/60 transition-colors duration-150">
                                            <td class="px-6 py-4 whitespace-nowrap">
                                                <div class="flex items-center gap-3">
                                                    <div class="w-9 h-9 rounded-lg bg-gradient-to-br from-[#15db00]/15 to-emerald-100 text-[#15db00] flex items-center justify-center text-sm font-black shrink-0">
                                                        {{ strtoupper(substr($umkm->nama_usaha, 0, 1)) }}
                                                    </div>
                                                    <div>
                                                        <p class="text-sm font-bold text-slate-900">{{ $umkm->nama_usaha }}</p>
                                                        <p class="text-[11px] text-slate-400 font-medium">{{ \Illuminate\Support\Str::limit($umkm->alamat, 28) }}</p>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap">
                                                <span class="px-2.5 py-1 inline-flex text-[11px] leading-5 font-bold rounded-full bg-[#15db00]/10 text-emerald-700 border border-[#15db00]/20">
                                                    {{ $umkm->jenis_usaha }}
                                                </span>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-slate-600">{{ $umkm->nama_pemilik }}</td>
                                            <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-black text-slate-900">{{ $umkm->modal_awal > 0 ? 'Rp ' . number_format($umkm->modal_awal, 0, ',', '.') : 'Rp 0' }}</td>
                                        </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    @endif
                </div>

                <!-- Side Panel -->
                <div class="space-y-6">

                    <!-- Quick Actions -->
                    <div class="bg-slate-900 rounded-2xl shadow-sm border border-slate-800 overflow-hidden relative">
                        <div class="absolute inset-0 bg-gradient-to-br from-[#15db00]/10 to-transparent pointer-events-none"></div>
                        <div class="relative px-6 py-5">
                            <h3 class="font-black text-lg text-white tracking-tight">Aksi Cepat</h3>
                            <p class="text-xs font-medium text-slate-400 mt-0.5">Navigasi modul internal admin</p>
                            <div class="mt-5 space-y-3">
                                <a href="{{ route('umkm.index') }}" class="flex items-center justify-between gap-3 p-3.5 rounded-xl bg-white/5 hover:bg-white/10 border border-white/10 transition-all duration-200 group">
                                    <div class="flex items-center gap-3">
                                        <div class="w-9 h-9 rounded-lg bg-[#15db00]/15 text-[#15db00] flex items-center justify-center shrink-0">
                                            <svg class="w-4.5 h-4.5" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4" />
                                            </svg>
                                        </div>
                                        <div>
                                            <p class="text-sm font-bold text-white">Monitoring Data UMKM</p>
                                            <p class="text-[11px] text-slate-400 font-medium">Kelola seluruh records perusahaan</p>
                                        </div>
                                    </div>
                                    <svg class="w-4 h-4 text-slate-500 group-hover:text-[#15db00] group-hover:translate-x-1 transition-all" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3" />
                                    </svg>
                                </a>
                                <a href="{{ route('umkm.create') }}" class="flex items-center justify-between gap-3 p-3.5 rounded-xl bg-white/5 hover:bg-white/10 border border-white/10 transition-all duration-200 group">
                                    <div class="flex items-center gap-3">
                                        <div class="w-9 h-9 rounded-lg bg-indigo-500/15 text-indigo-400 flex items-center justify-center shrink-0">
                                            <svg class="w-4.5 h-4.5" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" />
                                            </svg>
                                        </div>
                                        <div>
                                            <p class="text-sm font-bold text-white">Input Data Manual</p>
                                            <p class="text-[11px] text-slate-400 font-medium">Tambah entri UMKM baru</p>
                                        </div>
                                    </div>
                                    <svg class="w-4 h-4 text-slate-500 group-hover:text-[#15db00] group-hover:translate-x-1 transition-all" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3" />
                                    </svg>
                                </a>
                                <a href="{{ route('profile.edit') }}" class="flex items-center justify-between gap-3 p-3.5 rounded-xl bg-white/5 hover:bg-white/10 border border-white/10 transition-all duration-200 group">
                                    <div class="flex items-center gap-3">
                                        <div class="w-9 h-9 rounded-lg bg-amber-500/15 text-amber-400 flex items-center justify-center shrink-0">
                                            <svg class="w-4.5 h-4.5" fill="none" stroke="currentColor" stroke-width="2.2" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z" />
                                            </svg>
                                        </div>
                                        <div>
                                            <p class="text-sm font-bold text-white">Pengaturan Profil</p>
                                            <p class="text-[11px] text-slate-400 font-medium">Kelola akun administrator</p>
                                        </div>
                                    </div>
                                    <svg class="w-4 h-4 text-slate-500 group-hover:text-[#15db00] group-hover:translate-x-1 transition-all" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3" />
                                    </svg>
                                </a>
                            </div>
                        </div>
                    </div>

                    <!-- System Health -->
                    <div class="bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden">
                        <div class="px-6 py-5 border-b border-slate-100">
                            <h3 class="font-black text-lg text-slate-900 tracking-tight">Kesehatan Sistem</h3>
                        </div>
                        <div class="px-6 py-5 space-y-4">
                            <div class="flex items-center justify-between">
                                <div class="flex items-center gap-2.5">
                                    <span class="w-2 h-2 rounded-full bg-[#15db00] animate-pulse"></span>
                                    <span class="text-sm font-semibold text-slate-700">Layanan Database</span>
                                </div>
                                <span class="text-[11px] font-black text-[#15db00] bg-[#15db00]/10 px-2.5 py-1 rounded-full">Operasional</span>
                            </div>
                            <div class="flex items-center justify-between">
                                <div class="flex items-center gap-2.5">
                                    <span class="w-2 h-2 rounded-full bg-[#15db00] animate-pulse"></span>
                                    <span class="text-sm font-semibold text-slate-700">API Endpoint (React.js)</span>
                                </div>
                                <span class="text-[11px] font-black text-[#15db00] bg-[#15db00]/10 px-2.5 py-1 rounded-full">Online</span>
                            </div>
                            <div class="flex items-center justify-between">
                                <div class="flex items-center gap-2.5">
                                    <span class="w-2 h-2 rounded-full bg-[#15db00] animate-pulse"></span>
                                    <span class="text-sm font-semibold text-slate-700">Sesi Autentikasi Admin</span>
                                </div>
                                <span class="text-[11px] font-black text-[#15db00] bg-[#15db00]/10 px-2.5 py-1 rounded-full">Aktif</span>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

        </div>
    </div>
</x-app-layout>