@extends('layouts.default')
@section('content')
<div class="container-fluid">
    <div class="row mb-3">
        <div class="col-md-8">
            <h3>{{ $page_title }}</h3>
            <p class="text-muted mb-0">{{ $page_description }}</p>
        </div>
        <div class="col-md-4 text-md-end">
            <a href="{{ route('admin.onboarding.start') }}" class="btn btn-primary">Yeni Onboarding Başlat</a>
        </div>
    </div>

    <div class="row">
        <div class="col-xl-3 col-sm-6"><div class="card"><div class="card-body"><h3>{{ $stats['not_started'] }}</h3><span>Başlamadı</span></div></div></div>
        <div class="col-xl-3 col-sm-6"><div class="card"><div class="card-body"><h3>{{ $stats['in_progress'] }}</h3><span>Devam Ediyor</span></div></div></div>
        <div class="col-xl-3 col-sm-6"><div class="card"><div class="card-body"><h3>{{ $stats['needs_review'] }}</h3><span>Kontrol Gerekli</span></div></div></div>
        <div class="col-xl-3 col-sm-6"><div class="card"><div class="card-body"><h3>{{ $stats['completed'] }}</h3><span>Tamamlandı</span></div></div></div>
    </div>

    <div class="card">
        <div class="card-body">
            <form method="GET" class="row g-2 mb-4">
                <div class="col-md-3">
                    <select name="status" class="form-control default-select">
                        <option value="">Tüm durumlar</option>
                        <option value="not_started" @selected(request('status')==='not_started')>Başlamadı</option>
                        <option value="in_progress" @selected(request('status')==='in_progress')>Devam Ediyor</option>
                        <option value="needs_review" @selected(request('status')==='needs_review')>Kontrol Gerekli</option>
                        <option value="completed" @selected(request('status')==='completed')>Tamamlandı</option>
                    </select>
                </div>
                <div class="col-md-3"><button class="btn btn-dark">Filtrele</button> <a href="{{ route('admin.onboarding.index') }}" class="btn btn-light">Temizle</a></div>
            </form>
            <div class="table-responsive">
                <table class="table table-hover align-middle">
                    <thead><tr><th>Müşteri</th><th>Durum</th><th>Adım</th><th>Bağlantı</th><th>Marka Kiti</th><th>Plan</th><th class="text-end">İşlem</th></tr></thead>
                    <tbody>
                    @forelse($clients as $client)
                        <tr>
                            <td><a href="{{ route('admin.clients.show', $client) }}" class="font-w600 text-black">{{ $client->company_name }}</a><br><small>{{ $client->email ?: '-' }}</small></td>
                            <td><span class="badge {{ $client->onboardingBadgeClass() }}">{{ $client->onboardingStatusLabel() }}</span></td>
                            <td>{{ $client->onboarding_step ?: '-' }}</td>
                            <td>{{ $client->platform_connections_count }}</td>
                            <td>{{ $client->brand_kits_count }}</td>
                            <td>{{ $client->report_schedules_count }}</td>
                            <td class="text-end">
                                <a href="{{ route('admin.onboarding.start', ['client_id' => $client->id]) }}" class="btn btn-xs btn-outline-primary">Devam Et</a>
                                <a href="{{ route('admin.onboarding.summary', $client) }}" class="btn btn-xs btn-outline-dark">Özet</a>
                            </td>
                        </tr>
                    @empty
                        <tr><td colspan="7" class="text-center text-muted py-5">Henüz onboarding kaydı yok.</td></tr>
                    @endforelse
                    </tbody>
                </table>
            </div>
            {{ $clients->links() }}
        </div>
    </div>
</div>
@endsection
