@extends('layouts.app')
@section('title', 'Kullanıcılar')
@section('content')
<div class="flex justify-end mb-4">
    <a href="{{ route('panel.users.create') }}" class="bg-blue-600 text-white rounded px-4 py-2 text-sm font-medium">+ Yeni Kullanıcı</a>
</div>
<div class="bg-white rounded shadow overflow-x-auto">
    <table class="w-full text-sm">
        <thead class="bg-slate-100 text-left"><tr><th class="p-3">Ad</th><th class="p-3">E-posta</th><th class="p-3">Rol</th><th class="p-3">Durum</th><th class="p-3">İşlem</th></tr></thead>
        <tbody>
        @foreach ($users as $user)
            <tr class="border-t">
                <td class="p-3">{{ $user->name }}</td>
                <td class="p-3">{{ $user->email }}</td>
                <td class="p-3">{{ $user->roles->pluck('name')->join(', ') }}</td>
                <td class="p-3">{{ $user->status==='active' ? 'Aktif':'Pasif' }}</td>
                <td class="p-3 flex gap-2">
                    <a href="{{ route('panel.users.edit', $user) }}" class="text-slate-600 hover:underline">Düzenle</a>
                    <form method="POST" action="{{ route('panel.users.destroy', $user) }}" onsubmit="return confirm('Emin misiniz?')">
                        @csrf @method('DELETE')
                        <button class="text-red-600 hover:underline">Sil</button>
                    </form>
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
</div>
<div class="mt-4">{{ $users->links() }}</div>
@endsection
