@extends('layouts.dashboard')
@section('title', 'Invoice ' . $invoice->invoice_number)
@section('page-title', 'Invoice ' . $invoice->invoice_number)
@section('content')
<div class="row">
    <div class="col-lg-8">
        <div class="content-card">
            <div class="d-flex justify-content-between mb-4">
                <h2 class="mb-0">{{ $invoice->invoice_number }}<br><span class="badge {{ $invoice->statusBadgeClass() }} mt-2">{{ ucfirst($invoice->status) }}</span></h2>
                <h2 class="text-accent">${{ number_format($invoice->amount, 2) }}</h2>
            </div>
            <hr>
            <table class="table">
                <thead><tr><th>Description</th><th class="text-end">Amount</th></tr></thead>
                <tbody><tr><td>{{ $invoice->package->name ?? 'Custom' }}</td><td class="text-end">${{ number_format($invoice->amount, 2) }}</td></tr></tbody>
            </table>
        </div>
    </div>
    <div class="col-lg-4">
        <div class="content-card">
            @if($invoice->isUnpaid())
                <h4>Pay Now</h4>
                @if(gateway_enabled('paypal'))
                    <a href="{{ route('user.invoices.pay', [$invoice, 'gateway' => 'paypal']) }}" class="btn btn-warning w-100 btn-lg mb-2">Pay with PayPal</a>
                @endif
                @if(gateway_enabled('tap'))
                    <a href="{{ route('user.invoices.pay', [$invoice, 'gateway' => 'tap']) }}" class="btn btn-dark w-100">Pay with Tap</a>
                @endif
                @if(!gateway_enabled('paypal') && !gateway_enabled('tap'))
                    <p class="text-muted mb-0">No payment gateway is currently enabled.</p>
                @endif
            @else
                <h4>Paid ✓</h4>
                <p class="text-success">Paid {{ $invoice->paid_at?->format('M d, Y') }}</p>
            @endif
        </div>
    </div>
</div>
@endsection
