<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: DejaVu Sans, sans-serif; color: #15204a; font-size: 12px; }
        .header { background: #1c2b5f; color: #fff; padding: 22px 36px; }
        .header img { height: 26px; }
        .header .brand { font-size: 20px; font-weight: bold; }
        .header .brand span { color: #58b9e6; }
        .header .meta { color: #b9e4f8; margin-top: 8px; font-size: 11px; }
        .wrap { padding: 24px 36px; }
        .highlight { background: #eef1f9; border-radius: 12px; padding: 18px; text-align: center; margin-bottom: 18px; }
        .highlight .big { font-size: 30px; font-weight: bold; color: #1c2b5f; }
        .highlight .sub { color: #4b64ac; font-size: 11px; margin-top: 3px; }
        .chart-box { text-align: center; margin-bottom: 18px; }
        .chart-box img { max-width: 92%; max-height: 260px; }
        h2 { font-size: 14px; color: #1c2b5f; margin: 16px 0 8px; border-bottom: 2px solid #58b9e6; padding-bottom: 4px; }
        table { width: 100%; border-collapse: collapse; margin-top: 6px; }
        td, th { padding: 7px 9px; border-bottom: 1px solid #dce3f3; text-align: left; }
        th { background: #eef1f9; color: #28366a; font-size: 11px; text-transform: uppercase; }
        .footer { position: fixed; bottom: 0; left: 0; right: 0; background: #eef1f9; padding: 10px 36px; font-size: 9px; color: #4b64ac; }
    </style>
</head>
@php
    $logoPath = public_path('images/logo-white-pdf.png');
    $logo = is_file($logoPath) ? 'data:image/png;base64,'.base64_encode(file_get_contents($logoPath)) : null;
@endphp
<body>
    <div class="header">
        @if ($logo)
            <img src="{{ $logo }}" alt="Money-Wise">
        @else
            <div class="brand">money<span>wise</span></div>
        @endif
        <div class="meta">{{ $title }} · {{ now()->format('j F Y') }} @if($currency) · Currency: {{ $currency }} @endif</div>
    </div>

    <div class="wrap">
        @if ($highlight)
            <div class="highlight">
                <div class="big">{{ $highlight['value'] }}</div>
                <div class="sub">{{ $highlight['label'] }}</div>
            </div>
        @endif

        @if (! empty($chart) && \Illuminate\Support\Str::startsWith($chart, 'data:image/'))
            <div class="chart-box">
                @if (! empty($chartTitle))<h2 style="text-align:left">{{ $chartTitle }}</h2>@endif
                <img src="{{ $chart }}" alt="Chart">
            </div>
        @endif

        @foreach ($sections as $section)
            <h2>{{ $section['title'] }}</h2>
            <table>
                @foreach ($section['rows'] as $row)
                    <tr>
                        <td style="width: 55%; color:#28366a">{{ $row[0] }}</td>
                        <td style="font-weight: bold">{{ $row[1] }}</td>
                    </tr>
                @endforeach
            </table>
        @endforeach

        @if (!empty($note))
            <h2>Next step</h2>
            <p style="line-height:1.55; color:#28366a">{{ $note }}</p>
        @endif
    </div>

    <div class="footer">
        moneywise.co.ke, Africa's financial confidence ecosystem · Figures are estimates for planning, not regulated financial advice.
    </div>
</body>
</html>
