<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Total Fees Report</title>
    <style>
        body { font-family: Arial, sans-serif; font-size: 12px; margin: 20px; }
        .header { text-align: center; margin-bottom: 20px; }
        .info p { margin: 5px 0; }
        table { width: 100%; border-collapse: collapse; margin-top: 16px; }
        th, td { border: 1px solid #000; padding: 6px; text-align: left; }
        th { background: #f2f2f2; }
        .text-right { text-align: right; }
    </style>
</head>
<body>
    @include('modules.reports.partials.pdf-company-details')
    <div class="header">
        <h2>Total Fees Report</h2>
    </div>
    <div class="info">
        <p><strong>Date:</strong> {{ date('F j, Y') }}</p>
        <p><strong>Period:</strong> {{ $dateFrom }} to {{ $dateTo }}</p>
    </div>
    <p><strong>Total Fees:</strong> {{ number_format($metrics['totalFees'], 2) }}</p>
    <p><strong>Paid Fees:</strong> {{ number_format($metrics['paidFees'], 2) }}</p>
    <p><strong>Outstanding Fees:</strong> {{ number_format($metrics['outstandingFees'], 2) }}</p>
    <p><strong>Total Invoices:</strong> {{ $metrics['totalInvoices'] }}</p>

    <table>
        <thead>
            <tr>
                <th>Client Name</th>
                <th>Invoice #</th>
                <th>Invoice Date</th>
                <th>Due Date</th>
                <th class="text-right">Total Amount</th>
                <th class="text-right">Paid Amount</th>
                <th class="text-right">Balance Due</th>
                <th>Status</th>
                <th>Currency</th>
            </tr>
        </thead>
        <tbody>
            @forelse($rows as $row)
                <tr>
                    <td>{{ $row['client_name'] }}</td>
                    <td>{{ $row['invoice_number'] }}</td>
                    <td>{{ $row['invoice_date'] }}</td>
                    <td>{{ $row['due_date'] }}</td>
                    <td class="text-right">{{ number_format($row['total'], 2) }}</td>
                    <td class="text-right">{{ number_format($row['paid'], 2) }}</td>
                    <td class="text-right">{{ number_format($row['balance'], 2) }}</td>
                    <td>{{ ucfirst(str_replace('_', ' ', $row['status'])) }}</td>
                    <td>{{ $row['currency'] }}</td>
                </tr>
            @empty
                <tr>
                    <td colspan="9" style="text-align:center;">No invoices found.</td>
                </tr>
            @endforelse
        </tbody>
    </table>
</body>
</html>

