<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $title ?></title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: 'Courier New', monospace;
            font-size: 11px;
            line-height: 1.2;
            width: 80mm;
            padding: 5mm;
        }
        /* Semua teks dibuat tebal */
        body * {
            font-weight: bold;
        }
        .struk-header {
            text-align: center;
            margin-bottom: 8px;
            border-bottom: 1px dashed #000;
            padding-bottom: 8px;
        }
        .struk-title {
            font-size: 13px;
            margin-bottom: 3px;
        }
        .struk-subtitle {
            font-size: 10px;
            margin-bottom: 3px;
        }
        .section-title {
            margin: 6px 0 3px 0;
            border-bottom: 1px solid #000;
        }
        .detail-item {
            margin: 3px 0;
            display: flex;
            justify-content: space-between;
        }
        .detail-label {
            min-width: 40%;
        }
        .nomor-antrian {
            font-size: 20px;
            text-align: center;
            margin: 8px 0;
            padding: 8px;
            border: 2px solid #000;
            background: #f0f0f0;
        }
        .divider {
            border-top: 1px dashed #000;
            margin: 6px 0;
            padding-top: 6px;
        }
        .footer {
            text-align: center;
            font-size: 9px;
            margin-top: 8px;
        }
        .barcode-placeholder {
            text-align: center;
            margin: 6px 0;
            font-family: 'Libre Barcode 39', monospace;
            font-size: 18px;
        }
        @media print {
            body {
                width: 80mm;
                margin: 0;
                padding: 5mm;
            }
            .no-print {
                display: none;
            }
        }
    </style>
</head>
<body onload="window.print(); setTimeout(function(){ window.close(); }, 1000);">
    <div class="struk-header">
        <div class="struk-title">RS Poltekkes Kemenkes Semarang</div>
        <div class="struk-subtitle">BUKTI REGISTRASI PASIEN</div>
    </div>

    <div class="section-title">DATA PASIEN</div>
    
    <div class="detail-item">
        <span class="detail-label">No. RM:</span>
        <span><?= $registrasi->rme_no ?></span>
    </div>
    
    <div class="detail-item">
        <span class="detail-label">Nama:</span>
        <span><?= substr($registrasi->nama_lengkap, 0, 25) ?></span>
    </div>
    
    <div class="detail-item">
        <span class="detail-label">NIK:</span>
        <span><?= $registrasi->nik ?></span>
    </div>

    <div class="section-title">REGISTRASI</div>
    
    <div class="detail-item">
        <span class="detail-label">Poli:</span>
        <span><?= $registrasi->nama_poli ?></span>
    </div>
    
    <?php if ($registrasi->nama_dokter): ?>
    <div class="detail-item">
        <span class="detail-label">Dokter:</span>
        <span><?= $registrasi->nama_dokter ?></span>
    </div>
    <?php endif; ?>
    
    <div class="detail-item">
        <span class="detail-label">Tanggal:</span>
        <span><?= date('d/m/Y H:i', strtotime($registrasi->created_at)) ?></span>
    </div>
    
    <div class="detail-item">
        <span class="detail-label">Pembayaran:</span>
        <span><?= $registrasi->tipe_pembayaran ?></span>
    </div>

    <?php if ($registrasi->nomor_antrian): ?>
    <div class="nomor-antrian">
        ANTRIAN POLI: <?= str_pad($registrasi->nomor_antrian, 3, '0', STR_PAD_LEFT) ?>
    </div>
    
    <div class="barcode-placeholder">
        *P<?= str_pad($registrasi->nomor_antrian, 3, '0', STR_PAD_LEFT) ?>*
    </div>
    <?php endif; ?>

    <div class="divider"></div>

    <div class="footer">
        <div>Simpan struk ini sebagai bukti registrasi</div>
        <div>Terima kasih atas kunjungan Anda</div>
    </div>

    <div class="no-print" style="text-align: center; margin-top: 20px;">
        <button onclick="window.print()">Print Ulang</button>
        <button onclick="window.close()">Tutup</button>
    </div>
</body>
</html>
