<?php $__env->startSection('title', 'Wallet'); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-8">
    <div class="flex items-center justify-between">
        <div>
            <h1 class="text-2xl font-bold text-gray-900">Wallet</h1>
            <p class="mt-1 text-sm text-gray-500">Manage your wallet balance and transactions.</p>
        </div>
        <button id="openFundBtn" class="rounded-lg bg-green-950 px-4 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-green-700">Fund Wallet</button>
    </div>

    
    <div class="rounded-xl bg-gradient-to-br from-gray-900 to-gray-800 p-6 text-white">
        <p class="text-sm font-medium text-gray-300">Available Balance</p>
        <p class="mt-2 text-3xl font-bold">₦<?php echo e(number_format($wallet->balance, 2)); ?></p>
        <div class="mt-4 flex gap-6">
            <div>
                <p class="text-xs text-gray-400">Total Funded</p>
                <p class="text-sm font-semibold">₦<?php echo e(number_format($wallet->total_funded, 2)); ?></p>
            </div>
            <div>
                <p class="text-xs text-gray-400">Total Spent</p>
                <p class="text-sm font-semibold">₦<?php echo e(number_format($wallet->total_spent, 2)); ?></p>
            </div>
        </div>
    </div>

    
    <div class="rounded-xl bg-white shadow-sm border border-gray-100 overflow-hidden">
        <div class="px-6 py-4 border-b border-gray-100">
            <h2 class="text-lg font-semibold text-gray-900">Transaction History</h2>
        </div>
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-100">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Type</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Amount</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Balance After</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Date</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-50">
                    <?php $__empty_1 = true; $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tx): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="hover:bg-gray-50">
                        <td class="px-6 py-4 text-sm text-gray-900"><?php echo e($tx->description); ?></td>
                        <td class="px-6 py-4">
                            <span class="inline-flex items-center rounded-full <?php echo e($tx->type === 'credit' ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-700'); ?> px-2 py-1 text-xs font-medium">
                                <?php echo e(ucfirst($tx->type)); ?>

                            </span>
                        </td>
                        <td class="px-6 py-4 text-sm font-semibold <?php echo e($tx->type === 'credit' ? 'text-green-950' : 'text-red-600'); ?>">
                            <?php echo e($tx->type === 'credit' ? '+' : '-'); ?>₦<?php echo e(number_format($tx->amount, 2)); ?>

                        </td>
                        <td class="px-6 py-4 text-sm text-gray-900">₦<?php echo e(number_format($tx->balance_after, 2)); ?></td>
                        <td class="px-6 py-4 text-sm text-gray-500"><?php echo e($tx->created_at->format('M d, Y H:i')); ?></td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="5" class="px-6 py-12 text-center text-sm text-gray-500">No transactions yet.</td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <div class="px-6 py-4"><?php echo e($transactions->links()); ?></div>
    </div>
</div>


<div id="fundModal" class="hidden fixed inset-0 z-50 overflow-y-auto bg-black/50 flex items-center justify-center">
    <div id="fundModalContent" class="bg-white rounded-xl p-6 w-full max-w-md mx-4 shadow-2xl">
        <h3 class="text-lg font-semibold text-gray-900 mb-4">Fund Wallet</h3>
        <form method="POST" action="<?php echo e(route('wallet.fund')); ?>" id="fundForm">
            <?php echo csrf_field(); ?>
            <div class="mb-4">
                <label for="amount" class="block text-sm font-medium text-gray-700 mb-1">Amount (₦)</label>
                <input type="number" name="amount" id="amount" min="100" max="500000" required
                    class="block w-full rounded-md border-gray-300 shadow-sm focus:border-green-950 focus:ring-green-950 sm:text-sm px-3 py-2 border"
                    placeholder="Enter amount">
            </div>
            <div class="flex flex-wrap gap-2 mb-4">
                <button type="button" onclick="setAmount(1000)" class="rounded-md bg-gray-100 px-3 py-1.5 text-sm font-medium text-gray-700 hover:bg-gray-200">₦1,000</button>
                <button type="button" onclick="setAmount(2000)" class="rounded-md bg-gray-100 px-3 py-1.5 text-sm font-medium text-gray-700 hover:bg-gray-200">₦2,000</button>
                <button type="button" onclick="setAmount(5000)" class="rounded-md bg-gray-100 px-3 py-1.5 text-sm font-medium text-gray-700 hover:bg-gray-200">₦5,000</button>
                <button type="button" onclick="setAmount(10000)" class="rounded-md bg-gray-100 px-3 py-1.5 text-sm font-medium text-gray-700 hover:bg-gray-200">₦10,000</button>
            </div>
            <div class="flex gap-3">
                <button type="submit" class="flex-1 rounded-lg bg-green-950 px-4 py-2.5 text-sm font-semibold text-white hover:bg-green-700">Pay with Paystack</button>
                <button type="button" id="closeFundBtn" class="flex-1 rounded-lg bg-gray-100 px-4 py-2.5 text-sm font-semibold text-gray-700 hover:bg-gray-200">Cancel</button>
            </div>
        </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
function setAmount(amount) {
    document.getElementById('amount').value = amount;
}

const fundModal = document.getElementById('fundModal');
const openBtn = document.getElementById('openFundBtn');
const closeBtn = document.getElementById('closeFundBtn');
const modalContent = document.getElementById('fundModalContent');

openBtn.addEventListener('click', function() {
    fundModal.classList.remove('hidden');
    document.getElementById('amount').focus();
});

closeBtn.addEventListener('click', function() {
    fundModal.classList.add('hidden');
});

fundModal.addEventListener('click', function(e) {
    if (e.target === fundModal) {
        fundModal.classList.add('hidden');
    }
});

document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape' && !fundModal.classList.contains('hidden')) {
        fundModal.classList.add('hidden');
    }
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/xunna/Documents/software dev/laravel/clikzpay/resources/views/wallet/index.blade.php ENDPATH**/ ?>