<x-app-layout>
    <x-slot name="header">
        <h2 class="h4 mb-0">Impor Data Pemilih (CSV)</h2>
    </x-slot>

    <div class="card" style="max-width: 600px;">
        <div class="card-body">
            <p class="small text-muted">
                Format CSV: kolom <code>nama,nik,tps,rt,rw</code> (header wajib ada di baris pertama).
            </p>

            @if (session('importResult'))
                @php $result = session('importResult'); @endphp
                <div class="alert alert-info">
                    Berhasil impor: {{ $result['imported'] }}, dilewati: {{ $result['skipped'] }}
                    @if (!empty($result['errors']))
                        <ul class="mb-0 small mt-2">
                            @foreach ($result['errors'] as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    @endif
                </div>
            @endif

            <form action="{{ route('admin-desa.voter.import') }}" method="POST" enctype="multipart/form-data">
                @csrf
                <div class="mb-3">
                    <input type="file" name="file" class="form-control" accept=".csv,.txt" required>
                    <x-input-error :messages="$errors->get('file')" class="mt-1" />
                </div>
                <button class="btn btn-primary">Impor</button>
            </form>
        </div>
    </div>
</x-app-layout>
