@extends('layouts.app')

@section('content')
<div class="container">
    <h2>Gestión de Roles</h2>

    <a href="{{ route('roles.create') }}" class="btn btn-primary mb-3">
        Nuevo Rol
    </a>



    <table class="table table-bordered">
        <thead>
            <tr>
                <th>ID</th>
                <th>Nombre</th>
                <th>Acciones</th>
            </tr>
        </thead>
        <tbody>
            @foreach($roles as $role)
            <tr>
                <td>{{ $role->id }}</td>
                <td>{{ $role->name }}</td>
                <td>
    <a href="{{ route('roles.edit',$role) }}" 
       class="btn btn-warning btn-sm">Editar</a>

    <a href="{{ route('roles.permissions',$role) }}" 
       class="btn btn-info btn-sm">Permisos</a>

    <form action="{{ route('roles.destroy',$role) }}" 
          method="POST" class="d-inline">
        @csrf @method('DELETE')
        <button class="btn btn-danger btn-sm"
          onclick="return confirm('¿Eliminar este rol?')">
          Eliminar
        </button>
    </form>
</td>
            </tr>
            @endforeach
        </tbody>
    </table>
</div>
@endsection
