@extends('layouts.admin')

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

@section('content')
<form method="GET" class="card-arena p-4 mb-4">
    <div class="row g-3 align-items-end">
        <div class="col-md-6">
            <label class="form-label">{{ __('admin.actions.search') }}</label>
            <input type="search" name="q" value="{{ request('q') }}" class="form-control" placeholder="{{ __('admin.users.search_placeholder') }}">
        </div>
        <div class="col-md-3">
            <label class="form-label">{{ __('admin.users.filter_status') }}</label>
            <select name="status" class="form-select">
                <option value="">{{ __('admin.actions.filter') }}</option>
                @foreach(\App\Enums\UserStatus::cases() as $status)
                    <option value="{{ $status->value }}" @selected(request('status') === $status->value)>{{ $status->label() }}</option>
                @endforeach
            </select>
        </div>
        <div class="col-md-3">
            <button class="btn-arena btn-primary w-100">{{ __('admin.actions.search') }}</button>
        </div>
    </div>
</form>

<div class="card-arena overflow-hidden">
    <div class="table-responsive">
        <table class="table table-dark table-hover mb-0 align-middle">
            <thead>
                <tr>
                    <th>User</th>
                    <th>Email</th>
                    <th>Role</th>
                    <th>Status</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @forelse($users as $user)
                    <tr>
                        <td>
                            <div class="fw-600">{{ $user->display_name ?? $user->name }}</div>
                            <div class="fs-xs text-muted">{{ '@'.$user->username }}</div>
                        </td>
                        <td>{{ $user->email }}</td>
                        <td>{{ $user->role->label() }}</td>
                        <td>{{ $user->status->label() }}</td>
                        <td class="text-end">
                            <a href="{{ route('admin.users.show', $user) }}" class="btn-arena btn-ghost btn-sm">{{ __('admin.actions.view') }}</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">{{ $users->links() }}</div>
@endsection
