@extends('dashboard.layout')
@section('title', 'إدارة الصلاحيات')
@section('content')
    <div class="page-header">
        <h1>الصلاحيات</h1>
        <a href="{{ route('dashboard.permissions.create') }}" class="btn btn-primary"><i class="fas fa-plus"></i> صلاحية جديدة</a>
    </div>
    <div class="card">
        <table>
            <thead>
                <tr>
                    <th>#</th>
                    <th>الاسم</th>
                    <th>الإجراءات</th>
                </tr>
            </thead>
            <tbody>
                @forelse($permissions as $permission)
                    <tr>
                        <td>{{ $permission->id }}</td>
                        <td>{{ $permission->name }}</td>
                        <td>
                            <div class="actions">
                                <a href="{{ route('dashboard.permissions.edit', $permission) }}" class="btn btn-warning btn-sm"><i class="fas fa-edit"></i></a>
                                <form action="{{ route('dashboard.permissions.destroy', $permission) }}" method="POST" onsubmit="return confirm('تأكيد الحذف؟')">
                                    @csrf @method('DELETE')
                                    <button type="submit" class="btn btn-danger btn-sm"><i class="fas fa-trash"></i></button>
                                </form>
                            </div>
                        </td>
                    </tr>
                @empty
                    <tr><td colspan="3" style="text-align:center;color:#888;">لا يوجد صلاحيات</td></tr>
                @endforelse
            </tbody>
        </table>
        <div class="pagination">{{ $permissions->links() }}</div>
    </div>
@endsection
