<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <div class="rounded-2xl border border-sky-200/70 bg-gradient-to-r from-sky-50 to-green-50 px-5 py-4">
            <h2 class="font-semibold text-xl leading-tight text-sky-900">
                <?php echo e(__('Payment Dashboard')); ?>

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

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <!-- Statistics Cards -->
            <div class="mb-8 grid grid-cols-1 gap-6 md:grid-cols-4">
                <div class="rounded-2xl border border-sky-200/70 bg-gradient-to-br from-white to-sky-50 p-6 shadow-sm">
                    <div class="flex items-center">
                        <div class="flex-1">
                            <p class="text-sm text-sky-700"><?php echo e(__('Total Revenue')); ?></p>
                            <p class="text-2xl font-bold text-sky-900">$<?php echo e(number_format($stats['total'] ?? 0, 2)); ?></p>
                        </div>
                        <div class="rounded-full bg-sky-100 p-3">
                            <svg class="h-6 w-6 text-sky-600" fill="currentColor" viewBox="0 0 20 20">
                                <path d="M4 4a2 2 0 00-2 2v4a2 2 0 002 2V6h10a2 2 0 00-2-2H4zm2 6a2 2 0 012-2h8a2 2 0 012 2v4a2 2 0 01-2 2H8a2 2 0 01-2-2v-4zm6 4a2 2 0 100-4 2 2 0 000 4z" />
                            </svg>
                        </div>
                    </div>
                </div>

                <div class="rounded-2xl border border-sky-200/70 bg-gradient-to-br from-white to-sky-50 p-6 shadow-sm">
                    <div class="flex items-center">
                        <div class="flex-1">
                            <p class="text-sm text-sky-700"><?php echo e(__('Completed')); ?></p>
                            <p class="text-2xl font-bold text-sky-700">$<?php echo e(number_format($stats['completed'] ?? 0, 2)); ?></p>
                        </div>
                        <div class="rounded-full bg-green-100 p-3">
                            <svg class="h-6 w-6 text-green-600" fill="currentColor" viewBox="0 0 20 20">
                                <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
                            </svg>
                        </div>
                    </div>
                </div>

                <div class="rounded-2xl border border-sky-200/70 bg-gradient-to-br from-white to-sky-50 p-6 shadow-sm">
                    <div class="flex items-center">
                        <div class="flex-1">
                            <p class="text-sm text-sky-700"><?php echo e(__('Pending')); ?></p>
                            <p class="text-2xl font-bold text-amber-600">$<?php echo e(number_format($stats['pending'] ?? 0, 2)); ?></p>
                        </div>
                        <div class="rounded-full bg-amber-100 p-3">
                            <svg class="h-6 w-6 text-amber-600" fill="currentColor" viewBox="0 0 20 20">
                                <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v3.5a1 1 0 002 0V7zm0 7a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
                            </svg>
                        </div>
                    </div>
                </div>

                <div class="rounded-2xl border border-sky-200/70 bg-gradient-to-br from-white to-sky-50 p-6 shadow-sm">
                    <div class="flex items-center">
                        <div class="flex-1">
                            <p class="text-sm text-sky-700"><?php echo e(__('Failed')); ?></p>
                            <p class="text-2xl font-bold text-red-600"><?php echo e($stats['failed'] ?? 0); ?></p>
                        </div>
                        <div class="rounded-full bg-red-100 p-3">
                            <svg class="h-6 w-6 text-red-600" fill="currentColor" viewBox="0 0 20 20">
                                <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
                            </svg>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Payments Table -->
            <div class="overflow-hidden rounded-2xl border border-sky-200/70 bg-white shadow-sm">
                <div class="border-b border-sky-100 bg-sky-50/60 p-6">
                    <div class="flex justify-between items-center">
                        <h3 class="text-lg font-semibold text-gray-900"><?php echo e(__('Payment Transactions')); ?></h3>
                        <div class="flex gap-2">
                            <select onchange="filterByStatus(this.value)" class="rounded-lg border border-sky-300 bg-white px-4 py-2 text-sm focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-100">
                                <option value=""><?php echo e(__('All Status')); ?></option>
                                <option value="pending"><?php echo e(__('Pending')); ?></option>
                                <option value="completed"><?php echo e(__('Completed')); ?></option>
                                <option value="failed"><?php echo e(__('Failed')); ?></option>
                                <option value="refunded"><?php echo e(__('Refunded')); ?></option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="overflow-x-auto">
                    <table class="w-full">
                        <thead class="border-b border-sky-100 bg-sky-50/80">
                            <tr>
                                <th class="px-6 py-3 text-left text-sm font-semibold text-sky-800"><?php echo e(__('User')); ?></th>
                                <th class="px-6 py-3 text-left text-sm font-semibold text-sky-800"><?php echo e(__('Package')); ?></th>
                                <th class="px-6 py-3 text-left text-sm font-semibold text-sky-800"><?php echo e(__('Amount')); ?></th>
                                <th class="px-6 py-3 text-left text-sm font-semibold text-sky-800"><?php echo e(__('Method')); ?></th>
                                <th class="px-6 py-3 text-left text-sm font-semibold text-sky-800"><?php echo e(__('Status')); ?></th>
                                <th class="px-6 py-3 text-left text-sm font-semibold text-sky-800"><?php echo e(__('Date')); ?></th>
                                <th class="px-6 py-3 text-left text-sm font-semibold text-sky-800"><?php echo e(__('Actions')); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr class="border-b border-sky-100 hover:bg-sky-50/40">
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <div>
                                            <p class="font-semibold text-gray-900"><?php echo e($payment->subscription->user->name); ?></p>
                                            <p class="text-sm text-gray-600"><?php echo e($payment->subscription->user->email); ?></p>
                                        </div>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <span class="rounded-full bg-sky-100 px-3 py-1 text-sm font-semibold text-sky-800">
                                            <?php echo e($payment->subscription->package->name); ?>

                                        </span>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap font-semibold text-gray-900">
                                        $<?php echo e(number_format($payment->amount, 2)); ?>

                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">
                                        <?php echo e($payment->paymentMethod->name); ?>

                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <span class="px-3 py-1 rounded-full text-xs font-semibold
                                            <?php echo e($payment->status === 'completed' ? 'bg-green-100 text-green-800' : ''); ?>

                                            <?php echo e($payment->status === 'pending' ? 'bg-yellow-100 text-yellow-800' : ''); ?>

                                            <?php echo e($payment->status === 'failed' ? 'bg-red-100 text-red-800' : ''); ?>

                                            <?php echo e($payment->status === 'refunded' ? 'bg-gray-100 text-gray-800' : ''); ?>

                                        ">
                                            <?php echo e(ucfirst($payment->status)); ?>

                                        </span>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">
                                        <?php echo e($payment->created_at->format('M d, Y H:i')); ?>

                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm space-x-2">
                                        <a href="<?php echo e(route('admin.payments.show', $payment)); ?>"
                                            class="inline-block rounded bg-sky-600 px-3 py-1 text-xs text-white hover:bg-sky-700">
                                            <?php echo e(__('View')); ?>

                                        </a>
                                        <?php if($payment->status !== 'completed'): ?>
                                            <button onclick="updatePaymentStatus(<?php echo e($payment->id); ?>, 'completed')"
                                                class="inline-block px-3 py-1 bg-green-600 text-white rounded hover:bg-green-700 text-xs">
                                                <?php echo e(__('Mark Completed')); ?>

                                            </button>
                                        <?php endif; ?>
                                        <?php if($payment->status !== 'refunded'): ?>
                                            <button onclick="updatePaymentStatus(<?php echo e($payment->id); ?>, 'refunded')"
                                                class="inline-block px-3 py-1 bg-orange-600 text-white rounded hover:bg-orange-700 text-xs">
                                                <?php echo e(__('Refund')); ?>

                                            </button>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="7" class="px-6 py-4 text-center text-gray-500">
                                        <?php echo e(__('No payment records found')); ?>

                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>

                <?php if($payments->hasPages()): ?>
                    <div class="border-t border-sky-100 bg-sky-50/50 px-6 py-4">
                        <?php echo e($payments->links()); ?>

                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <!-- Payment Status Update Modal -->
    <form id="payment-status-form" method="POST" class="hidden">
        <?php echo csrf_field(); ?>
        <?php echo method_field('PATCH'); ?>
        <input type="hidden" name="status" id="payment-status-value" />
    </form>

    <script>
        function updatePaymentStatus(paymentId, status) {
            if (confirm(`<?php echo e(__('Are you sure you want to mark this payment as')); ?> ${status}?`)) {
                const form = document.getElementById('payment-status-form');
                form.action = `/admin/payments/${paymentId}/status`;
                document.getElementById('payment-status-value').value = status;
                form.submit();
            }
        }

        function filterByStatus(status) {
            // This would filter the table - you could use JS or redirect with query param
            if (status) {
                window.location.href = `<?php echo e(route('admin.payments.index')); ?>?status=${status}`;
            }
        }
    </script>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH D:\true-trucker\web\resources\views/admin/payments/index.blade.php ENDPATH**/ ?>