<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Loan Disbursed - {{ $loan->loan_number }}</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
            color: #333;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 600px;
            margin: 0 auto;
            background: #ffffff;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 0 20px rgba(0,0,0,0.1);
        }
        .header {
            background: linear-gradient(135deg, #0dcaf0, #0ba8d1);
            color: white;
            padding: 30px;
            text-align: center;
        }
        .header h1 {
            margin: 0;
            font-size: 24px;
            font-weight: 600;
        }
        .content {
            padding: 30px;
        }
        .disbursement-details {
            background: #f8f9fa;
            border-radius: 8px;
            padding: 20px;
            margin: 20px 0;
            border-left: 4px solid #0dcaf0;
        }
        .repayment-schedule {
            background: #e7f5ff;
            border-radius: 8px;
            padding: 20px;
            margin: 20px 0;
            border-left: 4px solid #0d6efd;
        }
        .detail-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
            padding-bottom: 10px;
            border-bottom: 1px solid #e9ecef;
        }
        .detail-item:last-child {
            border-bottom: none;
            margin-bottom: 0;
        }
        .detail-label {
            font-weight: 600;
            color: #495057;
        }
        .detail-value {
            color: #0dcaf0;
            font-weight: 600;
        }
        .footer {
            background: #f8f9fa;
            padding: 20px;
            text-align: center;
            color: #6c757d;
            font-size: 14px;
        }
        .btn {
            display: inline-block;
            background: #0dcaf0;
            color: white;
            padding: 12px 30px;
            text-decoration: none;
            border-radius: 5px;
            font-weight: 600;
            margin: 10px 0;
        }
        .btn:hover {
            background: #0ba8d1;
        }
        .icon {
            font-size: 48px;
            margin-bottom: 20px;
        }
        .important-note {
            background: #fff3cd;
            border: 1px solid #ffc107;
            border-radius: 5px;
            padding: 15px;
            margin: 15px 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="icon">💰</div>
            <h1>Loan Funds Disbursed</h1>
            <p>Your loan funds have been successfully transferred</p>
        </div>

        <div class="content">
            <h2>Dear {{ $client->first_name }} {{ $client->last_name }},</h2>

            <p>We are pleased to inform you that the funds for your loan <strong>{{ $loan->loan_number }}</strong> have been successfully disbursed.</p>

            <div class="disbursement-details">
                <h3>Disbursement Details</h3>
                <div class="detail-item">
                    <span class="detail-label">Loan Amount:</span>
                    <span class="detail-value">${{ number_format($loan->amount, 2) }}</span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">Disbursement Date:</span>
                    <span class="detail-value">{{ $loan->disbursement_date->format('M d, Y') }}</span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">Disbursement Method:</span>
                    <span class="detail-value">{{ ucfirst(str_replace('_', ' ', $loan->disbursement_method)) }}</span>
                </div>
                @if($loan->disbursement_reference)
                <div class="detail-item">
                    <span class="detail-label">Reference Number:</span>
                    <span class="detail-value">{{ $loan->disbursement_reference }}</span>
                </div>
                @endif
            </div>

            <div class="repayment-schedule">
                <h3>Repayment Information</h3>
                <div class="detail-item">
                    <span class="detail-label">Monthly Payment:</span>
                    <span class="detail-value">${{ number_format($loan->monthly_payment, 2) }}</span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">First Payment Due:</span>
                    <span class="detail-value">{{ $loan->repayment_date->format('M d, Y') }}</span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">Total Repayment:</span>
                    <span class="detail-value">${{ number_format($loan->total_repayment, 2) }}</span>
                </div>
            </div>

            <div class="important-note">
                <h4>📋 Important Notes:</h4>
                <ul>
                    <li>Please ensure timely repayment of your monthly installments</li>
                    <li>Late payments may incur additional charges and affect your credit history</li>
                    <li>You can make payments through various methods including bank transfer, mobile money, or cash at our offices</li>
                    <li>Keep track of your repayment schedule through your online account</li>
                </ul>
            </div>

            <p>If you have any questions about your loan or repayment schedule, please contact our customer service team.</p>

            <a href="{{ url('/loans/' . $loan->id) }}" class="btn">View Loan Details & Repayment Schedule</a>
        </div>

        <div class="footer">
            <p>&copy; {{ date('Y') }} Credora. All rights reserved.</p>
            <p>This is an automated message. Please do not reply to this email.</p>
        </div>
    </div>
</body>
</html>
