<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Savings Deposits Report</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            font-size: 12px;
            line-height: 1.4;
            margin: 20px;
        }
        .header {
            text-align: center;
            margin-bottom: 30px;
            border-bottom: 2px solid #333;
            padding-bottom: 10px;
        }
        .header h1 {
            margin: 0;
            font-size: 24px;
            color: #333;
        }
        .header p {
            margin: 5px 0;
            color: #666;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
            vertical-align: top;
        }
        th {
            background-color: #f5f5f5;
            font-weight: bold;
        }
        .text-right {
            text-align: right;
        }
        .text-center {
            text-align: center;
        }
        .footer {
            margin-top: 30px;
            text-align: center;
            font-size: 10px;
            color: #666;
            border-top: 1px solid #ddd;
            padding-top: 10px;
        }
        @media print {
            body { margin: 0; }
            .no-print { display: none; }
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>Savings Deposits Report</h1>
        <p>Generated on {{ now()->format('F d, Y H:i') }}</p>
        <p>Total Deposits: {{ $deposits->count() }}</p>
        <p>Total Amount: USD {{ number_format($deposits->sum('amount'), 2) }}</p>
    </div>

    <table>
        <thead>
            <tr>
                <th>Transaction #</th>
                <th>Client Name</th>
                <th>Account Number</th>
                <th>Amount</th>
                <th>Description</th>
                <th>Payment Method</th>
                <th>Date</th>
                <th>Created By</th>
            </tr>
        </thead>
        <tbody>
            @forelse($deposits as $deposit)
            <tr>
                <td>{{ $deposit->transaction_number }}</td>
                <td>{{ $deposit->savingsAccount->client->full_name }}</td>
                <td>{{ $deposit->savingsAccount->account_number }}</td>
                <td class="text-right">USD {{ number_format($deposit->amount, 2) }}</td>
                <td>{{ $deposit->description ?? 'N/A' }}</td>
                <td class="text-center">{{ ucfirst($deposit->payment_method ?? 'N/A') }}</td>
                <td>{{ $deposit->transaction_date->format('M d, Y') }}</td>
                <td>{{ $deposit->creator->name ?? 'N/A' }}</td>
            </tr>
            @empty
            <tr>
                <td colspan="8" class="text-center">No deposits found.</td>
            </tr>
            @endforelse
        </tbody>
    </table>

    <div class="footer">
        <p>Report generated by Credora System</p>
        <p>© {{ date('Y') }} All rights reserved</p>
    </div>
</body>
</html>
