

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

<?php $__env->startSection('admin-content'); ?>
<style>
    /* Specific Transactions Styles */
    .transactions-page .amount-text { font-weight: 700; color: #1a1a2e; font-size: 1rem; }
    .transactions-page .amount-text.success { color: #2e7d32; }

    .transactions-page .status-badge.success { background: #dcfce7; color: #166534; }
    .transactions-page .status-badge.pending { background: #fef9c3; color: #854d0e; }
    .transactions-page .status-badge.failed { background: #fee2e2; color: #991b1b; }

    .transactions-page .type-badge { padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
    .transactions-page .type-badge.subscription { background: #e3f2fd; color: #1565c0; }
    .transactions-page .type-badge.promotion { background: #f3e5f5; color: #7b1fa2; }
</style>

<div class="transactions-page">
    <!-- Page Header -->
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h4 class="fw-bold mb-1">Financial Transactions</h4>
            <p class="text-muted mb-0 small">Monitor payments, revenue, and order history</p>
        </div>
        <div class="d-flex gap-2">
            <a href="<?php echo e(route('admin.transactions.export')); ?>" class="btn btn-primary shadow-sm btn-lg d-flex align-items-center gap-2" 
               style="border-radius: 12px; font-size: 0.95rem;">
                <i class="bi bi-download"></i> Export CSV
            </a>
        </div>
    </div>

    <!-- Stats Cards -->
    <div class="row g-4 mb-4">
        <div class="col-lg-3 col-md-6">
            <div class="stat-card stat-card-primary d-flex align-items-center gap-3">
                <div class="stat-icon primary">
                    <i class="bi bi-receipt"></i>
                </div>
                <div>
                    <div class="stat-value"><?php echo e(number_format($stats['total_transactions'] ?? 0)); ?></div>
                    <div class="stat-label">Total Transactions</div>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-md-6">
            <div class="stat-card stat-card-success d-flex align-items-center gap-3">
                <div class="stat-icon success">
                    <i class="bi bi-check-circle-fill"></i>
                </div>
                <div>
                    <div class="stat-value"><?php echo e(number_format($stats['successful'] ?? 0)); ?></div>
                    <div class="stat-label">Successful</div>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-md-6">
            <div class="stat-card stat-card-warning d-flex align-items-center gap-3">
                <div class="stat-icon warning">
                    <i class="bi bi-hourglass-split"></i>
                </div>
                <div>
                    <div class="stat-value"><?php echo e(number_format($stats['pending'] ?? 0)); ?></div>
                    <div class="stat-label">Pending</div>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-md-6">
            <div class="stat-card stat-card-info d-flex align-items-center gap-3">
                <div class="stat-icon danger">
                    <i class="bi bi-x-circle-fill"></i>
                </div>
                <div>
                    <div class="stat-value"><?php echo e(number_format($stats['failed'] ?? 0)); ?></div>
                    <div class="stat-label">Failed</div>
                </div>
            </div>
        </div>
        <!-- Revenue Card (Full Width) -->
        <div class="col-12">
            <div class="stat-card d-flex align-items-center justify-content-between">
                <div class="d-flex align-items-center gap-4">
                    <div class="stat-icon info" style="width: 64px; height: 64px; font-size: 1.8rem;">
                        <i class="bi bi-currency-rupee"></i>
                    </div>
                    <div>
                        <div class="stat-value text-primary">₹<?php echo e(number_format($stats['total_revenue'] ?? 0, 2)); ?></div>
                        <div class="stat-label">Total Revenue Generated</div>
                    </div>
                </div>
                 <div class="d-flex align-items-center gap-4 border-start ps-4">
                    <div>
                        <div class="stat-value text-success h3 mb-0">₹<?php echo e(number_format($stats['platform_earnings'] ?? 0, 2)); ?></div>
                        <div class="stat-label">Platform Earnings (Commission)</div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Filters -->
    <div class="filter-card mb-4">
        <form method="GET" class="row g-3 align-items-end">
            <div class="col-lg-4 col-md-6">
                <label class="form-label small fw-bold text-muted mb-1">Search</label>
                <div class="input-group">
                    <span class="input-group-text bg-white border-end-0 ps-3" style="border-radius: 10px 0 0 10px;">
                        <i class="bi bi-search text-muted"></i>
                    </span>
                    <input type="text" name="search" class="form-control form-control-lg border-start-0" 
                           placeholder="Transaction ID, User, Amount..." 
                           value="<?php echo e(request('search')); ?>"
                           style="border-radius: 0 10px 10px 0;">
                </div>
            </div>
            <div class="col-lg-2 col-md-6">
                <label class="form-label small fw-bold text-muted mb-1">Status</label>
                <select name="status" class="form-select form-select-lg" style="border-radius: 10px;">
                    <option value="">All Status</option>
                    <option value="success" <?php echo e(request('status') == 'success' ? 'selected' : ''); ?>>Success</option>
                    <option value="pending" <?php echo e(request('status') == 'pending' ? 'selected' : ''); ?>>Pending</option>
                    <option value="failed" <?php echo e(request('status') == 'failed' ? 'selected' : ''); ?>>Failed</option>
                </select>
            </div>
            <div class="col-lg-2 col-md-6">
                <label class="form-label small fw-bold text-muted mb-1">Type</label>
                <select name="type" class="form-select form-select-lg" style="border-radius: 10px;">
                    <option value="">All Types</option>
                    <option value="subscription" <?php echo e(request('type') == 'subscription' ? 'selected' : ''); ?>>Subscription</option>
                    <option value="promotion" <?php echo e(request('type') == 'promotion' ? 'selected' : ''); ?>>Promotion</option>
                </select>
            </div>
            <div class="col-lg-2 col-md-6">
                <label class="form-label small fw-bold text-muted mb-1">Date Range</label>
                <input type="date" name="date_from" class="form-control form-control-lg" value="<?php echo e(request('date_from')); ?>" style="border-radius: 10px;">
            </div>
            <div class="col-lg-2 col-md-12">
                <button type="submit" class="btn btn-primary btn-lg w-100" style="border-radius: 10px;">
                    <i class="bi bi-funnel me-1"></i> Filter
                </button>
            </div>
        </form>
    </div>

    <!-- Transactions Table -->
    <div class="data-table">
        <div class="table-responsive">
            <table class="table mb-0">
                <thead>
                    <tr>
                        <th class="ps-4">Transaction ID</th>
                        <th>User / Payer</th>
                        <th>Type</th>
                        <th>Amount</th>
                        <th class="text-center">Status</th>
                        <th>Payment Method</th>
                        <th>Date & Time</th>
                        <th class="text-end pe-4">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transaction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td class="ps-4">
                                <span class="font-monospace text-muted small">#<?php echo e($transaction->id); ?></span>
                            </td>
                            <td>
                                <?php if($transaction->user): ?>
                                    <div>
                                        <div class="fw-bold text-dark"><?php echo e($transaction->user->name); ?></div>
                                        <div class="text-muted small"><?php echo e($transaction->user->email); ?></div>
                                    </div>
                                <?php else: ?>
                                    <span class="text-muted fst-italic">Unknown User</span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if($transaction->transaction_type == 'subscription'): ?>
                                    <span class="type-badge subscription">Subscription</span>
                                <?php elseif($transaction->transaction_type == 'promotion'): ?>
                                    <span class="type-badge promotion">Promotion</span>
                                <?php else: ?>
                                    <span class="badge bg-light text-dark border"><?php echo e(ucfirst($transaction->transaction_type)); ?></span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <div class="amount-text <?php echo e($transaction->status == 'success' ? 'success' : ''); ?>">
                                    ₹<?php echo e(number_format($transaction->total_amount, 2)); ?>

                                </div>
                            </td>
                            <td class="text-center">
                                <?php if($transaction->status == 'success'): ?>
                                    <span class="status-badge success">
                                        <i class="bi bi-check-circle-fill"></i> Success
                                    </span>
                                <?php elseif($transaction->status == 'pending'): ?>
                                    <span class="status-badge pending">
                                        <i class="bi bi-hourglass-split"></i> Pending
                                    </span>
                                <?php elseif($transaction->status == 'failed'): ?>
                                    <span class="status-badge failed">
                                        <i class="bi bi-x-circle-fill"></i> Failed
                                    </span>
                                <?php else: ?>
                                    <span class="badge bg-light text-muted border"><?php echo e(ucfirst($transaction->status)); ?></span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <span class="d-inline-block text-truncate" style="max-width: 100px;" title="<?php echo e($transaction->payment_method); ?>">
                                    <i class="bi bi-credit-card me-1 text-muted"></i> <?php echo e(ucfirst($transaction->payment_method ?? 'N/A')); ?>

                                </span>
                            </td>
                            <td>
                                <div class="text-dark small fw-medium"><?php echo e($transaction->created_at->format('M d, Y')); ?></div>
                                <small class="text-muted"><?php echo e($transaction->created_at->format('h:i A')); ?></small>
                            </td>
                            <td class="text-end pe-4">
                                <a href="<?php echo e(route('admin.transactions.show', $transaction)); ?>" class="action-btn primary" title="View Details" data-bs-toggle="tooltip">
                                    <i class="bi bi-eye"></i>
                                </a>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="8" class="text-center py-5">
                                <div class="py-4">
                                    <i class="bi bi-receipt fs-1 text-muted opacity-50 d-block mb-3"></i>
                                    <h5 class="fw-bold text-muted">No Transactions Found</h5>
                                    <p class="text-muted small mb-0">Try adjusting your filters</p>
                                </div>
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        
        <?php if($transactions->hasPages()): ?>
           <div class="p-3 border-top bg-light" style="border-radius: 0 0 16px 16px;">
                <?php echo e($transactions->links()); ?>

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

<script>
    document.addEventListener('DOMContentLoaded', function() {
        var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
        tooltipTriggerList.map(function (el) {
            return new bootstrap.Tooltip(el);
        });
    });
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/u281583269/domains/theminiport.com/public_html/resources/views/admin/transactions/index.blade.php ENDPATH**/ ?>