<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Invoice - <?php echo e($pesanan->kode_pesanan); ?></title>
    <style>
        /* General Settings */
        body { 
            font-family: 'Helvetica', 'Arial', sans-serif; 
            font-size: 8pt; 
            color: #1a1a1a; 
            line-height: 1.25; 
            margin: 0; 
            padding: 0;
            background: #fff; 
        }

        /* Page Layout - Minimal Margins to Fit 1 Page */
        @page { 
            size: A4 portrait; 
            margin: 8mm 10mm; 
        }
        
        .container { 
            width: 100%; 
        }

        /* Header Layout */
        .header-table { 
            width: 100%; 
            margin-bottom: 8px; 
            border-collapse: collapse; 
        }
        .logo-text { 
            font-size: 18pt; 
            font-weight: 900; 
            color: #ea580c; 
            letter-spacing: 0.5px; 
        }
        .invoice-label { 
            font-size: 16pt; 
            font-weight: 700; 
            color: #000; 
            text-align: right; 
            text-transform: uppercase; 
        }

        /* Meta Information */
        .meta-table { 
            width: 100%; 
            margin-bottom: 12px; 
            border-collapse: collapse; 
        }
        .meta-table td { 
            padding: 2px 0; 
            font-size: 8.5pt; 
            vertical-align: top;
        }
        .meta-label { 
            width: 100px; 
            color: #555; 
            font-weight: normal; 
        }
        .meta-colon {
            width: 10px;
            color: #555;
        }
        .meta-value {
            font-weight: bold;
            color: #000;
        }
        .invoice-id {
            color: #ea580c;
        }
        .status-badge { 
            background: #dcfce7; 
            color: #16a34a; 
            padding: 1px 6px; 
            border-radius: 3px; 
            font-weight: bold; 
            font-size: 6.5pt; 
            text-transform: uppercase; 
            margin-left: 8px;
            display: inline-block;
        }

        /* Product Table */
        .product-table { 
            width: 100%; 
            border-collapse: collapse; 
            margin-bottom: 10px; 
            page-break-inside: avoid;
        }
        .product-table th { 
            background: #111; 
            color: #fff; 
            padding: 6px 10px; 
            text-align: left; 
            font-size: 7.5pt; 
            font-weight: bold; 
            text-transform: uppercase; 
        }
        .product-table td { 
            padding: 15px; 
            border-bottom: 1px solid #f2f2f2; 
            vertical-align: top; 
        }
        .product-name { 
            font-weight: bold; 
            color: #ea580c; 
            font-size: 9pt; 
            margin-bottom: 4px; 
            text-transform: lowercase;
        }
        .product-meta { 
            font-size: 7.5pt; 
            color: #888; 
            line-height: 1.3;
        }
        
        /* Summary Table Alignment */
        .summary-section {
            width: 100%;
            margin-bottom: 20px;
            text-align: right;
        }
        .summary-table { 
            width: 320px; 
            display: inline-table;
            border-collapse: collapse; 
        }
        .summary-table td { 
            padding: 5px 0; 
            font-size: 9pt; 
        }
        .summary-label { 
            text-align: left; 
            color: #666; 
        }
        .summary-value { 
            text-align: right; 
            font-weight: bold; 
            color: #111; 
        }
        .total-row td { 
            padding-top: 15px;
            margin-top: 5px;
        }
        .total-label { 
            font-size: 10pt; 
            font-weight: bold; 
            color: #111; 
        }
        .total-amount { 
            font-size: 13pt; 
            font-weight: bold; 
            color: #ea580c; 
        }

        /* Footer Columns (Alamat, Metode) */
        .footer-cols { 
            width: 100%; 
            border-collapse: collapse; 
            margin-top: 20px;
        }
        .footer-cols td { 
            vertical-align: top; 
        }
        .footer-header { 
            font-size: 8.5pt; 
            font-weight: bold; 
            color: #999; 
            text-transform: uppercase; 
            padding-bottom: 6px; 
            border-bottom: 1px solid #eeeeee;
            margin-bottom: 12px;
            display: block;
            width: 100%;
        }
        .footer-content { 
            font-size: 9pt; 
            color: #333; 
            line-height: 1.5; 
        }
        
        /* Disclaimer */
        .bottom-notes {
            margin-top: 30px;
            padding-top: 15px;
            border-top: 1px solid #f0f0f0;
            color: #bbb;
            font-size: 7.5pt;
        }
        .update-stamp {
            text-align: right;
            font-style: italic;
            font-size: 7pt;
            color: #ddd;
            margin-top: 4px;
        }

        /* Helper Classes */
        .text-right { text-align: right; }
        .text-center { text-align: center; }
        .uppercase { text-transform: uppercase; }
        .bold { font-weight: bold; }
    </style>
