<?php
$setting = function_exists('app_setting') ? app_setting() : [];
$appName = trim((string) ($setting['nama_perusahaan'] ?? $setting['nama_aplikasi'] ?? 'Nusa POS')) ?: 'Nusa POS';
$tanggal = ! empty($transaksi['tanggal_penjualan']) ? date('d/m/Y', strtotime($transaksi['tanggal_penjualan'])) : date('d/m/Y');
$jam = ! empty($transaksi['created_at']) ? date('H:i', strtotime($transaksi['created_at'])) : date('H:i');
$totalDibayar = (float) ($totalDibayar ?? 0);
$totalPenjualan = (float) ($transaksi['total_penjualan'] ?? 0);
$sisa = max(0, $totalPenjualan - $totalDibayar);
?>
<!doctype html>
<html lang="id">
<head>
    <meta charset="utf-8">
    <title>Nota <?= esc($transaksi['no_transaksi'] ?? '') ?></title>
    <style>
        @page {
            size: 58mm 297mm;
            margin: 0;
        }

        * {
            box-sizing: border-box;
        }

        html,
        body {
            width: 58mm;
            margin: 0;
            padding: 0;
            background: #fff;
            color: #111;
            font-family: "Courier New", Courier, monospace;
            font-size: 10px;
            line-height: 1.25;
        }

        .receipt {
            width: 58mm;
            min-height: 0;
            margin: 0;
            padding: 3mm;
            background: #fff;
        }

        .header {
            text-align: center;
        }

        .store-name {
            font-size: 12px;
            font-weight: 700;
            text-transform: uppercase;
            overflow-wrap: anywhere;
        }

        .muted {
            color: #333;
        }

        .line {
            border-top: 1px dashed #111;
            margin: 5px 0;
        }

        .row {
            display: flex;
            justify-content: space-between;
            gap: 8px;
        }

        .label {
            flex: 0 0 auto;
        }

        .value {
            text-align: right;
            overflow-wrap: anywhere;
        }

        .item {
            margin-bottom: 5px;
        }

        .item-name {
            font-weight: 700;
            overflow-wrap: anywhere;
        }

        .item-calc {
            display: flex;
            justify-content: space-between;
            gap: 8px;
            padding-left: 5px;
        }

        .totals .row {
            margin: 2px 0;
        }

        .total-main {
            font-weight: 700;
            font-size: 11px;
        }

        .footer {
            margin-top: 8px;
            text-align: center;
        }
    </style>
</head>
<body>
    <?= view('admin/penjualan/partials/nota_thermal_body', get_defined_vars()) ?>
</body>
</html>
