<x-filament-panels::page>
    <div class="space-y-6">
        {{-- Main Stats Grid --}}
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
            @foreach ($mainStats as $stat)
                <div
                    class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm p-5 transition hover:shadow-md">
                    <div class="flex flex-col gap-1">
                        <span
                            class="text-xs font-bold text-gray-400 dark:text-gray-500 uppercase tracking-tight">{{ $stat['label'] }}</span>
                        <div class="flex items-baseline gap-1">
                            @if ($stat['prefix'])
                                <span
                                    class="text-sm font-semibold text-gray-400 dark:text-gray-500">{{ $stat['prefix'] }}</span>
                            @endif
                            <span class="text-2xl font-bold text-gray-900 dark:text-white">{{ $stat['value'] }}</span>
                        </div>
                        <span class="text-xs text-gray-400 dark:text-gray-600">{{ $stat['desc'] }}</span>
                    </div>
                </div>
            @endforeach
        </div>

        {{-- Units Breakdown --}}
        <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
            {{-- Production --}}
            <div
                class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm overflow-hidden">
                <div class="px-5 py-3 border-b border-gray-100 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50">
                    <h3 class="text-sm font-bold text-gray-700 dark:text-gray-300">Produksi Telur (By Unit)</h3>
                </div>
                <div class="divide-y divide-gray-100 dark:divide-gray-800">
                    @forelse($totalEggsByUnit as $item)
                        <div
                            class="px-5 py-3 flex justify-between items-center transition hover:bg-gray-50 dark:hover:bg-gray-800/40">
                            <div class="flex flex-col">
                                <span
                                    class="text-sm text-gray-600 dark:text-gray-400 font-medium">{{ $item['unit_name'] }}</span>
                            </div>
                            <div class="flex gap-4">
                                <div class="text-right">
                                    <span class="text-[10px] text-gray-400 font-bold uppercase block">Bagus</span>
                                    <span
                                        class="text-sm font-bold text-emerald-600 dark:text-emerald-400">{{ $item['total_good'] }}</span>
                                </div>
                                <div class="text-right border-l border-gray-100 dark:border-gray-800 pl-4">
                                    <span class="text-[10px] text-gray-400 font-bold uppercase block">Pecah</span>
                                    <span
                                        class="text-sm font-bold text-rose-600 dark:text-rose-400">{{ $item['total_broken'] }}</span>
                                </div>
                            </div>
                        </div>
                    @empty
                        <div class="px-5 py-10 text-center text-gray-400 text-sm">Belum ada data produksi</div>
                    @endforelse
                </div>
            </div>

            {{-- Delayed --}}
            <div
                class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm overflow-hidden">
                <div class="px-5 py-3 border-b border-gray-100 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50">
                    <h3 class="text-sm font-bold text-gray-700 dark:text-gray-300">Barang Tertunda (By Unit)</h3>
                </div>
                <div class="divide-y divide-gray-100 dark:divide-gray-800">
                    @forelse($totalDelayedByUnit as $item)
                        <div
                            class="px-5 py-3 flex justify-between items-center transition hover:bg-gray-50 dark:hover:bg-gray-800/40">
                            <span
                                class="text-sm text-gray-600 dark:text-gray-400 font-medium">{{ $item['unit_name'] }}</span>
                            <span class="text-sm font-bold text-gray-900 dark:text-white">{{ $item['total'] }}</span>
                        </div>
                    @empty
                        <div class="px-5 py-10 text-center text-gray-400 text-sm">Tidak ada barang tertunda</div>
                    @endforelse
                </div>
            </div>
        </div>
    </div>

    <style>
        @import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@200;300;400;500;600;700;800&display=swap');

        :root {
            --fi-page-content-padding: 2rem;
        }

        .fi-section {
            background: transparent !important;
            box-shadow: none !important;
            border: none !important;
        }

        * {
            font-family: 'Plus Jakarta Sans', sans-serif;
        }

        .tracking-tighter {
            letter-spacing: -0.05em;
        }

        .tracking-tight {
            letter-spacing: -0.025em;
        }
    </style>
</x-filament-panels::page>
