<?php $__env->startSection('title', 'Payment Transactions Ledger'); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-6">
    <!-- Header Row & Export CSV Trigger -->
    <div class="flex items-center justify-between">
        <div>
            <h2 class="text-2xl font-extrabold text-white tracking-tight">Payment Transactions Ledger</h2>
            <p class="text-xs text-slate-400 mt-1">Audit log of all completed, pending, and refunded payment gateway transactions.</p>
        </div>
        <a href="<?php echo e(route('admin.payments.export')); ?>" class="flex items-center gap-2 bg-slate-800 hover:bg-slate-700 text-white font-semibold text-xs px-4 py-2.5 rounded-xl border border-slate-700 transition-all">
            <i data-lucide="download" class="w-4 h-4 text-emerald-400"></i>
            <span>Export CSV Report</span>
        </a>
    </div>

    <!-- Search & Gateway Filter Bar -->
    <div class="glass-card p-4 rounded-2xl flex flex-col md:flex-row gap-4 items-center justify-between">
        <form action="<?php echo e(route('admin.payments.index')); ?>" method="GET" class="flex items-center gap-3 w-full md:w-auto flex-1">
            <div class="relative flex-1 max-w-md">
                <i data-lucide="search" class="w-4 h-4 absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-500"></i>
                <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search TXN Ref, Client, or Company..." class="w-full bg-slate-950 border border-slate-800 text-slate-200 text-xs rounded-xl pl-10 pr-4 py-2.5 focus:outline-none focus:border-indigo-500">
            </div>

            <select name="method" onchange="this.form.submit()" class="bg-slate-950 border border-slate-800 text-slate-300 text-xs rounded-xl px-4 py-2.5 focus:outline-none focus:border-indigo-500">
                <option value="">All Gateways</option>
                <option value="Stripe" <?php echo e(request('method') == 'Stripe' ? 'selected' : ''); ?>>Stripe</option>
                <option value="Credit Card" <?php echo e(request('method') == 'Credit Card' ? 'selected' : ''); ?>>Credit Card</option>
                <option value="Bank Transfer" <?php echo e(request('method') == 'Bank Transfer' ? 'selected' : ''); ?>>Bank Transfer</option>
                <option value="PayPal" <?php echo e(request('method') == 'PayPal' ? 'selected' : ''); ?>>PayPal</option>
            </select>

            <button type="submit" class="bg-slate-800 text-slate-300 px-4 py-2.5 rounded-xl text-xs font-semibold border border-slate-700">Filter</button>
        </form>

        <span class="text-xs text-slate-400 font-medium">Showing <?php echo e($payments->total()); ?> Total Transactions</span>
    </div>

    <!-- Payments Ledger Table -->
    <div class="glass-card rounded-2xl overflow-hidden">
        <div class="overflow-x-auto">
            <table class="w-full text-left text-xs text-slate-300">
                <thead class="bg-slate-900/90 text-slate-400 uppercase text-[10px] font-bold tracking-wider border-b border-slate-800">
                    <tr>
                        <th class="py-4 px-6">Transaction Ref</th>
                        <th class="py-4 px-6">Client Company</th>
                        <th class="py-4 px-6">Invoice #</th>
                        <th class="py-4 px-6">Gateway Method</th>
                        <th class="py-4 px-6">Amount Paid</th>
                        <th class="py-4 px-6">Status</th>
                        <th class="py-4 px-6">Timestamp</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-slate-800/60 font-medium">
                    <?php $__empty_1 = true; $__currentLoopData = $payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pay): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr class="hover:bg-slate-900/40 transition-colors">
                            <td class="py-4 px-6 font-mono text-indigo-400 font-bold"><?php echo e($pay->transaction_reference); ?></td>
                            <td class="py-4 px-6">
                                <p class="text-xs font-bold text-white"><?php echo e($pay->client->company ?? 'N/A'); ?></p>
                                <p class="text-[11px] text-slate-400"><?php echo e($pay->client->name ?? ''); ?></p>
                            </td>
                            <td class="py-4 px-6 font-mono text-slate-300"><?php echo e($pay->invoice->invoice_number ?? 'N/A'); ?></td>
                            <td class="py-4 px-6">
                                <span class="inline-flex items-center gap-1.5 px-3 py-1 rounded-lg text-xs bg-slate-900 border border-slate-800 text-slate-200">
                                    <i data-lucide="credit-card" class="w-3.5 h-3.5 text-indigo-400"></i>
                                    <?php echo e($pay->payment_method); ?>

                                </span>
                            </td>
                            <td class="py-4 px-6 font-extrabold text-emerald-400 text-sm">$<?php echo e(number_format($pay->amount, 2)); ?></td>
                            <td class="py-4 px-6">
                                <?php if($pay->status === 'Success'): ?>
                                    <span class="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-bold bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">
                                        <span class="w-1.5 h-1.5 rounded-full bg-emerald-400"></span> Success
                                    </span>
                                <?php elseif($pay->status === 'Refunded'): ?>
                                    <span class="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-bold bg-amber-500/10 text-amber-400 border border-amber-500/20">
                                        <span class="w-1.5 h-1.5 rounded-full bg-amber-400"></span> Refunded
                                    </span>
                                <?php else: ?>
                                    <span class="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-bold bg-rose-500/10 text-rose-400 border border-rose-500/20">
                                        <span class="w-1.5 h-1.5 rounded-full bg-rose-400"></span> Failed
                                    </span>
                                <?php endif; ?>
                            </td>
                            <td class="py-4 px-6 text-slate-400 font-mono"><?php echo e($pay->paid_at->format('M d, Y H:i')); ?></td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="7" class="py-8 text-center text-slate-500">No payment transaction records found.</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <div class="p-4 border-t border-slate-800">
            <?php echo e($payments->links()); ?>

        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\RentEz\Desktop\projects\billingCRM\resources\views/admin/payments/index.blade.php ENDPATH**/ ?>