<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Loan Requests Notification</title>
    <style>
        body {
            font-family: 'Segoe UI', Arial, sans-serif;
            background-color: #f4f4f4;
            color: #333;
            margin: 0;
            padding: 20px;
        }

        .container {
            max-width: 900px;
            margin: auto;
            background-color: #ffffff;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        }

        h3 {
            font-size: 20px;
            color: #007bff;
            margin-bottom: 25px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
            font-size: 14px;
        }

        th,
        td {
            border: 1px solid #dee2e6;
            padding: 10px;
            text-align: left;
        }

        thead {
            background-color: #f1f1f1;
        }

        tfoot tr {
            background-color: #f9f9f9;
            font-weight: bold;
        }

        .footer {
            font-size: 12px;
            color: #777;
            text-align: center;
            border-top: 1px solid #e1e1e1;
            padding-top: 15px;
        }
    </style>
</head>

<body>
    <div class="container">
        <h3>{{ $data->requestsCount }} new loan requests have been created</h3>

        <table>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Status</th>
                    <th>Client</th>
                    <th>Loan Date</th>
                    <th>Amount</th>
                    <th>Weekly Payment</th>
                    <th>Disbursement Amount</th>
                </tr>
            </thead>
            <tbody>
                @php $totalAmount = 0; $totalDelivered = 0; @endphp
                @foreach ($data->requests as $item)
                @php
                $totalAmount += $item->loanamount;
                $totalDelivered += $item->realamount;
                @endphp
                <tr>
                    <td>{{ $item->id }}</td>
                    <td>{{ $item->client ? 'Renewal' : 'New' }}</td>
                    <td>{{ $item->client->fullname ?? $item->request_client->fullname }}</td>
                    <td>{{ \Carbon\Carbon::parse($item->loandate)->format('d/n/Y') }}</td>
                    <td>${{ number_format($item->loanamount, 2) }}</td>
                    <td>${{ number_format($item->weeklypayment, 2) }}</td>
                    <td>${{ number_format($item->realamount, 2) }}</td>
                </tr>
                @endforeach
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="6" style="text-align: right;">Total Amount:</td>
                    <td>${{ number_format($totalAmount, 2) }}</td>
                </tr>
                <tr>
                    <td colspan="6" style="text-align: right;">Total Disbursement:</td>
                    <td>${{ number_format($totalDelivered, 2) }}</td>
                </tr>
            </tfoot>
        </table>

        <div class="footer">
            This email was generated automatically. Please do not reply.
        </div>
    </div>
</body>

</html>