<style>
body { font-family: 'Courier New', Courier, monospace; }
.kot-wrap { max-width: 320px; margin: 0 auto; }
.kot-wrap h1 { font-size: 18px; font-weight: 900; text-align: center; letter-spacing: 2px; }
.kot-wrap .restaurant { text-align: center; font-size: 12px; color: #555; }
.kot-divider { border: none; border-top: 1px dashed #999; margin: 10px 0; }
.kot-meta { font-size: 12px; margin-bottom: 8px; }
.kot-meta td { padding: 2px 4px; }
.kot-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kot-table th { font-size: 11px; text-transform: uppercase; border-bottom: 1px solid #333; padding: 4px 2px; }
.kot-table td { padding: 5px 2px; border-bottom: 1px dashed #ddd; vertical-align: top; }
.kot-footer { text-align: center; font-size: 11px; color: #888; margin-top: 12px; }
</style>

<div class="kot-wrap">
    <h1>KOT</h1>
    <div class="restaurant">Kitchen Order Ticket</div>
    <hr class="kot-divider">

    <table class="kot-meta">
        <tr><td><strong>Order #</strong></td><td><?= e($order['order_number']) ?></td></tr>
        <tr><td><strong>Type</strong></td><td><?= strtoupper($order['order_type'] ?? 'DELIVERY') ?></td></tr>
        <tr><td><strong>Time</strong></td><td><?= date('h:i A', strtotime($order['placed_at'])) ?></td></tr>
        <tr><td><strong>Customer</strong></td><td><?= e($order['customer_name']) ?></td></tr>
        <?php if ($order['delivery_address']): ?>
        <tr><td><strong>Address</strong></td><td style="font-size:11px;"><?= e($order['delivery_address']) ?></td></tr>
        <?php endif; ?>
    </table>

    <hr class="kot-divider">

    <table class="kot-table">
        <thead>
            <tr>
                <th>Item</th>
                <th style="text-align:center;width:35px;">Qty</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($items as $item): ?>
            <tr>
                <td>
                    <strong><?= e($item['item_name']) ?></strong>
                    <?php if ($item['choices_detail']): ?>
                    <div style="font-size:10px;color:#555;"><?= e($item['choices_detail']) ?></div>
                    <?php endif; ?>
                </td>
                <td style="text-align:center;font-weight:700;font-size:16px;"><?= $item['quantity'] ?></td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

    <?php if ($order['special_instructions']): ?>
    <hr class="kot-divider">
    <div style="font-size:11px;"><strong>NOTES:</strong> <?= e($order['special_instructions']) ?></div>
    <?php endif; ?>

    <hr class="kot-divider">
    <div class="kot-footer">
        Printed: <?= date('d/m/Y H:i') ?>
    </div>
</div>
