<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{ $meta['title'] ?? 'Refund 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 th.text-center { text-align: center; }
        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-row { display: flex; gap: 20px; margin-bottom: 20px; }
        .summary-box { background: #fef2f2; border: 1px solid #fecaca; border-radius: 4px; padding: 15px; text-align: center; width: 48%; display: inline-block; }
        .summary-value { font-size: 24px; font-weight: bold; color: #dc2626; }
        .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')

    <table width="100%" style="margin-bottom: 20px;">
        <tr>
            <td width="48%">
                <div class="summary-box">
                    <div class="summary-value">${{ number_format($data['total_refunds'] ?? 0, 2) }}</div>
                    <div class="summary-label">Total Refunds</div>
                </div>
            </td>
            <td width="4%"></td>
            <td width="48%">
                <div class="summary-box">
                    <div class="summary-value">{{ $data['refund_count'] ?? 0 }}</div>
                    <div class="summary-label">Refund Count</div>
                </div>
            </td>
        </tr>
    </table>

    @if(!empty($data['by_gateway']))
        <div class="section-title">Refunds by Gateway</div>
        <table class="data">
            <thead>
                <tr>
                    <th>Gateway</th>
                    <th class="text-right" style="text-align: right;">Amount</th>
                    <th class="text-center" style="text-align: center;">Count</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>
                        <td style="text-align: center;">{{ $row['count'] }}</td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    @endif

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

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