<?= $this->extend('admin/layout/main') ?>
<?= $this->section('content') ?>

<h3 class="mb-4"><?= lang('App.dashboard') ?></h3>

<div class="row mb-4">
    <div class="col-md-4">
        <div class="card p-3">
            <div class="text-muted small"><?= lang('App.revenue') ?> (<?= lang('App.this_month') ?>)</div>
            <div class="fs-4 fw-bold text-success"><?= number_format($pnl['revenue'], 2) ?></div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card p-3">
            <div class="text-muted small"><?= lang('App.expenses') ?> (<?= lang('App.this_month') ?>)</div>
            <div class="fs-4 fw-bold text-danger"><?= number_format($pnl['expenses'], 2) ?></div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card p-3">
            <div class="text-muted small"><?= lang('App.net_profit') ?></div>
            <div class="fs-4 fw-bold"><?= number_format($pnl['net_profit'], 2) ?></div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-md-6">
        <div class="card p-3">
            <h6><?= lang('App.upcoming_renewals') ?></h6>
            <?php foreach ($upcomingRenewals as $s): ?>
                <div class="d-flex justify-content-between border-bottom py-2 small">
                    <span><?= esc($s['name']) ?></span>
                    <span><?= esc($s['renewal_date']) ?></span>
                </div>
            <?php endforeach; ?>
            <?php if (empty($upcomingRenewals)): ?><p class="text-muted small"><?= lang('App.no_data') ?></p><?php endif; ?>
        </div>
    </div>
    <div class="col-md-6">
        <div class="card p-3">
            <h6><?= lang('App.recent_invoices') ?></h6>
            <?php foreach ($recentInvoices as $inv): ?>
                <div class="d-flex justify-content-between border-bottom py-2 small">
                    <span><?= esc($inv['invoice_number']) ?></span>
                    <span><?= number_format($inv['amount'], 2) ?> <?= esc($inv['currency']) ?></span>
                </div>
            <?php endforeach; ?>
            <?php if (empty($recentInvoices)): ?><p class="text-muted small"><?= lang('App.no_data') ?></p><?php endif; ?>
        </div>
    </div>
</div>

<?= $this->endSection() ?>
