<x-app-layout>
    <x-slot name="header">
        <h2 class="h4 mb-0">Dashboard Admin Desa</h2>
    </x-slot>

    @if ($landingUrl)
        <div class="card mb-4">
            <div class="card-body d-flex justify-content-between align-items-center flex-wrap gap-3">
                <div>
                    <div class="small text-muted">Link Landing Page Desa Anda</div>
                    <code>{{ $landingUrl }}</code>
                    <div class="mt-2 d-flex gap-2">
                        <button type="button" class="btn btn-sm btn-outline-secondary" onclick="navigator.clipboard.writeText('{{ $landingUrl }}'); Swal.fire({icon:'success', title:'Link disalin', timer:1200, showConfirmButton:false})">
                            Copy Link
                        </button>
                        <a href="{{ $qrCodeUrl }}" download="qr-{{ $desa->slug }}.svg" class="btn btn-sm btn-outline-secondary">
                            Download QR Code
                        </a>
                    </div>
                </div>
                <img src="{{ $qrCodeUrl }}" alt="QR Code {{ $desa->nama }}" style="width: 100px; height: 100px;">
            </div>
        </div>
    @endif

    <div class="row g-3 mb-4">
        <div class="col-md-2-4 col-md-3">
            <div class="card text-center">
                <div class="card-body">
                    <div class="text-muted small">Total Calon</div>
                    <div class="h3">{{ $stats['candidates'] }}</div>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card text-center">
                <div class="card-body">
                    <div class="text-muted small">Total Pemilih</div>
                    <div class="h3">{{ $stats['voters'] }}</div>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card text-center">
                <div class="card-body">
                    <div class="text-muted small">Visitor Hari Ini</div>
                    <div class="h3">{{ $stats['visitors_today'] }}</div>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card text-center">
                <div class="card-body">
                    <div class="text-muted small">Visitor Bulan Ini</div>
                    <div class="h3">{{ $stats['visitors_this_month'] }}</div>
                </div>
            </div>
        </div>
    </div>
</x-app-layout>
