<x-layout.universal pageTitle="Gestione Fornitori" showBreadcrumb="true" showSidebar="true">
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h3 class="card-title mb-0">Lista Fornitori</h3>
                    <a href="{{ route('admin.fornitori.create') }}" class="btn btn-primary">
                        <i class="fas fa-plus me-1"></i>Nuovo Fornitore
                    </a>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-striped table-hover">
                            <thead class="table-dark">
                                <tr>
                                    <th>ID</th>
                                    <th>Ragione Sociale</th>
                                    <th>Partita IVA</th>
                                    <th>Email</th>
                                    <th>Telefono</th>
                                    <th>Città</th>
                                    <th>Azioni</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse($fornitori as $fornitore)
                                    <tr>
                                        <td>{{ $fornitore->id_fornitore }}</td>
                                        <td><strong>{{ $fornitore->ragione_sociale }}</strong></td>
                                        <td>{{ $fornitore->partita_iva ?? '-' }}</td>
                                        <td>{{ $fornitore->email ?? '-' }}</td>
                                        <td>{{ $fornitore->telefono ?? '-' }}</td>
                                        <td>{{ $fornitore->citta ?? '-' }}</td>
                                        <td>
                                            <div class="btn-group" role="group">
                                                <a href="{{ route('admin.fornitori.show', $fornitore) }}" class="btn btn-sm btn-outline-info">
                                                    <i class="fas fa-eye"></i> Visualizza
                                                </a>
                                                <a href="{{ route('admin.fornitori.edit', $fornitore) }}" class="btn btn-sm btn-outline-primary">
                                                    <i class="fas fa-edit"></i> Modifica
                                                </a>
                                                <form method="POST" action="{{ route('admin.fornitori.destroy', $fornitore) }}" class="d-inline" onsubmit="return confirm('Sei sicuro di voler eliminare questo fornitore?')">
                                                    @csrf
                                                    @method('DELETE')
                                                    <button type="submit" class="btn btn-sm btn-outline-danger">
                                                        <i class="fas fa-trash"></i> Elimina
                                                    </button>
                                                </form>
                                            </div>
                                        </td>
                                    </tr>
                                @empty
                                    <tr>
                                        <td colspan="7" class="text-center">
                                            <div class="alert alert-info">
                                                <i class="fas fa-info-circle"></i> Nessun fornitore trovato.
                                            </div>
                                        </td>
                                    </tr>
                                @endforelse
                            </tbody>
                        </table>
                    </div>

                    <!-- Paginazione -->
                    @if($fornitori->hasPages())
                        <div class="d-flex justify-content-center mt-4">
                            {{ $fornitori->links() }}
                        </div>
                    @endif
                </div>
            </div>
        </div>
    </div>
</div>
</x-layout.universal>