@extends('layouts.admin')

@section('title', __('admin.events.title'))

@section('content')
<div class="d-flex justify-content-between align-items-center mb-4">
    <form method="GET" class="d-flex gap-2">
        <input type="search" name="q" value="{{ request('q') }}" class="form-control" placeholder="{{ __('admin.actions.search') }}">
        <button class="btn-arena btn-ghost">{{ __('admin.actions.search') }}</button>
    </form>
    <a href="{{ route('admin.events.create') }}" class="btn-arena btn-primary">{{ __('admin.events.create') }}</a>
</div>

<div class="card-arena overflow-hidden">
    <div class="table-responsive">
        <table class="table table-dark table-hover mb-0">
            <thead>
                <tr>
                    <th>Event</th>
                    <th>Game</th>
                    <th>Status</th>
                    <th>Starts</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @forelse($events as $event)
                    <tr>
                        <td>
                            <div class="fw-600">{{ $event->title }}</div>
                            <div class="fs-xs text-muted">{{ $event->pricing_type->label() }}</div>
                        </td>
                        <td>{{ $event->game?->name }}</td>
                        <td>{{ $event->status->label() }}</td>
                        <td>{{ $event->starts_at?->format('M j, Y H:i') }}</td>
                        <td class="text-end">
                            <a href="{{ route('admin.events.edit', $event) }}" class="btn-arena btn-ghost btn-sm">{{ __('admin.actions.edit') }}</a>
                            <a href="{{ route('admin.events.registrations.index', $event) }}" class="btn-arena btn-ghost btn-sm">{{ __('admin.nav.registrations') }}</a>
                        </td>
                    </tr>
                @empty
                    <tr><td colspan="5" class="text-center py-5 text-muted">{{ __('admin.empty.no_results') }}</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>

<div class="mt-4">{{ $events->links() }}</div>
@endsection
