<x-app-layout>
    <div class="mx-auto max-w-6xl px-4 py-8 sm:px-6 lg:px-8">
        <h1 class="text-3xl font-black text-slate-950 dark:text-white">Community Chat Messages</h1>
        <div class="mt-6 space-y-3">
            @foreach ($messages as $message)
                <div class="rounded-lg border border-blue-100 bg-white p-4 dark:border-blue-900/50 dark:bg-slate-900">
                    <div class="flex flex-wrap items-start justify-between gap-3">
                        <div>
                            <p class="text-sm text-slate-700 dark:text-slate-200"><span class="font-black">{{ $message->user->name }}</span>: {{ $message->message }}</p>
                            <p class="mt-1 text-xs text-slate-500">{{ $message->created_at->diffForHumans() }} {{ $message->is_hidden ? '• hidden' : '' }}</p>
                        </div>
                        <div class="flex gap-2">
                            <form method="POST" action="{{ route('admin.community.messages.toggle-hidden', $message) }}">@csrf @method('PATCH')<button class="text-sm font-bold text-blue-700 dark:text-blue-300">{{ $message->is_hidden ? 'Unhide' : 'Hide' }}</button></form>
                            <form method="POST" action="{{ route('admin.community.messages.destroy', $message) }}">@csrf @method('DELETE')<button class="text-sm font-bold text-red-600">Delete</button></form>
                            <form method="POST" action="{{ route('admin.community.users.ban', $message->user) }}">@csrf <button class="text-sm font-bold text-red-600">Ban User</button></form>
                        </div>
                    </div>
                </div>
            @endforeach
        </div>
        <div class="mt-6">{{ $messages->links() }}</div>
    </div>
</x-app-layout>
