<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{ $meta['title'] ?? 'Profit & Loss 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 td { padding: 10px 12px; border-bottom: 1px solid #eee; }
        .row-label { font-weight: 600; }
        .row-amount { text-align: right; font-family: 'Courier New', monospace; }
        .row-revenue td { color: #16a34a; }
        .row-expense td { color: #dc2626; }
        .row-total { border-top: 2px solid #1d4ed8; }
        .row-total td { font-size: 16px; font-weight: bold; padding-top: 12px; }
        .section-header { background-color: #f1f5f9; }
        .section-header td { font-weight: bold; font-size: 13px; color: #475569; text-transform: uppercase; padding: 12px; }
        .margin-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 4px; padding: 15px; margin-top: 20px; text-align: center; }
        .margin-value { font-size: 24px; font-weight: bold; color: #1d4ed8; }
        .margin-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 class="data">
        <tr class="section-header">
            <td colspan="2">Revenue</td>
        </tr>
        <tr class="row-revenue">
            <td class="row-label">Gross Revenue</td>
            <td class="row-amount">${{ number_format($data['revenue'] ?? 0, 2) }}</td>
        </tr>

        <tr class="section-header">
            <td colspan="2">Expenses</td>
        </tr>
        <tr class="row-expense">
            <td class="row-label">Refunds</td>
            <td class="row-amount">(${{ number_format($data['refunds'] ?? 0, 2) }})</td>
        </tr>
        <tr class="row-expense">
            <td class="row-label">Payment Gateway Fees</td>
            <td class="row-amount">(${{ number_format($data['gateway_fees'] ?? 0, 2) }})</td>
        </tr>
        <tr class="row-expense">
            <td class="row-label">Infrastructure Cost (Est.)</td>
            <td class="row-amount">(${{ number_format($data['infrastructure_cost'] ?? 0, 2) }})</td>
        </tr>

        <tr class="row-total">
            <td class="row-label">Net Profit</td>
            <td class="row-amount" style="color: {{ ($data['net_profit'] ?? 0) >= 0 ? '#16a34a' : '#dc2626' }}">
                ${{ number_format($data['net_profit'] ?? 0, 2) }}
            </td>
        </tr>
    </table>

    <div class="margin-box">
        <div class="margin-value">{{ $data['margin_percentage'] ?? 0 }}%</div>
        <div class="margin-label">Profit Margin</div>
    </div>

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