<?php $__env->startSection('title', 'Billing'); ?>

<?php $__env->startSection('content'); ?>
<div class="pg-head">
    <div>
        <h1>Billing</h1>
        <p>Per-event invoices, manual payments, promo codes, and organisation credits.</p>
    </div>
    <div class="pg-actions">
        <a href="<?php echo e(route('mexco.super.invoices')); ?>" class="btn-outline">All invoices</a>
        <a href="<?php echo e(route('mexco.super.promos.create')); ?>" class="btn-purple">+ Promo code</a>
    </div>
</div>

<div class="stat-row">
    <div class="card stat-card">
        <div class="stat-label">Outstanding</div>
        <div class="stat-num" style="font-size:1.25rem">MYR <?php echo e(number_format($stats['outstanding_cents'] / 100, 0)); ?></div>
    </div>
    <div class="card stat-card">
        <div class="stat-label">Pending invoices</div>
        <div class="stat-num"><?php echo e($stats['pending']); ?></div>
    </div>
    <div class="card stat-card">
        <div class="stat-label">Paid this month</div>
        <div class="stat-num" style="font-size:1.25rem;color:var(--mexco-success)">MYR <?php echo e(number_format($stats['paid_this_month_cents'] / 100, 0)); ?></div>
    </div>
    <div class="card stat-card">
        <div class="stat-label">Overdue</div>
        <div class="stat-num" style="color:<?php echo e($stats['overdue'] ? 'var(--mexco-danger)' : 'inherit'); ?>"><?php echo e($stats['overdue']); ?></div>
    </div>
</div>

<div class="card">
    <div class="form-panel" style="padding-bottom:.75rem">
        <h2 style="font-size:1rem;margin:0 0 .35rem">Recent invoices</h2>
        <p class="panel-lead" style="margin:0">Draft invoices are created automatically when paid plans are assigned to events.</p>
    </div>
    <div class="tbl-wrap">
        <table class="data-tbl">
            <thead>
                <tr>
                    <th>Invoice</th>
                    <th>Organisation</th>
                    <th>Event</th>
                    <th>Total</th>
                    <th>Status</th>
                    <th style="text-align:right">Actions</th>
                </tr>
            </thead>
            <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $recentInvoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $inv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <?php
                        $pill = match($inv->status) {
                            'paid' => 'success',
                            'pending' => 'accent',
                            'cancelled', 'failed' => 'muted',
                            default => '',
                        };
                    ?>
                    <tr>
                        <td class="mono"><?php echo e($inv->invoice_number); ?></td>
                        <td><?php echo e($inv->organisation?->name ?? '-'); ?></td>
                        <td>
                            <div class="cell-name"><?php echo e($inv->event?->name ?? '-'); ?></div>
                            <?php if($inv->event_id): ?><div class="cell-sub mono"><?php echo e($inv->event_id); ?></div><?php endif; ?>
                        </td>
                        <td><?php echo e($inv->formattedTotal()); ?></td>
                        <td><span class="status-pill <?php echo e($pill); ?>"><?php echo e($inv->statusLabel()); ?></span></td>
                        <td><a href="<?php echo e(route('mexco.super.invoices.show', $inv)); ?>" class="btn-outline btn-sm">View</a></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="6" class="text-center cell-sub py-4">No invoices yet. Create an event with a paid plan to generate one.</td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('super-admin.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\myapp\resources\views/super-admin/billing/index.blade.php ENDPATH**/ ?>