@extends('admin.layout')
@section('title','Registrations')
@section('page_title','Registrations')

@section('content')
<div class="card">
    <div class="card-header">
        <form class="form-row align-items-center" method="GET">
            <div class="col-md-4 mb-2">
                <input type="text" name="q" value="{{ request('q') }}" class="form-control" placeholder="Search name, city, contact…">
            </div>
            <div class="col-md-3 mb-2">
                <select name="category" class="form-control">
                    <option value="">All Categories</option>
                    <option value="Beauty Pageant" @selected(request('category')=='Beauty Pageant')>Beauty Pageant</option>
                    <option value="Fashion Show" @selected(request('category')=='Fashion Show')>Fashion Show</option>
                </select>
            </div>
            <div class="col-md-3 mb-2">
                <select name="status" class="form-control">
                    <option value="">All Statuses</option>
                    @foreach(['pending','shortlisted','approved','rejected'] as $s)
                        <option value="{{ $s }}" @selected(request('status')==$s)>{{ ucfirst($s) }}</option>
                    @endforeach
                </select>
            </div>
            <div class="col-md-2 mb-2">
                <button class="btn btn-gold btn-block">Filter</button>
            </div>
        </form>
    </div>
    <div class="card-body table-responsive p-0">
        <table class="table table-hover text-nowrap mb-0">
            <thead>
                <tr><th>#</th><th>Name</th><th>Age</th><th>Category</th><th>City</th><th>Contact</th><th>Status</th><th>Date</th><th></th></tr>
            </thead>
            <tbody>
            @forelse($registrations as $r)
                <tr>
                    <td>{{ $r->id }}</td>
                    <td class="font-weight-bold">{{ $r->name }}</td>
                    <td>{{ $r->age }}</td>
                    <td>{{ $r->category }}</td>
                    <td>{{ $r->city ?: '—' }}</td>
                    <td>{{ $r->contact }}</td>
                    <td><span class="badge badge-{{ $r->status=='approved'?'success':($r->status=='rejected'?'danger':($r->status=='shortlisted'?'info':'warning')) }}">{{ ucfirst($r->status) }}</span></td>
                    <td class="text-muted small">{{ $r->created_at->format('d M Y') }}</td>
                    <td>
                        <a href="{{ route('admin.registrations.show',$r) }}" class="btn btn-sm btn-info"><i class="fas fa-eye"></i></a>
                        <form action="{{ route('admin.registrations.destroy',$r) }}" method="POST" class="d-inline" onsubmit="return confirm('Delete this registration?')">
                            @csrf @method('DELETE')
                            <button class="btn btn-sm btn-danger"><i class="fas fa-trash"></i></button>
                        </form>
                    </td>
                </tr>
            @empty
                <tr><td colspan="9" class="text-center text-muted py-4">No registrations found.</td></tr>
            @endforelse
            </tbody>
        </table>
    </div>
    <div class="card-footer">{{ $registrations->links() }}</div>
</div>
@endsection
