@extends('layouts.admin')
@section('title', __('Payments'))

@section('content')
<h1 class="h4 fw-bold mb-3">🧾 {{ __('Payment approvals') }}</h1>

<div class="d-flex gap-2 mb-3 flex-wrap">
    @foreach(['pending' => __('Pending'), 'info_requested' => __('Info requested'), 'approved' => __('Approved'), 'rejected' => __('Rejected'), 'all' => __('All')] as $key => $label)
        <a href="?status={{ $key }}" class="btn btn-sm {{ $status === $key ? 'mb-btn-primary' : 'mb-btn-ghost' }}">{{ $label }}</a>
    @endforeach
</div>

<div class="mb-card p-3">
    <table class="table mb-table align-middle mb-0">
        <thead><tr>
            <th>{{ __('Clinic') }}</th><th>{{ __('Gateway') }}</th><th>{{ __('Amount') }}</th>
            <th>{{ __('Months') }}</th><th>{{ __('Reference') }}</th><th>{{ __('Status') }}</th><th>{{ __('Submitted') }}</th><th></th>
        </tr></thead>
        <tbody>
        @forelse($payments as $p)
            <tr>
                <td>{{ $p->tenant->name }}</td>
                <td>{{ $p->gateway->label() }}</td>
                <td dir="ltr">{{ $p->amountFormatted() }}</td>
                <td>{{ $p->period_months }}</td>
                <td dir="ltr" class="mb-muted small">{{ $p->proof_reference }}</td>
                <td><span class="status-chip" style="background: {{ $p->status->color() }}">{{ $p->status->label() }}</span></td>
                <td class="mb-muted small">{{ $p->created_at->format('d M · H:i') }}</td>
                <td><a href="{{ route('admin.payments.show', $p) }}" class="btn btn-sm mb-btn-primary">{{ __('Review') }}</a></td>
            </tr>
        @empty
            <tr><td colspan="8" class="mb-muted py-4 text-center">{{ __('No payments in this view.') }}</td></tr>
        @endforelse
        </tbody>
    </table>
</div>
{{ $payments->links() }}
@endsection
