<?php $__env->startSection('title', 'Invoice ' . $invoice->invoice_number); ?>
<?php $__env->startSection('page-title', 'Invoice ' . $invoice->invoice_number); ?>
<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-lg-8">
        <div class="content-card">
            <div class="d-flex justify-content-between mb-4">
                <div>
                    <h2 class="mb-0"><?php echo e($invoice->invoice_number); ?></h2>
                    <span class="badge <?php echo e($invoice->statusBadgeClass()); ?> mt-2"><?php echo e(ucfirst($invoice->status)); ?></span>
                </div>
                <div class="text-end">
                    <h2 class="text-accent">$<?php echo e(number_format($invoice->amount, 2)); ?> <small><?php echo e($invoice->currency); ?></small></h2>
                    <small class="text-muted">Created <?php echo e($invoice->created_at->format('M d, Y')); ?></small>
                </div>
            </div>

            <hr>

            <div class="row">
                <div class="col-md-6">
                    <h6 class="text-uppercase text-muted small">Billed To</h6>
                    <p class="mb-0"><strong><?php echo e($invoice->user->name); ?></strong></p>
                    <p class="text-muted"><?php echo e($invoice->user->email); ?></p>
                    <p class="user-role-badge role-<?php echo e($invoice->user->role); ?>"><?php echo e($invoice->user->role); ?></p>
                </div>
                <div class="col-md-6 text-md-end">
                    <h6 class="text-uppercase text-muted small">Details</h6>
                    <p class="mb-0">Due: <strong><?php echo e($invoice->due_date?->format('M d, Y') ?? '—'); ?></strong></p>
                    <?php if($invoice->paid_at): ?><p>Paid: <strong><?php echo e($invoice->paid_at->format('M d, Y')); ?></strong></p><?php endif; ?>
                    <?php if($invoice->payment_method): ?><p>Method: <?php echo e(ucfirst($invoice->payment_method)); ?></p><?php endif; ?>
                </div>
            </div>

            <hr>

            <table class="table">
                <thead><tr><th>Description</th><th class="text-end">Amount</th></tr></thead>
                <tbody>
                <tr>
                    <td><?php echo e($invoice->package->name ?? 'Custom invoice'); ?>

                        <?php if($invoice->package): ?><br><small class="text-muted"><?php echo e($invoice->package->blogs_count); ?> blogs</small><?php endif; ?>
                    </td>
                    <td class="text-end">$<?php echo e(number_format($invoice->amount, 2)); ?></td>
                </tr>
                </tbody>
                <tfoot><tr><th>Total</th><th class="text-end">$<?php echo e(number_format($invoice->amount, 2)); ?> <?php echo e($invoice->currency); ?></th></tr></tfoot>
            </table>

            <?php if($invoice->notes): ?>
                <h6 class="text-uppercase text-muted small mt-4">Notes</h6>
                <p><?php echo e($invoice->notes); ?></p>
            <?php endif; ?>
        </div>

        <?php if($invoice->payments->isNotEmpty()): ?>
        <div class="content-card">
            <div class="content-card-header"><h3>Payment History</h3></div>
            <table class="table">
                <thead><tr><th>Date</th><th>Gateway</th><th>Transaction ID</th><th>Amount</th><th>Status</th></tr></thead>
                <tbody>
                <?php $__currentLoopData = $invoice->payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pay): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e($pay->created_at->format('M d, Y H:i')); ?></td>
                        <td><?php echo e(ucfirst($pay->gateway)); ?></td>
                        <td><code><?php echo e($pay->transaction_id); ?></code></td>
                        <td>$<?php echo e(number_format($pay->amount, 2)); ?></td>
                        <td><span class="badge bg-<?php echo e($pay->status === 'completed' ? 'success' : 'secondary'); ?>"><?php echo e(ucfirst($pay->status)); ?></span></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>
        <?php endif; ?>
    </div>

    <div class="col-lg-4">
        <div class="content-card">
            <div class="content-card-header"><h3>Actions</h3></div>
            <?php if($invoice->isUnpaid()): ?>
                <form action="<?php echo e(route('admin.invoices.markPaid', $invoice)); ?>" method="POST" class="mb-2">
                    <?php echo csrf_field(); ?> <button class="btn btn-success w-100">Mark as Paid</button>
                </form>
            <?php else: ?>
                <form action="<?php echo e(route('admin.invoices.markUnpaid', $invoice)); ?>" method="POST" class="mb-2">
                    <?php echo csrf_field(); ?> <button class="btn btn-outline-warning w-100">Mark as Unpaid</button>
                </form>
            <?php endif; ?>
            <form action="<?php echo e(route('admin.invoices.destroy', $invoice)); ?>" method="POST" onsubmit="return confirm('Delete invoice?')">
                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                <button class="btn btn-outline-danger w-100">Delete Invoice</button>
            </form>
            <a href="<?php echo e(route('admin.invoices.index')); ?>" class="btn btn-link w-100 mt-2">← Back to invoices</a>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.dashboard', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp82\htdocs\blog\resources\views/admin/invoices/show.blade.php ENDPATH**/ ?>