@extends('admin.layouts.app')

@section('title', 'User Aplikasi')
@section('page_title', 'Manajemen User')
@section('page_subtitle', 'Daftar akun pengguna aplikasi Flutter')

@section('content')
<div class="card soft-card">
    <div class="card-body">
        <form class="d-flex gap-2 mb-3" method="GET">
            <input class="form-control" name="search" value="{{ request('search') }}" placeholder="Cari nama atau email user">
            <button class="btn btn-outline-ocean" type="submit"><i class="bi bi-search"></i></button>
        </form>
        <div class="table-responsive">
            <table class="table table-hover">
                <thead><tr><th>Nama</th><th>Email</th><th>Terdaftar</th><th class="text-end">Aksi</th></tr></thead>
                <tbody>
                @forelse($users as $user)
                    <tr>
                        <td class="fw-semibold">{{ $user->name }}</td>
                        <td>{{ $user->email }}</td>
                        <td>{{ $user->created_at?->format('d M Y H:i') }}</td>
                        <td class="text-end">
                            <form method="POST" action="{{ route('admin.users.destroy', $user) }}" data-confirm="Hapus user aplikasi ini?">
                                @csrf @method('DELETE')
                                <button class="btn btn-sm btn-outline-danger" type="submit"><i class="bi bi-trash"></i></button>
                            </form>
                        </td>
                    </tr>
                @empty
                    <tr><td colspan="4" class="text-center text-muted py-4">Belum ada user aplikasi.</td></tr>
                @endforelse
                </tbody>
            </table>
        </div>
        {{ $users->links() }}
    </div>
</div>
@endsection
