<div>
    <div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4 sm:mb-6">
        <h1 class="text-xl sm:text-2xl font-bold text-gray-800">الأدوار والصلاحيات</h1>
        @can('roles.create')
        <a href="{{ route('roles.create') }}" wire:navigate
           class="inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-sm font-medium">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
            <span class="hidden sm:inline">إضافة دور</span>
        </a>
        @endcan
    </div>

    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4">
        @foreach($roles as $role)
        <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-4 sm:p-5">
            <div class="flex items-start justify-between mb-3">
                <div>
                    <h3 class="font-semibold text-gray-800 text-sm sm:text-base">{{ $role->name_ar }}</h3>
                    <p class="text-xs text-gray-500 font-mono">{{ $role->slug }}</p>
                </div>
                <span class="px-2 py-0.5 text-xs rounded-full ms-2 {{ $role->is_system ? 'bg-amber-100 text-amber-700' : 'bg-blue-100 text-blue-700' }}">
                    {{ $role->is_system ? 'نظام' : 'مخصص' }}
                </span>
            </div>
            <div class="flex items-center justify-between text-xs sm:text-sm text-gray-600">
                <span>المستوى: {{ $role->level }}</span>
                <span>{{ $role->users_count }} مستخدم</span>
            </div>
            @if(!$role->is_system)
                @can('roles.update')
                <div class="mt-3 pt-3 border-t border-gray-100">
                    <a href="{{ route('roles.edit', $role) }}" wire:navigate class="text-blue-600 hover:text-blue-800 text-sm py-2 inline-block">تعديل الصلاحيات</a>
                </div>
                @endcan
            @endif
        </div>
        @endforeach
    </div>
</div>
