@extends('layouts.default')
@section('title', $page_title)
@section('content')
<div class="container-fluid">
    @include('admin.partials.page-header')
    <div class="card">
        <div class="card-body">
            <div class="alert alert-light border">Token değerleri düz metin gösterilmez. Kayıtlar Laravel encryption ile şifreli saklanır; düzenleme bağlantı ekranından yapılır.</div>
            <div class="table-responsive">
                <table class="table table-responsive-md align-middle">
                    <thead><tr><th>Müşteri</th><th>Platform</th><th>Ad</th><th>Tip</th><th>Durum</th><th>Son Kontrol</th><th>Son Hata</th></tr></thead>
                    <tbody>
                    @forelse($credentials as $credential)
                        <tr>
                            <td>{{ $credential->client?->company_name ?? '-' }}</td>
                            <td>{{ strtoupper(str_replace('_', ' ', $credential->platform)) }}</td>
                            <td>{{ $credential->name }}</td>
                            <td>{{ $credential->credential_type }}</td>
                            <td>@include('admin.partials.status-badge', ['status' => $credential->is_active ? 'active' : 'error'])</td>
                            <td>{{ $credential->last_checked_at?->format('d.m.Y H:i') ?? '-' }}</td>
                            <td>{{ $credential->last_error ? \Illuminate\Support\Str::limit($credential->last_error, 90) : '-' }}</td>
                        </tr>
                    @empty
                        <tr><td colspan="7" class="text-center text-muted py-5">Henüz token kaydı yok.</td></tr>
                    @endforelse
                    </tbody>
                </table>
            </div>
            {{ $credentials->links() }}
        </div>
    </div>
</div>
@endsection
