<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Admin Dashboard Report</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 24px; color: #0f172a; }
        .muted { color: #475569; font-size: 12px; }
        .grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin: 16px 0; }
        .card { border: 1px solid #cbd5e1; border-radius: 8px; padding: 12px; }
        table { width: 100%; border-collapse: collapse; margin-top: 12px; }
        th, td { border: 1px solid #cbd5e1; padding: 8px; font-size: 12px; text-align: left; }
        th { background: #f1f5f9; }
        @media print { .no-print { display: none; } }
    </style>
</head>
<body>
    <h2>Dashboard Analytics Report</h2>
    <div class="muted">Range: {{ strtoupper($range) }} | {{ $start->toDateString() }} to {{ $end->toDateString() }}</div>
    <div class="muted">Generated: {{ $generatedAt->toDateTimeString() }}</div>

    <div class="grid">
        <div class="card">
            <div class="muted">Total Transactions</div>
            <div><strong>{{ $totals['transactions'] }}</strong></div>
        </div>
        <div class="card">
            <div class="muted">Gross Sales</div>
            <div><strong>NGN {{ number_format($totals['gross'], 2) }}</strong></div>
        </div>
        <div class="card">
            <div class="muted">Profit</div>
            <div><strong>NGN {{ number_format($totals['profit'], 2) }}</strong></div>
        </div>
    </div>

    <table>
        <thead>
            <tr>
                <th>Date</th>
                <th>Transactions</th>
                <th>Gross Sales</th>
                <th>Profit</th>
            </tr>
        </thead>
        <tbody>
            @forelse($rows as $row)
                <tr>
                    <td>{{ $row->day }}</td>
                    <td>{{ (int) $row->total }}</td>
                    <td>NGN {{ number_format((float) $row->gross, 2) }}</td>
                    <td>NGN {{ number_format((float) $row->profit, 2) }}</td>
                </tr>
            @empty
                <tr>
                    <td colspan="4">No records for selected range.</td>
                </tr>
            @endforelse
        </tbody>
    </table>

    <button class="no-print" onclick="window.print()" style="margin-top:12px; padding:8px 12px;">Print / Save PDF</button>
</body>
</html>
