<div class="hero">
    <div>
        <h2 style="margin:0 0 6px;">Selamat datang, <?= esc($user['name']) ?></h2>
        <p style="margin:0; opacity:0.95;">Cek promo yang sedang berjalan sebelum melayani pelanggan.</p>
    </div>
</div>

<div class="panel">
    <span class="pill">Promo Aktif Hari Ini</span>
    <h3 style="margin:6px 0 14px;">Katalog reward yang bisa ditukar member hari ini</h3>
    <?php if (empty($activePromosToday)) : ?>
        <p class="muted" style="margin:0;">Tidak ada promo yang aktif hari ini.</p>
    <?php else : ?>
        <div class="table-wrap">
            <table>
                <thead>
                    <tr><th>Nama Promo</th><th>Layanan/Produk</th><th>Diskon</th><th>Poin Dibutuhkan</th><th>Periode</th></tr>
                </thead>
                <tbody>
                    <?php foreach ($activePromosToday as $promo) : ?>
                        <tr>
                            <td><?= esc($promo['name']) ?></td>
                            <td><?= esc($promo['item_name'] ?? '-') ?></td>
                            <td><?= $promo['discount_type'] === 'percent' ? esc($promo['discount_value']) . '%' : 'Rp ' . esc(number_format((int) $promo['discount_value'], 0, ',', '.')) ?></td>
                            <td><span class="pill" style="margin:0;"><?= esc(number_format((int) $promo['points_required'], 0, ',', '.')) ?> poin</span></td>
                            <td>
                                <?php if (!empty($promo['start_date']) || !empty($promo['end_date'])) : ?>
                                    <?= $promo['start_date'] ? esc(date('d/m/Y', strtotime($promo['start_date']))) : '-' ?>
                                    s/d
                                    <?= $promo['end_date'] ? esc(date('d/m/Y', strtotime($promo['end_date']))) : '-' ?>
                                <?php else : ?>
                                    <span class="muted">Selalu berlaku</span>
                                <?php endif; ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    <?php endif; ?>
</div>
