@extends('layouts.app')
@section('title', 'Partenaires')
@section('content')
<div class="d-flex justify-content-between align-items-center mb-3">
    <h3>Partenaires (laboratoires / cliniques)</h3>
    <a href="{{ route('admin.partners.create') }}" class="btn btn-primary">+ Nouveau partenaire</a>
</div>

<div class="card p-3">
    <div class="table-responsive">
        <table class="table align-middle">
            <thead>
                <tr>
                    <th>Nom</th>
                    <th>Type</th>
                    <th>Contact</th>
                    <th>Demandes</th>
                    <th>Statut</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @forelse($partners as $p)
                <tr>
                    <td>{{ $p->name }}</td>
                    <td>{{ ucfirst($p->type) }}</td>
                    <td>{{ $p->contact_person }}<br><span class="small text-muted">{{ $p->email }}</span></td>
                    <td>{{ $p->requests_count }}</td>
                    <td>
                        <span class="badge {{ $p->active ? 'bg-success' : 'bg-secondary' }}">
                            {{ $p->active ? 'Actif' : 'Inactif' }}
                        </span>
                    </td>
                    <td class="table-actions">
                        <form action="{{ route('admin.partners.toggle', $p) }}" method="POST">
                            @csrf
                            <button class="btn btn-sm btn-outline-secondary">
                                {{ $p->active ? 'Desactiver' : 'Activer' }}
                            </button>
                        </form>
                    </td>
                </tr>
                @empty
                <tr><td colspan="6" class="text-center text-muted">Aucun partenaire cree pour le moment.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
    {{ $partners->links() }}
</div>
@endsection
