<div>
    <x-slot name="header">
        <h2 class="text-xl font-semibold leading-tight text-gray-800">
            Tipos de plataforma
        </h2>
    </x-slot>

    <div class="py-6">
        <div class="mx-auto max-w-8xl sm:px-6 lg:px-8 mt-2">

            @if (session()->has('success'))
                <div class="mb-4 rounded bg-green-100 px-4 py-2 text-green-700">
                    {{ session('success') }}
                </div>
            @endif

            {{-- Search + Create --}}
            <div class="mb-4 flex items-center justify-between">
                <div class="w-1/3">
                    <input
                        type="text"
                        wire:model.live.debounce.300ms="search"
                        placeholder="Buscar tipo..."
                        class="w-full rounded border px-3 py-2"
                    >
                </div>

                <a href="{{ route('types.create') }}"
                   class="rounded bg-blue-600 px-4 py-2 text-white hover:bg-blue-700">
                    Nuevo tipo
                </a>
            </div>

            {{-- Tabla --}}
            <div class="overflow-hidden rounded bg-white shadow">
                <table class="min-w-full text-left text-sm">

                    <thead class="bg-gray-100 text-xs uppercase text-gray-600">
                    <tr>
                        <th class="px-4 py-3">Nombre</th>
                        <th class="px-4 py-3">Shortname</th>
                        <th class="px-4 py-3">Descripción</th>
                        <th class="px-4 py-3 text-right">Acciones</th>
                    </tr>
                    </thead>

                    <tbody class="divide-y">
                    @forelse($types as $type)
                        <tr class="hover:bg-gray-50">
                            <td class="px-4 py-3">{{ $type->name }}</td>
                            <td class="px-4 py-3">{{ $type->shortname }}</td>
                            <td class="px-4 py-3">{{ $type->description ?? '—' }}</td>

                            <td class="px-4 py-3 text-right">
                                <a href="{{ route('types.edit', $type) }}"
                                   class="text-blue-600 hover:text-blue-800">
                                    Editar
                                </a>
                            </td>
                        </tr>

                    @empty
                        <tr>
                            <td colspan="4" class="px-4 py-3 text-center text-gray-500">
                                No hay tipos registrados.
                            </td>
                        </tr>
                    @endforelse
                    </tbody>

                </table>
            </div>

            {{-- Paginación --}}
            <div class="mt-4">
                {{ $types->links() }}
            </div>

        </div>
    </div>
</div>

