<!DOCTYPE html>
<html lang="en" data-bs-theme="light">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Commercial Invoice - <?php echo e($invoice->invoice_number); ?></title>
    <?php echo $__env->make('components.style', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    <style>
        body {
            background-color: #fff;
            padding: 20px;
        }
        .invoice-box {
            max-width: 800px;
            margin: auto;
            padding: 30px;
            border: 1px solid #eee;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
            font-size: 16px;
            line-height: 24px;
            font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
            color: #555;
        }
        .invoice-box table {
            width: 100%;
            line-height: inherit;
            text-align: left;
            border-collapse: collapse;
        }
        .invoice-box table td, .invoice-box table th {
            padding: 5px;
            vertical-align: top;
        }
        .invoice-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
        }
        .invoice-title {
            font-size: 32px;
            font-weight: bold;
            color: #333;
        }
        .company-info {
            text-align: right;
        }
        .customer-info {
            margin-bottom: 20px;
            padding-top: 10px;
            border-top: 2px solid #eee;
        }
        .items-table {
            margin-top: 20px;
        }
        .items-table th {
            background: #f8f8f8;
            border-bottom: 2px solid #ddd;
        }
        .items-table td, .items-table th {
            border: 1px solid #eee;
        }
        .summary-box {
            width: 300px;
            float: right;
            margin-top: 20px;
        }
        @media print {
            .invoice-box {
                box-shadow: none;
                border: 0;
            }
            body {
                -webkit-print-color-adjust: exact !important;
                print-color-adjust: exact !important;
            }
            .no-print {
                display: none !important;
            }
        }
    </style>
</head>
<body>
    <div class="text-center mb-3 no-print">
        <button onclick="window.print()" class="btn btn-primary"><i class="fas fa-print"></i> Print Invoice</button>
        <button onclick="window.close()" class="btn btn-secondary">Close</button>
    </div>

    <div class="invoice-box">
        <div class="invoice-header">
            <div>
                <img src="<?php echo e(asset('assets/images/logo.png')); ?>" style="max-height: 60px;" alt="Logo" onerror="this.style.display='none'">
                <h4 class="mt-2"><?php echo e(config('app.name', 'Habib Cables')); ?></h4>
            </div>
            <div class="company-info">
                <div class="invoice-title">COMMERCIAL INVOICE</div>
                <div class="mt-2">
                    <strong>Invoice #:</strong> <?php echo e($invoice->invoice_number); ?><br>
                    <strong>Date:</strong> <?php echo e($invoice->invoice_date ? $invoice->invoice_date->format('M d, Y') : 'N/A'); ?><br>
                    <strong>Status:</strong> <?php echo e(ucfirst(str_replace('_', ' ', $invoice->status))); ?>

                </div>
            </div>
        </div>

        <div class="customer-info row">
            <div class="col-6">
                <strong>Billed To:</strong><br>
                <?php echo e($invoice->customer->name ?? 'N/A'); ?><br>
                <?php echo e($invoice->customer->contact->phone ?? ''); ?><br>
                <?php echo e($invoice->customer->contact->email ?? ''); ?>

            </div>
            <div class="col-6 text-end">
                <strong>Sales Rep:</strong><br>
                <?php echo e($invoice->supervisingEmployee->name ?? 'N/A'); ?>

            </div>
        </div>

        <table class="items-table table table-sm mt-4">
            <thead>
                <tr>
                    <th>Item</th>
                    <th class="text-center">Qty</th>
                    <th class="text-end">Price</th>
                    <th class="text-end">Total</th>
                </tr>
            </thead>
            <tbody>
                <?php $__currentLoopData = $invoice->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td>
                            <strong><?php echo e($item->item->name ?? 'N/A'); ?></strong><br>
                            <small class="text-muted"><?php echo e($item->item->sku ?? ''); ?></small>
                        </td>
                        <td class="text-center"><?php echo e($item->ordered_quantity); ?></td>
                        <td class="text-end"><?php echo e(number_format($item->ordered_unit_price, 2)); ?></td>
                        <td class="text-end"><?php echo e(number_format($item->ordered_total, 2)); ?></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
        </table>

        <div class="row mt-4">
            <div class="col-6">
                <?php if($invoice->remarks): ?>
                    <strong>Notes:</strong><br>
                    <p class="text-muted"><?php echo e($invoice->remarks); ?></p>
                <?php endif; ?>
            </div>
            <div class="col-6">
                <table class="table table-sm table-borderless summary-box">
                    <tr>
                        <td><strong>SubTotal:</strong></td>
                        <td class="text-end">Rs. <?php echo e(number_format($invoice->total_ordered_amount, 2)); ?></td>
                    </tr>
                    <?php if($invoice->discount_amount > 0): ?>
                    <tr>
                        <td><strong>Discount:</strong></td>
                        <td class="text-end text-danger">-Rs. <?php echo e(number_format($invoice->discount_amount, 2)); ?></td>
                    </tr>
                    <?php endif; ?>
                    <tr class="border-top">
                        <td class="fs-5"><strong>Net Total:</strong></td>
                        <td class="text-end fs-5 fw-bold">Rs. <?php echo e(number_format($invoice->net_total, 2)); ?></td>
                    </tr>
                </table>
            </div>
        </div>
        
        <div class="text-center mt-5 pt-5 border-top text-muted">
            <small>Thank you for your business!</small>
        </div>
    </div>

    <?php echo $__env->make('components.script', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    <script>
        window.onload = function() {
            // Un-comment to auto-print
            // window.print();
        }
    </script>
</body>
</html>
<?php /**PATH C:\laragon\www\habibcables-ERP\resources\views\factory-pos\print\commercial_invoice.blade.php ENDPATH**/ ?>