@extends('layouts.admin')

@section('title', 'Dashboard')

@section('content')
    {{-- Banner Selamat Datang --}}
    <div class="relative w-full rounded-[2rem] bg-gradient-to-r from-primary-600 via-primary-700 to-indigo-900 overflow-hidden shadow-2xl shadow-primary-500/20 mb-10 border border-white/10">
        {{-- Background Dekoratif --}}
        <div class="absolute inset-0 bg-[url('https://www.transparenttextures.com/patterns/cubes.png')] opacity-10 mix-blend-overlay"></div>
        <div class="absolute top-0 right-0 -mr-20 -mt-20 w-72 h-72 rounded-full bg-white/10 blur-3xl mix-blend-overlay"></div>
        <div class="absolute bottom-0 right-40 w-40 h-40 rounded-full bg-blue-400/20 blur-2xl"></div>

        <div class="relative z-10 px-8 py-10 md:py-14 flex flex-col md:flex-row items-center justify-between gap-6">
            <div class="text-white">
                <div class="inline-flex items-center gap-2 px-3 py-1.5 bg-white/10 backdrop-blur-md rounded-full mb-4 border border-white/20">
                    <i class="fas fa-calendar-alt text-primary-200 text-xs"></i>
                    <span class="text-xs font-semibold tracking-wide text-primary-100">{{ now()->translatedFormat('l, d F Y') }}</span>
                </div>
                <h1 class="text-3xl md:text-4xl font-black mb-2 tracking-tight">
                    Selamat Datang, <span class="text-transparent bg-clip-text bg-gradient-to-r from-blue-200 to-indigo-100">{{ auth()->user()->name ?? 'Admin' }}!</span>
                </h1>
                <p class="text-primary-100/80 max-w-lg text-sm md:text-base leading-relaxed">
                    Pantau aktivitas perpustakaan hari ini. Kelola koleksi buku Anda dan berikan pelayanan terbaik bagi anggota.
                </p>
            </div>

            <!-- Jam Digital Sederhana (Opsional & Dekoratif) -->
            <div class="hidden md:flex flex-col items-center justify-center p-5 bg-white/10 backdrop-blur-md border border-white/20 rounded-3xl shadow-lg ring-1 ring-white/10">
                <i class="fas fa-clock text-primary-200 text-3xl mb-2 opacity-80 animate-pulse"></i>
                <div class="text-xs font-bold text-white uppercase tracking-widest bg-primary-900/50 px-3 py-1 rounded-full text-center">
                    Aktivitas<br>Realtime
                </div>
            </div>
        </div>
    </div>

    {{-- Grid Kartu Statistik --}}
    <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 mb-10">
        {{-- Total Buku --}}
        <div class="group bg-white rounded-[1.5rem] p-6 border-0 shadow-lg shadow-gray-200/50 hover:shadow-2xl hover:shadow-primary-500/30 transition-all duration-300 transform hover:-translate-y-2 relative overflow-hidden">
            <div class="absolute -right-6 -top-6 w-24 h-24 rounded-full bg-primary-50 opacity-50 group-hover:scale-150 transition-transform duration-500 ease-out"></div>
            
            <div class="flex items-center justify-between relative z-10 mb-6">
                <div class="w-14 h-14 bg-gradient-to-br from-primary-500 to-primary-600 text-white rounded-2xl flex items-center justify-center shadow-md shadow-primary-200 group-hover:rotate-12 transition-transform duration-300">
                    <i class="fas fa-book text-xl"></i>
                </div>
                <span class="flex items-center gap-1 text-[11px] font-bold text-green-600 bg-green-50 px-3 py-1.5 rounded-full border border-green-100 shadow-sm">
                    <i class="fas fa-check-circle"></i> Sistem
                </span>
            </div>
            
            <div class="relative z-10">
                <p class="text-4xl font-black text-gray-900 tracking-tight">{{ number_format($totalBuku ?? 0) }}</p>
                <p class="text-sm text-gray-400 font-medium mt-1">Total Koleksi Buku</p>
            </div>
        </div>

        {{-- Total Anggota --}}
        <div class="group bg-white rounded-[1.5rem] p-6 border-0 shadow-lg shadow-gray-200/50 hover:shadow-2xl hover:shadow-emerald-500/30 transition-all duration-300 transform hover:-translate-y-2 relative overflow-hidden">
            <div class="absolute -right-6 -top-6 w-24 h-24 rounded-full bg-emerald-50 opacity-50 group-hover:scale-150 transition-transform duration-500 ease-out"></div>
            
            <div class="flex items-center justify-between relative z-10 mb-6">
                <div class="w-14 h-14 bg-gradient-to-br from-emerald-500 to-emerald-600 text-white rounded-2xl flex items-center justify-center shadow-md shadow-emerald-200 group-hover:rotate-12 transition-transform duration-300">
                    <i class="fas fa-users text-xl"></i>
                </div>
                <span class="flex items-center gap-1 text-[11px] font-bold text-green-600 bg-green-50 px-3 py-1.5 rounded-full border border-green-100 shadow-sm">
                    <i class="fas fa-check-circle"></i> Aktif
                </span>
            </div>
            
            <div class="relative z-10">
                <p class="text-4xl font-black text-gray-900 tracking-tight">{{ number_format($totalAnggota ?? 0) }}</p>
                <p class="text-sm text-gray-400 font-medium mt-1">Anggota Terdaftar</p>
            </div>
        </div>

        {{-- Peminjaman Hari Ini --}}
        <div class="group bg-white rounded-[1.5rem] p-6 border-0 shadow-lg shadow-gray-200/50 hover:shadow-2xl hover:shadow-amber-500/30 transition-all duration-300 transform hover:-translate-y-2 relative overflow-hidden">
            <div class="absolute -right-6 -top-6 w-24 h-24 rounded-full bg-amber-50 opacity-50 group-hover:scale-150 transition-transform duration-500 ease-out"></div>
            
            <div class="flex items-center justify-between relative z-10 mb-6">
                <div class="w-14 h-14 bg-gradient-to-br from-amber-500 to-amber-600 text-white rounded-2xl flex items-center justify-center shadow-md shadow-amber-200 group-hover:-rotate-12 transition-transform duration-300">
                    <i class="fas fa-exchange-alt text-xl"></i>
                </div>
                <span class="flex items-center gap-1 text-[11px] font-bold text-amber-600 bg-amber-50 px-3 py-1.5 rounded-full border border-amber-100 shadow-sm">
                    <i class="fas fa-bolt"></i> Hari Ini
                </span>
            </div>
            
            <div class="relative z-10">
                <p class="text-4xl font-black text-gray-900 tracking-tight">{{ number_format($totalPeminjamanHariIni ?? 0) }}</p>
                <p class="text-sm text-gray-400 font-medium mt-1">Sirkulasi Peminjaman</p>
            </div>
        </div>

        {{-- Total Pengunjung/Tamu --}}
        <div class="group bg-white rounded-[1.5rem] p-6 border-0 shadow-lg shadow-gray-200/50 hover:shadow-2xl hover:shadow-purple-500/30 transition-all duration-300 transform hover:-translate-y-2 relative overflow-hidden">
            <div class="absolute -right-6 -top-6 w-24 h-24 rounded-full bg-purple-50 opacity-50 group-hover:scale-150 transition-transform duration-500 ease-out"></div>
            
            <div class="flex items-center justify-between relative z-10 mb-6">
                <div class="w-14 h-14 bg-gradient-to-br from-purple-500 to-purple-600 text-white rounded-2xl flex items-center justify-center shadow-md shadow-purple-200 group-hover:rotate-12 transition-transform duration-300">
                    <i class="fas fa-clipboard-list text-xl"></i>
                </div>
                <span class="flex items-center gap-1 text-[11px] font-bold text-purple-600 bg-purple-50 px-3 py-1.5 rounded-full border border-purple-100 shadow-sm">
                    <i class="fas fa-chart-line"></i> Tercatat
                </span>
            </div>
            
            <div class="relative z-10">
                <p class="text-4xl font-black text-gray-900 tracking-tight">{{ number_format($totalBukuTamu ?? 0) }}</p>
                <p class="text-sm text-gray-400 font-medium mt-1">Total Pengunjung</p>
            </div>
        </div>
    </div>

    {{-- Menu Aksi Cepat / Quick Actions --}}
    <div class="bg-white rounded-[2rem] p-8 shadow-xl shadow-gray-200/40 border border-gray-50 flex flex-col md:flex-row items-center justify-between gap-6 relative overflow-hidden">
        <div class="absolute right-0 bottom-0 w-64 h-64 bg-gradient-to-tl from-gray-50 to-transparent rounded-tl-full opacity-50"></div>
        
        <div class="relative z-10">
            <h3 class="text-xl font-bold text-gray-900 mb-1">Aksi Cepat Admin</h3>
            <p class="text-sm text-gray-500">Akses langsung ke menu-menu operasional paling sering digunakan.</p>
        </div>
        
        <div class="flex flex-wrap items-center gap-3 relative z-10">
            <a href="{{ route('admin.buku.index', ['add' => 'true']) }}" class="px-5 py-2.5 bg-gray-50 hover:bg-primary-50 text-gray-700 hover:text-primary-700 font-semibold rounded-xl border border-gray-200 hover:border-primary-200 transition-all shadow-sm flex items-center gap-2">
                <i class="fas fa-plus text-xs"></i> Tambah Buku Baru
            </a>
            <a href="{{ route('admin.peminjaman.index', ['add' => 'true']) }}" class="px-5 py-2.5 bg-gray-50 hover:bg-amber-50 text-gray-700 hover:text-amber-700 font-semibold rounded-xl border border-gray-200 hover:border-amber-200 transition-all shadow-sm flex items-center gap-2">
                <i class="fas fa-hand-holding-usd text-xs"></i> Catat Peminjaman
            </a>
            <a href="{{ route('admin.laporan.peminjaman') }}" class="px-5 py-2.5 bg-primary-600 hover:bg-primary-700 text-white font-bold rounded-xl shadow-md cursor-pointer transition-colors flex items-center gap-2">
                <i class="fas fa-print text-xs"></i> Cetak Laporan
            </a>
        </div>
    </div>

    {{-- Widget Tambahan: Buku Terpopuler --}}
    <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6 mt-6">
        <h3 class="text-lg font-bold text-gray-900 mb-4 border-b pb-2">Top 5 Buku Terpopuler</h3>
        <ul class="divide-y divide-gray-100">
            @forelse($bukuPopuler as $buku)
            <li class="py-3 flex justify-between items-center">
                <div>
                    <p class="font-bold text-sm text-gray-800">{{ $buku->judul }}</p>
                    <p class="text-xs text-gray-500">{{ $buku->pengarang }}</p>
                </div>
                <span class="bg-blue-100 text-blue-800 text-xs font-bold px-3 py-1 rounded-full">
                    {{ $buku->peminjaman_count }} Peminjaman
                </span>
            </li>
            @empty
            <li class="py-3 text-sm text-gray-500">Belum ada data peminjaman.</li>
            @endforelse
        </ul>
    </div>
@endsection
