<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Quarterly Report - {{ $period_label }}</title>
    <style>
        body {
            font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
            font-size: 12px;
            line-height: 1.6;
            color: #333;
            margin: 40px;
        }
        .header {
            text-align: center;
            margin-bottom: 30px;
            border-bottom: 3px solid #2c3e50;
            padding-bottom: 20px;
        }
        .header h1 {
            color: #2c3e50;
            font-size: 24px;
            margin-bottom: 5px;
        }
        .header h2 {
            color: #3498db;
            font-size: 18px;
            margin: 0;
        }
        .section {
            margin-bottom: 30px;
        }
        .section-title {
            font-size: 14px;
            font-weight: bold;
            color: #2c3e50;
            background-color: #f8f9fa;
            padding: 10px;
            margin-bottom: 15px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        table th, table td {
            padding: 10px;
            text-align: left;
            border: 1px solid #ddd;
        }
        table th {
            background-color: #2c3e50;
            color: white;
        }
        table tr:nth-child(even) {
            background-color: #f8f9fa;
        }
        .summary-box {
            display: inline-block;
            width: 30%;
            text-align: center;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 5px;
            margin: 10px 1%;
        }
        .summary-value {
            font-size: 24px;
            font-weight: bold;
            color: #2c3e50;
        }
        .summary-label {
            color: #7f8c8d;
            font-size: 10px;
        }
        .footer {
            margin-top: 40px;
            text-align: center;
            font-size: 10px;
            color: #7f8c8d;
            border-top: 1px solid #ddd;
            padding-top: 20px;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>QUARTERLY INVESTMENT REPORT</h1>
        <h2>{{ $period_label }}</h2>
    </div>

    <div class="section">
        <div class="section-title">Investor Information</div>
        <table>
            <tr>
                <td style="width: 30%;">Investor Name</td>
                <td><strong>{{ $investor->full_name }}</strong></td>
            </tr>
            <tr>
                <td>Email</td>
                <td>{{ $investor->email }}</td>
            </tr>
            <tr>
                <td>Report Date</td>
                <td>{{ $date }}</td>
            </tr>
        </table>
    </div>

    <div class="section">
        <div class="section-title">Portfolio Summary</div>
        <div style="text-align: center;">
            <div class="summary-box">
                <div class="summary-value">USD {{ number_format($total_invested, 2) }}</div>
                <div class="summary-label">TOTAL INVESTED</div>
            </div>
            <div class="summary-box">
                <div class="summary-value">{{ $investments->count() }}</div>
                <div class="summary-label">ACTIVE INVESTMENTS</div>
            </div>
            <div class="summary-box">
                <div class="summary-value">USD {{ number_format($total_dividends, 2) }}</div>
                <div class="summary-label">{{ $period_label }} DIVIDENDS</div>
            </div>
        </div>
    </div>

    <div class="section">
        <div class="section-title">Investment Holdings</div>
        <table>
            <thead>
                <tr>
                    <th>Reference</th>
                    <th>Tier</th>
                    <th>Amount</th>
                    <th>Term</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
                @forelse($investments as $investment)
                <tr>
                    <td>{{ $investment->reference }}</td>
                    <td>{{ ucfirst($investment->investment_tier) }}</td>
                    <td>{{ $investment->currency }} {{ number_format($investment->investment_amount, 2) }}</td>
                    <td>{{ $investment->investment_term }} year(s)</td>
                    <td>{{ ucfirst(str_replace('_', ' ', $investment->status)) }}</td>
                </tr>
                @empty
                <tr>
                    <td colspan="5" style="text-align: center;">No active investments</td>
                </tr>
                @endforelse
            </tbody>
        </table>
    </div>

    @if($dividends->count() > 0)
    <div class="section">
        <div class="section-title">Dividend Payments This Quarter</div>
        <table>
            <thead>
                <tr>
                    <th>Investment</th>
                    <th>Amount</th>
                    <th>Status</th>
                    <th>Paid At</th>
                </tr>
            </thead>
            <tbody>
                @foreach($dividends as $dividend)
                <tr>
                    <td>{{ $dividend->investment->reference ?? 'N/A' }}</td>
                    <td>{{ $dividend->currency }} {{ number_format($dividend->amount, 2) }}</td>
                    <td>{{ ucfirst($dividend->status) }}</td>
                    <td>{{ $dividend->paid_at?->format('M j, Y') ?? 'Pending' }}</td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
    @endif

    <div class="section">
        <div class="section-title">Important Notes</div>
        <ul>
            <li>Returns shown are based on actual performance and may vary from projections.</li>
            <li>All figures are in USD unless otherwise stated.</li>
            <li>For questions about this report, contact investors@meatsoko.com</li>
        </ul>
    </div>

    <div class="footer">
        <p>This report is for informational purposes only and does not constitute financial advice.</p>
        <p>MSL Assets & Investments | Nairobi, Kenya</p>
        <p>Report generated on {{ $date }}</p>
    </div>
</body>
</html>
