@extends('layouts.dashboard')
@section('title', 'My Invoices')
@section('page-title', 'My Invoices')
@section('content')
<div class="content-card">
    <div class="content-card-header"><h3>{{ $invoices->total() }} Invoices</h3></div>
    <div class="table-responsive">
    <table class="table">
        <thead><tr><th>#</th><th>Description</th><th>Amount</th><th>Status</th><th></th></tr></thead>
        <tbody>
        @forelse($invoices as $inv)
            <tr>
                <td><a href="{{ route('user.invoices.show', $inv) }}">{{ $inv->invoice_number }}</a></td>
                <td>{{ $inv->package->name ?? 'Custom' }}</td>
                <td>${{ number_format($inv->amount, 2) }}</td>
                <td><span class="badge {{ $inv->statusBadgeClass() }}">{{ ucfirst($inv->status) }}</span></td>
                <td>@if($inv->isUnpaid())<a href="{{ route('user.invoices.pay', $inv) }}" class="btn btn-sm btn-warning">Pay Now</a>@endif</td>
            </tr>
        @empty
            <tr><td colspan="5" class="text-center text-muted py-4">No invoices.</td></tr>
        @endforelse
        </tbody>
    </table>
    </div>
    {{ $invoices->links() }}
</div>
@endsection
