@extends('layouts.app')
@section('title', $roleLabel.' İzinleri')
@section('content')
<form method="POST" action="{{ route('panel.roles.update', $role) }}" class="bg-white rounded shadow p-6 max-w-4xl">
    @csrf
    @method('PUT')

    <h2 class="text-lg font-semibold mb-4">{{ $roleLabel }} — İzinler</h2>

    @foreach ($groupedPermissions as $category => $categoryPermissions)
        <div class="mb-6">
            <h3 class="text-sm font-semibold text-slate-600 border-b pb-1 mb-2">{{ $category }}</h3>
            <div class="grid grid-cols-2 gap-2">
                @foreach ($categoryPermissions as $permission)
                    <label class="flex items-center gap-2 text-sm">
                        <input type="checkbox" name="permissions[]" value="{{ $permission->name }}"
                            @checked($role->hasPermissionTo($permission->name))>
                        {{ $labels[$permission->name][1] ?? $permission->name }}
                    </label>
                @endforeach
            </div>
        </div>
    @endforeach

    <button class="bg-blue-600 text-white rounded px-4 py-2 text-sm font-medium">Kaydet</button>
</form>
@endsection
