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

@section('content')
<div class="row">
    <div class="col-lg-3 col-6">
        <div class="small-box bg-gold">
            <div class="inner"><h3>{{ $stats['total_registrations'] }}</h3><p>Total Registrations</p></div>
            <div class="icon"><i class="fas fa-users"></i></div>
            <a href="{{ route('admin.registrations.index') }}" class="small-box-footer">View all <i class="fas fa-arrow-circle-right"></i></a>
        </div>
    </div>
    <div class="col-lg-3 col-6">
        <div class="small-box bg-warning">
            <div class="inner"><h3>{{ $stats['pending'] }}</h3><p>Pending Review</p></div>
            <div class="icon"><i class="fas fa-hourglass-half"></i></div>
            <a href="{{ route('admin.registrations.index', ['status'=>'pending']) }}" class="small-box-footer">View <i class="fas fa-arrow-circle-right"></i></a>
        </div>
    </div>
    <div class="col-lg-3 col-6">
        <div class="small-box bg-info">
            <div class="inner"><h3>{{ $stats['pageant'] }}</h3><p>Beauty Pageant</p></div>
            <div class="icon"><i class="fas fa-crown"></i></div>
            <a href="{{ route('admin.registrations.index', ['category'=>'Beauty Pageant']) }}" class="small-box-footer">View <i class="fas fa-arrow-circle-right"></i></a>
        </div>
    </div>
    <div class="col-lg-3 col-6">
        <div class="small-box bg-secondary">
            <div class="inner"><h3>{{ $stats['fashion'] }}</h3><p>Fashion Show</p></div>
            <div class="icon"><i class="fas fa-shirt"></i></div>
            <a href="{{ route('admin.registrations.index', ['category'=>'Fashion Show']) }}" class="small-box-footer">View <i class="fas fa-arrow-circle-right"></i></a>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-7">
        <div class="card">
            <div class="card-header"><h3 class="card-title">Recent Registrations</h3></div>
            <div class="card-body p-0">
                <table class="table table-striped mb-0">
                    <thead><tr><th>Name</th><th>Category</th><th>City</th><th>Status</th><th></th></tr></thead>
                    <tbody>
                    @forelse($recentRegistrations as $r)
                        <tr>
                            <td>{{ $r->name }}</td>
                            <td>{{ $r->category }}</td>
                            <td>{{ $r->city ?: '—' }}</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><a href="{{ route('admin.registrations.show',$r) }}" class="btn btn-sm btn-default">View</a></td>
                        </tr>
                    @empty
                        <tr><td colspan="5" class="text-center text-muted py-3">No registrations yet.</td></tr>
                    @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="col-lg-5">
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h3 class="card-title">Recent Messages</h3>
                <span class="badge badge-danger">{{ $stats['unread_messages'] }} unread</span>
            </div>
            <div class="card-body p-0">
                <ul class="list-group list-group-flush">
                @forelse($recentMessages as $m)
                    <li class="list-group-item">
                        <a href="{{ route('admin.messages.show',$m) }}" class="font-weight-bold text-dark">{{ $m->name }}</a>
                        @unless($m->is_read)<span class="badge badge-danger ml-1">new</span>@endunless
                        <div class="text-muted small text-truncate">{{ $m->message }}</div>
                    </li>
                @empty
                    <li class="list-group-item text-center text-muted">No messages yet.</li>
                @endforelse
                </ul>
            </div>
        </div>
    </div>
</div>
@endsection
