@extends('layouts.public')

@section('title', 'Beranda - IPA')

@section('content')
    {{-- Hero --}}
    <section class="relative bg-gradient-to-br from-primary-500 via-primary-600 to-primary-700 text-white overflow-hidden">
        <div class="absolute inset-0 opacity-10">
            <svg class="w-full h-full" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="p" width="40" height="40" patternUnits="userSpaceOnUse"><circle cx="2" cy="2" r="2" fill="white"/></pattern></defs><rect width="100%" height="100%" fill="url(#p)"/></svg>
        </div>
        <div class="container-custom py-20 lg:py-28 relative">
            <div class="max-w-3xl">
                <span class="inline-block px-4 py-1.5 bg-white/20 backdrop-blur rounded-full text-sm font-medium mb-4">Portal Resmi Aset Daerah</span>
                <h1 class="text-4xl lg:text-6xl font-bold leading-tight mb-4">
                    Temukan Aset Daerah untuk Kebutuhan Anda
                </h1>
                <p class="text-lg lg:text-xl text-white/90 mb-8">
                    Informasi lengkap gedung, lapangan, ruko, dan aset daerah lainnya yang bisa dimanfaatkan atau disewa.
                </p>

                <div class="flex flex-col sm:flex-row sm:items-center gap-3 mb-6">
                    <a href="{{ route('assets.index') }}" class="btn-primary">Lihat Daftar Aset</a>
                    <a href="{{ route('map') }}" class="btn-secondary">Lihat Peta Aset</a>
                </div>

                <form action="{{ route('assets.index') }}" method="GET" class="flex flex-col sm:flex-row gap-2 bg-white rounded-3xl p-3 shadow-lg border border-white/30">
                    <input type="text" name="q" placeholder="Cari aset, misal: aula, lapangan, ruko..."
                        class="flex-1 px-4 py-3 border-0 focus:ring-0 text-gray-900 placeholder-gray-400 rounded-lg">
                    <button type="submit" class="btn-primary px-6 py-3">
                        <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
                        </svg>
                        Cari Aset
                    </button>
                </form>
            </div>
        </div>
    </section>

    {{-- Statistik --}}
    <section class="container-custom -mt-12 relative z-10">
        <div class="grid grid-cols-2 lg:grid-cols-4 gap-4">
            @php
                $statItems = [
                    ['label' => 'Total Aset', 'value' => $stats['total_assets'], 'color' => 'primary'],
                    ['label' => 'Aset Tersedia', 'value' => $stats['available_assets'], 'color' => 'green'],
                    ['label' => 'Kategori', 'value' => $stats['total_categories'], 'color' => 'blue'],
                    ['label' => 'OPD Pengelola', 'value' => $stats['total_opds'], 'color' => 'purple'],
                ];
            @endphp
            @foreach($statItems as $item)
                <div class="card p-5">
                    <div class="text-3xl font-bold text-gray-900">{{ number_format($item['value']) }}</div>
                    <div class="text-sm text-gray-500 mt-1">{{ $item['label'] }}</div>
                </div>
            @endforeach
        </div>
    </section>

    {{-- Kategori --}}
    <section class="container-custom py-16">
        <div class="flex items-end justify-between mb-8">
            <div>
                <h2 class="text-3xl font-bold text-gray-900">Kategori Aset</h2>
                <p class="text-gray-500 mt-1">Jelajahi aset berdasarkan kategori</p>
            </div>
        </div>

        <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4">
            @foreach($categories as $category)
                <a href="{{ route('categories.show', $category->slug) }}" class="card p-5 text-center group">
                    <div class="w-14 h-14 mx-auto bg-primary-100 text-primary-600 rounded-xl flex items-center justify-center mb-3 group-hover:bg-primary-500 group-hover:text-white transition-colors">
                        <svg class="w-7 h-7" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/>
                        </svg>
                    </div>
                    <div class="font-semibold text-gray-900">{{ $category->name }}</div>
                    <div class="text-xs text-gray-500 mt-0.5">{{ $category->assets_count }} aset</div>
                </a>
            @endforeach
        </div>
    </section>

    {{-- Aset Unggulan --}}
    @if($featuredAssets->count())
        <section class="container-custom py-12">
            <div class="flex items-end justify-between mb-8">
                <div>
                    <h2 class="text-3xl font-bold text-gray-900">Aset Unggulan</h2>
                    <p class="text-gray-500 mt-1">Pilihan aset terbaik untuk Anda</p>
                </div>
                <a href="{{ route('assets.index') }}" class="hidden sm:block text-primary-600 font-medium hover:underline">Lihat semua &rarr;</a>
            </div>

            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
                @foreach($featuredAssets as $asset)
                    <x-asset-card :asset="$asset" />
                @endforeach
            </div>
        </section>
    @endif

    {{-- Aset Terbaru --}}
    @if($latestAssets->count())
        <section class="container-custom py-12">
            <div class="flex items-end justify-between mb-8">
                <div>
                    <h2 class="text-3xl font-bold text-gray-900">Aset Terbaru</h2>
                    <p class="text-gray-500 mt-1">Aset yang baru saja dipublikasikan</p>
                </div>
                <a href="{{ route('assets.index') }}" class="hidden sm:block text-primary-600 font-medium hover:underline">Lihat semua &rarr;</a>
            </div>

            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5">
                @foreach($latestAssets as $asset)
                    <x-asset-card :asset="$asset" />
                @endforeach
            </div>
        </section>
    @endif
@endsection