<div style="max-width: 250px; font-family: monospace; font-size: 12px; margin: auto;">
    <div style="text-align: center;">
        <h4><?= esc($setting['nama_toko'] ?? 'TOKO KAMI') ?></h4>
        <p><?= esc($setting['alamat'] ?? '-') ?></p>
        <hr>
    </div>

    <p><strong>Kode:</strong> <?= esc($sale['kode']) ?></p>
    <p><strong>Tanggal:</strong> <?= date('d-m-Y H:i:s', strtotime($sale['tanggal'])) ?></p>
    <p><strong>Kasir:</strong> <?= esc($sale['kasir'] ?? '-') ?></p>
    <p><strong>Pelanggan:</strong> <?= esc($sale['customer_name'] ?? '-') ?></p>
    <p><strong>Metode Bayar:</strong> <?= ucfirst($sale['payment_method']) ?></p>

    <table width="100%" style="margin-top: 10px;">
        <thead>
            <tr style="border-bottom: 1px dashed #000;">
                <th style="text-align: left;">Item</th>
                <th style="text-align: right;">Qty</th>
                <th style="text-align: right;">Harga</th>
                <th style="text-align: right;">Sub</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($details as $d): ?>
            <tr>
                <td><?= esc($d['nama_item']) ?></td>
                <td style="text-align: right;"><?= $d['qty'] ?></td>
                <td style="text-align: right;">Rp<?= number_format($d['total']) ?></td>
                <td style="text-align: right;">Rp<?= number_format($d['subtotal']) ?></td>
            </tr>
            <?php endforeach ?>
        </tbody>
    </table>

    <hr>
    <table width="100%">
        <tr>
            <td><strong>Total</strong></td>
            <td style="text-align: right;"><strong>Rp<?= number_format($sale['total']) ?></strong></td>
        </tr>

        <?php if (!empty($sale['tax_percent']) && $sale['tax_percent'] > 0): ?>
        <tr>
            <td>Pajak (<?= $sale['tax_name'] ?> <?= $sale['tax_percent'] ?>%)</td>
            <td style="text-align: right;">Rp<?= number_format($sale['tax_amount']) ?></td>
        </tr>
        <tr>
            <td><strong>Grand Total</strong></td>
            <td style="text-align: right;"><strong>Rp<?= number_format($sale['grand_total']) ?></strong></td>
        </tr>
        <?php else: ?>
        <tr>
            <td><strong>Grand Total</strong></td>
            <td style="text-align: right;"><strong>Rp<?= number_format($sale['total']) ?></strong></td>
        </tr>
        <?php endif ?>

        <tr>
            <td>Dibayar</td>
            <td style="text-align: right;">Rp<?= number_format($sale['dibayar']) ?></td>
        </tr>
        <tr>
            <td>Kembali</td>
            <td style="text-align: right;">Rp<?= number_format($sale['kembali']) ?></td>
        </tr>
    </table>

    <hr>
    <div style="text-align: center;">
        <p>-- TERIMA KASIH --</p>
    </div>
</div>
