@extends('layouts.app')
@php
$item=1;
@endphp
@section('content')
<div class="d-flex align-items-center justify-content-between mt-3 mb-3">
    <div>
        <h3 class="mb-0 fw-bold"><i class="fas fa-tag me-2"></i>Tipo Usuario</h3>
        <small class="text-muted">Listado y mantenimiento de tipos de usuario</small>
    </div>
    <a href="{{ route('admin.tipo-usuario.create') }}" class="btn btn-primary">
        <i class="fas fa-plus me-2"></i>Nuevo
    </a>
</div>

<div class="card shadow-sm border-0">
    <div class="card-header bg-white d-flex justify-content-between align-items-center">
        <div class="fw-bold">Listado</div>
        <small class="text-muted">Total: {{ $items->total() }}</small>
    </div>

    <div class="table-responsive">
        <table class="table table-hover align-middle mb-0">
            <thead class="table-light">
                <tr>
                    <th style="width:90px;">ID</th>
                    <th>Tipo Usuario</th>
                    <th style="width:140px;">Estado</th>
                    <th class="text-end" style="width:220px;">Acciones</th>
                </tr>
            </thead>
            <tbody>
            @forelse($items as $it)
                <tr>
                    <td class="fw-semibold" align="center">{{ $loop->iteration}}</td>
                    <td>{{ $it->tipo_usuario }}</td>
                    <td>
                        @if($it->estado === 'AC')
                            <span class="badge bg-success">Activo</span>
                        @else
                            <span class="badge bg-secondary">Inactivo</span>
                        @endif
                    </td>
                    <td class="text-end">
                        <a href="{{ route('admin.tipo-usuario.edit', $it) }}" class="btn btn-sm btn-outline-secondary">
                            <i class="fas fa-pen me-1"></i>Editar
                        </a>

                        <form action="{{ route('admin.tipo-usuario.destroy', $it) }}"
                              method="POST"
                              class="d-inline"
                              onsubmit="return confirm('¿Eliminar? Se marcará estado=EL.')">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-sm btn-outline-danger">
                                <i class="fas fa-trash me-1"></i>Eliminar
                            </button>
                        </form>
                    </td>
                </tr>
                @php $item=+1; @endphp

            @empty
                <tr>
                    <td colspan="4" class="text-center text-muted py-5">
                        No hay registros.
                    </td>
                </tr>
            @endforelse
            </tbody>
        </table>
    </div>

    <div class="card-footer bg-white">
        {{ $items->links() }}
    </div>
</div>
@endsection