<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{ $meta['title'] ?? 'Revenue Report' }}</title>
    <style>
        body { font-family: 'Helvetica', Arial, sans-serif; font-size: 12px; color: #333; margin: 40px; }
        table.data { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
        table.data th { background-color: #1d4ed8; color: white; padding: 8px 12px; text-align: left; font-size: 11px; text-transform: uppercase; }
        table.data th.text-right { text-align: right; }
        table.data td { padding: 8px 12px; border-bottom: 1px solid #eee; }
        table.data tr:nth-child(even) { background-color: #f8fafc; }
        .section-title { font-size: 14px; font-weight: bold; color: #1d4ed8; margin: 20px 0 10px; border-bottom: 1px solid #e2e8f0; padding-bottom: 5px; }
        .summary-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 4px; padding: 15px; margin-bottom: 20px; text-align: center; }
        .summary-value { font-size: 24px; font-weight: bold; color: #1d4ed8; }
        .summary-label { font-size: 11px; color: #64748b; text-transform: uppercase; margin-top: 4px; }
        .footer { margin-top: 40px; text-align: center; font-size: 10px; color: #999; border-top: 1px solid #eee; padding-top: 15px; }
    </style>
</head>
<body>
    @include('reports._header')

    <div class="summary-box">
        <div class="summary-value">${{ number_format($data['total_revenue'] ?? 0, 2) }}</div>
        <div class="summary-label">Total Revenue</div>
    </div>

    @if(!empty($data['by_period']))
        <div class="section-title">Revenue by Period</div>
        <table class="data">
            <thead>
                <tr>
                    <th>Period</th>
                    <th class="text-right" style="text-align: right;">Amount</th>
                </tr>
            </thead>
            <tbody>
                @foreach($data['by_period'] as $row)
                    <tr>
                        <td>{{ $row['period'] }}</td>
                        <td style="text-align: right;">${{ number_format($row['amount'], 2) }}</td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    @endif

    @if(!empty($data['by_service_type']))
        <div class="section-title">Revenue by Service Type</div>
        <table class="data">
            <thead>
                <tr>
                    <th>Service Type</th>
                    <th class="text-right" style="text-align: right;">Amount</th>
                </tr>
            </thead>
            <tbody>
                @foreach($data['by_service_type'] as $row)
                    <tr>
                        <td>{{ ucfirst($row['type']) }}</td>
                        <td style="text-align: right;">${{ number_format($row['amount'], 2) }}</td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    @endif

    @if(!empty($data['by_gateway']))
        <div class="section-title">Revenue by Gateway</div>
        <table class="data">
            <thead>
                <tr>
                    <th>Gateway</th>
                    <th class="text-right" style="text-align: right;">Amount</th>
                </tr>
            </thead>
            <tbody>
                @foreach($data['by_gateway'] as $row)
                    <tr>
                        <td>{{ ucfirst($row['gateway']) }}</td>
                        <td style="text-align: right;">${{ number_format($row['amount'], 2) }}</td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    @endif

    @if(!empty($data['by_plan']))
        <div class="section-title">Revenue by Plan</div>
        <table class="data">
            <thead>
                <tr>
                    <th>Plan</th>
                    <th class="text-right" style="text-align: right;">Amount</th>
                </tr>
            </thead>
            <tbody>
                @foreach($data['by_plan'] as $row)
                    <tr>
                        <td>{{ $row['plan'] }}</td>
                        <td style="text-align: right;">${{ number_format($row['amount'], 2) }}</td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    @endif

    <div class="footer">
        <p>EZSCALE &mdash; Cloud Infrastructure Services &mdash; support@ezscale.cloud</p>
    </div>
</body>
</html>
