@extends('layouts.admin')

@section('title', 'Games')

@section('content')
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h3 mb-0">Games</h1>
    <a href="{{ route('admin.games.create') }}" class="btn btn-primary">Add Game</a>
</div>

<div class="table-responsive">
    <table class="table table-dark table-striped align-middle">
        <thead>
            <tr>
                <th>Name</th>
                <th>Slug</th>
                <th>Status</th>
                <th>Players</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @forelse($games as $game)
                <tr>
                    <td>{{ $game->name }}</td>
                    <td><code>{{ $game->slug }}</code></td>
                    <td>{{ $game->status->label() }}</td>
                    <td>{{ $game->player_game_profiles_count }}</td>
                    <td class="text-end">
                        <a href="{{ route('admin.games.edit', $game) }}" class="btn btn-sm btn-outline-light">Edit</a>
                        <form action="{{ route('admin.games.destroy', $game) }}" method="POST" class="d-inline" onsubmit="return confirm('Delete this game?')">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-sm btn-outline-danger">Delete</button>
                        </form>
                    </td>
                </tr>
            @empty
                <tr>
                    <td colspan="5" class="text-muted">No games yet.</td>
                </tr>
            @endforelse
        </tbody>
    </table>
</div>

{{ $games->links() }}
@endsection
