<?php $__env->startSection('title', 'Financial Ledger & Orders'); ?>

<?php $__env->startSection('content'); ?>

    <div class="flex flex-col md:flex-row md:justify-between md:items-end mb-8 gap-4">
        <div>
            <h1 class="text-3xl font-extrabold text-white tracking-tight">Financial Ledger</h1>
            <p class="text-slate-400 mt-1 text-sm">Track all client deposits, domain purchases, and system transactions.</p>
        </div>
        <div class="flex gap-4">
            <div class="bg-slate-800/60 border border-slate-700 px-5 py-3 rounded-xl flex flex-col shadow-lg">
                <span class="text-xs text-slate-400 font-bold uppercase tracking-wider mb-1">Total Deposits</span>
                <span class="text-lg font-bold text-emerald-400">৳<?php echo e(number_format($totalDeposit, 2)); ?></span>
            </div>
            <div class="bg-slate-800/60 border border-slate-700 px-5 py-3 rounded-xl flex flex-col shadow-lg">
                <span class="text-xs text-slate-400 font-bold uppercase tracking-wider mb-1">Total Domain Sales</span>
                <span class="text-lg font-bold text-indigo-400">৳<?php echo e(number_format($totalSpent, 2)); ?></span>
            </div>
        </div>
    </div>

    <div class="bg-slate-800/40 border border-slate-700 rounded-2xl overflow-hidden shadow-lg">
        
        <div class="p-6 border-b border-slate-700 bg-slate-800/50 flex flex-col md:flex-row justify-between items-center gap-4">
            <h2 class="text-lg font-bold text-white flex items-center gap-2">
                <i class="fas fa-list-ul text-blue-400"></i> Transaction History
            </h2>
            
            <form action="<?php echo e(route('admin.orders.index')); ?>" method="GET" class="flex flex-col sm:flex-row gap-3 w-full md:w-auto">
                <select name="type" class="bg-slate-900 border border-slate-700 text-slate-300 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 outline-none">
                    <option value="">All Types</option>
                    <option value="credit" <?php echo e(request('type') == 'credit' ? 'selected' : ''); ?>>Deposits (Credit)</option>
                    <option value="debit" <?php echo e(request('type') == 'debit' ? 'selected' : ''); ?>>Purchases (Debit)</option>
                </select>
                
                <div class="relative w-full sm:w-64">
                    <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search TrxID or User..." class="bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 outline-none">
                    <i class="fas fa-search absolute left-3 top-3 text-slate-500"></i>
                </div>
                <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors">
                    Filter
                </button>
            </form>
        </div>

        <div class="overflow-x-auto">
            <table class="w-full text-left text-sm text-slate-300">
                <thead class="bg-slate-800/80 text-xs uppercase font-semibold text-slate-400">
                    <tr>
                        <th class="px-6 py-4">Transaction ID</th>
                        <th class="px-6 py-4">Client</th>
                        <th class="px-6 py-4">Description / Item</th>
                        <th class="px-6 py-4">Amount</th>
                        <th class="px-6 py-4">Status</th>
                        <th class="px-6 py-4 text-right">Date</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-slate-700/50">
                    <?php $__empty_1 = true; $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $trx): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="hover:bg-slate-800/50 transition-colors">
                        
                        <td class="px-6 py-4">
                            <?php if($trx->trx_id): ?>
                                <span class="font-mono text-xs bg-slate-900 border border-slate-700 px-2 py-1 rounded text-slate-300"><?php echo e($trx->trx_id); ?></span>
                            <?php else: ?>
                                <span class="text-slate-500 text-xs">N/A (Internal)</span>
                            <?php endif; ?>
                            <div class="text-xs text-slate-500 mt-1 uppercase tracking-wider">Method: <?php echo e($trx->method ?? 'System'); ?></div>
                        </td>

                        <td class="px-6 py-4">
                            <a href="<?php echo e(route('admin.users.show', $trx->user_id)); ?>" class="font-bold text-blue-400 hover:text-blue-300 transition-colors block"><?php echo e($trx->username); ?></a>
                            <span class="text-xs text-slate-500"><?php echo e($trx->email); ?></span>
                        </td>

                        <td class="px-6 py-4">
                            <div class="text-slate-300 max-w-xs truncate" title="<?php echo e($trx->description); ?>"><?php echo e($trx->description ?? 'No description provided'); ?></div>
                        </td>

                        <td class="px-6 py-4 font-bold text-lg">
                            <?php if($trx->transaction_type == 'credit'): ?>
                                <span class="text-emerald-400 flex items-center gap-1">
                                    <i class="fas fa-plus text-xs"></i> ৳<?php echo e(number_format($trx->amount, 2)); ?>

                                </span>
                            <?php else: ?>
                                <span class="text-red-400 flex items-center gap-1">
                                    <i class="fas fa-minus text-xs"></i> ৳<?php echo e(number_format($trx->amount, 2)); ?>

                                </span>
                            <?php endif; ?>
                        </td>

                        <td class="px-6 py-4">
                            <?php if($trx->status == 'approved'): ?>
                                <span class="bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 px-2.5 py-1 rounded text-xs font-medium"><i class="fas fa-check-circle mr-1"></i> Approved</span>
                            <?php elseif($trx->status == 'pending'): ?>
                                <span class="bg-yellow-500/10 text-yellow-400 border border-yellow-500/20 px-2.5 py-1 rounded text-xs font-medium"><i class="fas fa-clock mr-1"></i> Pending</span>
                            <?php else: ?>
                                <span class="bg-red-500/10 text-red-400 border border-red-500/20 px-2.5 py-1 rounded text-xs font-medium"><i class="fas fa-times-circle mr-1"></i> <?php echo e(ucfirst($trx->status)); ?></span>
                            <?php endif; ?>
                        </td>

                        <td class="px-6 py-4 text-right text-slate-400">
                            <div class="font-medium"><?php echo e(date('d M Y', strtotime($trx->created_at))); ?></div>
                            <div class="text-xs"><?php echo e(date('h:i A', strtotime($trx->created_at))); ?></div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="6" class="px-6 py-10 text-center text-slate-500">
                            <i class="fas fa-file-invoice-dollar text-4xl mb-3 opacity-50 block"></i>
                            No financial records found.
                        </td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        
        <div class="p-4 border-t border-slate-700">
            <?php echo e($transactions->links()); ?>

        </div>
    </div>

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

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/hhhnbari/public_html/resources/views/admin/orders/index.blade.php ENDPATH**/ ?>