</head>
<body>
<div class="container">
    
    <!-- HEADER -->
    <table class="header-table">
        <tr>
            <td>
                <div class="logo-text">RAJA FUTSAL</div>
            </td>
            <td>
                <div class="invoice-label">INVOICE</div>
            </td>
        </tr>
    </table>

    <!-- META INFO -->
    <table class="meta-table">
        <tr>
            <td class="meta-label">No. Invoice</td>
            <td class="meta-colon">:</td>
            <td class="meta-value">
                <span class="invoice-id"><?php echo e($pesanan->kode_pesanan); ?></span>
                <span class="status-badge">Lunas</span>
            </td>
        </tr>
        <tr>
            <td class="meta-label">Penjual</td>
            <td class="meta-colon">:</td>
            <td class="meta-value">Raja Futsal</td>
        </tr>
        <tr>
            <td class="meta-label">Pembeli</td>
            <td class="meta-colon">:</td>
            <td class="meta-value"><?php echo e($pesanan->alamat->nama_penerima ?? $pesanan->user->name); ?></td>
        </tr>
        <tr>
            <td class="meta-label">Tanggal Pembelian</td>
            <td class="meta-colon">:</td>
            <td class="meta-value"><?php echo e($pesanan->created_at->translatedFormat('d F Y')); ?></td>
        </tr>
    </table>

    <!-- PRODUCT TABLE -->
    <table class="product-table">
        <thead>
            <tr>
                <th style="width: 50%;">INFO PRODUK</th>
                <th class="text-center" style="width: 10%;">JUMLAH</th>
                <th class="text-right" style="width: 20%;">HARGA SATUAN</th>
                <th class="text-right" style="width: 20%;">TOTAL HARGA</th>
            </tr>
        </thead>
        <tbody>
            <?php $__currentLoopData = $pesanan->detail; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $detail): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr>
                <td>
                    <div class="product-name"><?php echo e($detail->nama_produk); ?></div>
                    <div class="product-meta">
                        <?php if($detail->warna): ?> Warna: <?php echo e($detail->warna); ?> <?php endif; ?>
                        <?php if($detail->ukuran): ?> <?php if($detail->warna): ?> | <?php endif; ?> Ukuran: <?php echo e($detail->ukuran); ?> <?php endif; ?>
                        <?php if($detail->produk && $detail->produk->berat): ?> 
                            <br>Berat: <?php echo e($detail->produk->berat); ?> gr
                        <?php endif; ?>
                    </div>
                </td>
                <td class="text-center" style="vertical-align: middle;"><?php echo e($detail->qty); ?></td>
                <td class="text-right" style="vertical-align: middle;">Rp<?php echo e(number_format($detail->harga, 0, ',', '.')); ?></td>
                <td class="text-right" style="vertical-align: middle;">Rp<?php echo e(number_format($detail->subtotal, 0, ',', '.')); ?></td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>
    </table>

    <!-- SUMMARY SECTION -->
    <div class="summary-section">
        <table class="summary-table">
            <tr>
                <td class="summary-label">TOTAL HARGA (<?php echo e($pesanan->detail->sum('qty')); ?> BARANG)</td>
                <td class="summary-value">Rp<?php echo e(number_format($subtotalProduk, 0, ',', '.')); ?></td>
            </tr>
            <tr>
                <td class="summary-label">Total Ongkos Kirim</td>
                <td class="summary-value">Rp<?php echo e(number_format($ongkir, 0, ',', '.')); ?></td>
            </tr>
            <tr>
                <td class="summary-label">Total Jarak</td>
                <td class="summary-value"><?php echo e($jarakKm); ?> km (Rp<?php echo e(number_format($biayaJarak, 0, ',', '.')); ?>)</td>
            </tr>
            <tr>
                <td class="summary-label">Total Berat Produk</td>
                <td class="summary-value">
                    <?php $weightDisplay = $totalBerat >= 1000 ? number_format($totalBerat/1000, 2).' kg' : $totalBerat.' gr'; ?>
                    <?php echo e($weightDisplay); ?> (Rp<?php echo e(number_format($biayaBerat, 0, ',', '.')); ?>)
                </td>
            </tr>
            <tr>
                <td class="summary-label">Beda Provinsi atau Sama</td>
                <td class="summary-value"><?php echo e($kategoriProvinsi); ?> (Rp<?php echo e(number_format($biayaProvinsi, 0, ',', '.')); ?>)</td>
            </tr>
            <tr class="total-row">
                <td class="total-label">TOTAL BELANJA</td>
                <td class="total-amount">Rp<?php echo e(number_format($pesanan->total_harga, 0, ',', '.')); ?></td>
            </tr>
        </table>
    </div>

    <!-- ADDRESS AND PAYMENT METHOD -->
    <table class="footer-cols">
        <tr>
            <td style="width: 65%; padding-right: 40px;">
                <span class="footer-header">Alamat Pengiriman</span>
                <div class="footer-content">
                    <span class="bold"><?php echo e($pesanan->alamat->nama_penerima ?? $pesanan->user->name); ?></span> (<?php echo e($pesanan->alamat->no_hp ?? '-'); ?>)<br>
                    <?php echo e($pesanan->alamat->alamat_lengkap ?? ''); ?><br>
                    <?php echo e(strtoupper($pesanan->alamat->district->name ?? '')); ?>, <?php echo e(strtoupper($pesanan->alamat->city->name ?? '')); ?><br>
                    <?php echo e(strtoupper($pesanan->alamat->province->name ?? '')); ?> <?php echo e($pesanan->alamat->kode_pos ?? ''); ?>

                </div>
                
                <div style="margin-top: 25px;">
                    <span class="footer-header">Kurir</span>
                    <div class="footer-content bold">KurirSendiri-Raja Futsal</div>
                </div>
            </td>
            <td style="width: 35%; text-align: right;">
                <span class="footer-header">Metode Pembayaran</span>
                <div class="footer-content">
                    <?php if($pesanan->pembayaran): ?>
                        <span style="font-size: 11pt; font-weight: bold; color: #111;"><?php echo e(strtoupper(str_replace('_', ' ', $pesanan->pembayaran->metode))); ?></span>
                    <?php else: ?>
                        <span class="bold">BELUM BAYAR</span>
                    <?php endif; ?>
                </div>
            </td>
        </tr>
    </table>

    <!-- FOOTER NOTES -->
    <div class="bottom-notes">
        Invoice ini sah dan diproses oleh komputer.<br>
        Silakan hubungi <b>Raja Futsal</b> apabila kamu membutuhkan bantuan.
    </div>
    <div class="update-stamp">
        Terakhir diupdate: <?php echo e(now()->translatedFormat('d F Y H:i')); ?> WIB
    </div>

</div>
</body>
</html><?php /**PATH C:\laragon\www\ecommerce\resources\views/pesanan/invoice.blade.php ENDPATH**/ ?>