

<?php $__env->startSection('title', 'PG Finsev | Admin Dashboard'); ?>
<?php $__env->startSection('page-title', 'Admin Dashboard'); ?>

<?php $__env->startSection('page-description'); ?>
    Welcome back, <?php echo e(Auth::user()->name); ?>

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

<?php $__env->startPush('styles'); ?>
<style>
/* =====================================================
           CONTENT
        ===================================================== */
.welcome {
            margin-bottom: 24px;
        }


        .welcome h2 {
            color: #1d3557;

            font-size: 20px;

            font-weight: 800;
        }


        .welcome p {
            margin-top: 5px;

            color: #8b98aa;

            font-size: 10px;
        }


        /* =====================================================
           STAT CARDS
        ===================================================== */

        .stats-grid {
            display: grid;

            grid-template-columns:
                repeat(4, 1fr);

            gap: 15px;

            margin-bottom: 22px;
        }


        .stat-card {
            position: relative;

            padding: 19px;

            background: #ffffff;

            border: 1px solid #e3eaf3;

            border-radius: 14px;

            overflow: hidden;

            transition: .2s;
        }


        .stat-card:hover {
            transform: translateY(-2px);

            box-shadow:
                0 8px 25px
                rgba(31, 52, 80, .06);
        }


        .stat-icon {
            width: 38px;

            height: 38px;

            display: flex;

            align-items: center;

            justify-content: center;

            margin-bottom: 13px;

            border-radius: 10px;

            font-size: 16px;
        }


        .icon-blue {
            background: #eaf2ff;

            color: #1769e0;
        }


        .icon-purple {
            background: #f2eaff;

            color: #7c3aed;
        }


        .icon-orange {
            background: #fff4df;

            color: #c27a13;
        }


        .icon-green {
            background: #e8f8ef;

            color: #27814b;
        }


        .stat-label {
            color: #8997aa;

            font-size: 9px;

            font-weight: 800;

            text-transform: uppercase;

            letter-spacing: .5px;
        }


        .stat-value {
            margin-top: 7px;

            color: #273b59;

            font-size: 25px;

            font-weight: 900;
        }


        .stat-link {
            display: inline-block;

            margin-top: 6px;

            color: #1769e0;

            font-size: 8px;

            font-weight: 700;
        }


        /* =====================================================
           TWO COLUMN
        ===================================================== */

        .dashboard-grid {
            display: grid;

            grid-template-columns:
                1.5fr 1fr;

            gap: 18px;

            margin-bottom: 18px;
        }


        .card {
            background: #ffffff;

            border: 1px solid #e3eaf3;

            border-radius: 14px;

            overflow: hidden;
        }


        .card-header {
            display: flex;

            align-items: center;

            justify-content: space-between;

            padding:
                17px 19px;

            border-bottom: 1px solid #edf1f6;
        }


        .card-header h3 {
            color: #273b59;

            font-size: 13px;

            font-weight: 800;
        }


        .card-header span,
        .card-header a {
            color: #1769e0;

            font-size: 9px;

            font-weight: 700;
        }


        .card-body {
            padding: 18px;
        }


        /* =====================================================
           QUICK ACTIONS
        ===================================================== */

        .quick-actions {
            display: grid;

            grid-template-columns:
                repeat(2, 1fr);

            gap: 10px;
        }


        .quick-action {
            display: flex;

            align-items: center;

            gap: 11px;

            min-height: 65px;

            padding: 11px;

            background: #f8fafc;

            border: 1px solid #edf1f5;

            border-radius: 10px;

            color: #445a75;

            transition: .2s;
        }


        .quick-action:hover {
            background: #f1f6ff;

            border-color: #dce9fb;

            color: #1769e0;
        }


        .quick-icon {
            width: 36px;

            height: 36px;

            display: flex;

            align-items: center;

            justify-content: center;

            flex-shrink: 0;

            border-radius: 9px;

            background: #eaf2ff;

            font-size: 14px;
        }


        .quick-text strong {
            display: block;

            color: #344966;

            font-size: 10px;
        }


        .quick-text span {
            display: block;

            margin-top: 3px;

            color: #97a3b2;

            font-size: 8px;
        }


        /* =====================================================
           KYC STATUS
        ===================================================== */

        .kyc-row {
            display: flex;

            align-items: center;

            justify-content: space-between;

            padding: 12px 0;

            border-bottom: 1px solid #edf1f5;
        }


        .kyc-row:last-child {
            border-bottom: 0;
        }


        .kyc-left {
            display: flex;

            align-items: center;

            gap: 10px;
        }


        .kyc-icon {
            width: 32px;

            height: 32px;

            display: flex;

            align-items: center;

            justify-content: center;

            border-radius: 8px;

            background: #f4f7fa;

            font-size: 13px;
        }


        .kyc-name {
            color: #435a76;

            font-size: 10px;

            font-weight: 700;
        }


        .kyc-count {
            color: #273b59;

            font-size: 14px;

            font-weight: 900;
        }


        /* =====================================================
           TABLE
        ===================================================== */

        .table-wrap {
            overflow-x: auto;
        }


        table {
            width: 100%;

            border-collapse: collapse;

            min-width: 650px;
        }


        th {
            padding:
                11px 15px;

            background: #f8fafc;

            color: #9aa6b6;

            font-size: 8px;

            font-weight: 800;

            text-align: left;

            text-transform: uppercase;
        }


        td {
            padding:
                13px 15px;

            border-top: 1px solid #edf1f6;

            color: #536982;

            font-size: 9px;
        }


        .client {
            display: flex;

            align-items: center;

            gap: 9px;
        }


        .client-avatar {
            width: 31px;

            height: 31px;

            display: flex;

            align-items: center;

            justify-content: center;

            border-radius: 8px;

            background: #eaf2ff;

            color: #1769e0;

            font-size: 10px;

            font-weight: 900;
        }


        .client-name {
            color: #344966;

            font-size: 9px;

            font-weight: 800;
        }


        .client-email {
            margin-top: 2px;

            color: #9aa6b6;

            font-size: 7px;
        }


        .badge {
            display: inline-flex;

            align-items: center;

            gap: 5px;

            padding:
                5px 8px;

            border-radius: 20px;

            font-size: 7px;

            font-weight: 800;
        }


        .dot {
            width: 5px;

            height: 5px;

            border-radius: 50%;

            background: currentColor;
        }


        .badge-green {
            color: #287646;

            background: #eaf8ef;
        }


        .badge-orange {
            color: #b7791f;

            background: #fff7e8;
        }


        .badge-red {
            color: #be123c;

            background: #fff1f2;
        }


        .badge-gray {
            color: #64748b;

            background: #f1f5f9;
        }


        .view-btn {
            display: inline-flex;

            align-items: center;

            justify-content: center;

            padding:
                6px 10px;

            border-radius: 7px;

            background: #eaf2ff;

            color: #1769e0;

            font-size: 8px;

            font-weight: 800;
        }


        .view-btn:hover {
            background: #1769e0;

            color: #ffffff;
        }


        /* =====================================================
           PAYMENT AMOUNT
        ===================================================== */

        .amount {
            color: #287646;

            font-weight: 800;
        }


        /* =====================================================
           RESPONSIVE
        ===================================================== */

        @media (max-width: 1150px) {

            .stats-grid {
                grid-template-columns:
                    repeat(2, 1fr);
            }

            .dashboard-grid {
                grid-template-columns: 1fr;
            }

        }


        @media (max-width: 800px) {

            .sidebar {
                position: relative;

                width: 100%;

                height: auto;

                min-height: auto;

                overflow: visible;
            }

            .sidebar-menu {
                overflow: visible;
            }

            .sidebar-bottom {
                margin-top: 10px;
            }

            .main {
                margin-left: 0;
            }

            .topbar {
                padding: 0 18px;
            }

            .content {
                padding: 18px;
            }

        }


        @media (max-width: 550px) {

            .stats-grid {
                grid-template-columns: 1fr;
            }

            .quick-actions {
                grid-template-columns: 1fr;
            }

            .topbar-title h1 {
                font-size: 17px;
            }

            .topbar {
                padding: 0 12px;
            }

            .content {
                padding: 12px;
            }

            .notification {
                width:35px;
                height:35px;
                flex:none;
            }

        }

    
</style>
<?php $__env->stopPush(); ?>

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

<div class="welcome">

            <h2>
                Overview
            </h2>

            <p>
                Monitor clients, applications, KYC verification and payments.
            </p>

        </div>



        <!-- =================================================
             STATISTICS
        ================================================== -->

        <div class="stats-grid">


            <!-- CLIENTS -->

            <div class="stat-card">

                <div class="stat-icon icon-blue">
                    👥
                </div>

                <div class="stat-label">
                    Total Clients
                </div>

                <div class="stat-value">
                    <?php echo e($totalClients); ?>

                </div>

                <a
                    href="<?php echo e(route('admin.clients')); ?>"
                    class="stat-link"
                >
                    View Clients →
                </a>

            </div>


            <!-- APPLICATIONS -->

            <div class="stat-card">

                <div class="stat-icon icon-purple">
                    📋
                </div>

                <div class="stat-label">
                    Applications
                </div>

                <div class="stat-value">
                    <?php echo e($totalApplications); ?>

                </div>

                <a
                    href="<?php echo e(route('admin.applications')); ?>"
                    class="stat-link"
                >
                    View Applications →
                </a>

            </div>


            <!-- KYC -->

            <div class="stat-card">

                <div class="stat-icon icon-orange">
                    🪪
                </div>

                <div class="stat-label">
                    Pending KYC
                </div>

                <div class="stat-value">
                    <?php echo e($pendingKyc); ?>

                </div>

                <a
                    href="<?php echo e(route('admin.clients')); ?>"
                    class="stat-link"
                >
                    Review KYC →
                </a>

            </div>


            <!-- PAYMENTS -->

            <div class="stat-card">

                <div class="stat-icon icon-green">
                    💳
                </div>

                <div class="stat-label">
                    Total Payments
                </div>

                <div class="stat-value">
                    <?php echo e($totalPayments); ?>

                </div>

                <a
                    href="<?php echo e(route('admin.payments')); ?>"
                    class="stat-link"
                >
                    View Payments →
                </a>

            </div>


        </div>



        <!-- =================================================
             LOAN OVERVIEW
        ================================================== -->

        <div class="stats-grid">

            <div class="stat-card">
                <div class="stat-icon icon-blue">💰</div>
                <div class="stat-label">Total Loans</div>
                <div class="stat-value"><?php echo e($totalLoans); ?></div>
                <a href="<?php echo e(route('admin.loans')); ?>" class="stat-link">View Loans →</a>
            </div>

            <div class="stat-card">
                <div class="stat-icon icon-orange">⏳</div>
                <div class="stat-label">Pending Loans</div>
                <div class="stat-value"><?php echo e($pendingLoans); ?></div>
                <a href="<?php echo e(route('admin.loans')); ?>" class="stat-link">Review Pending →</a>
            </div>

            <div class="stat-card">
                <div class="stat-icon icon-green">✓</div>
                <div class="stat-label">Active Loans</div>
                <div class="stat-value"><?php echo e($activeLoans); ?></div>
                <a href="<?php echo e(route('admin.loans')); ?>" class="stat-link">View Active →</a>
            </div>

            <div class="stat-card">
                <div class="stat-icon icon-purple">⚠</div>
                <div class="stat-label">Overdue Loans</div>
                <div class="stat-value"><?php echo e($overdueLoans); ?></div>
                <a href="<?php echo e(route('admin.loans')); ?>" class="stat-link">Review Overdue →</a>
            </div>

        </div>

        <div class="dashboard-grid">

            <div class="card">
                <div class="card-header">
                    <h3>Loan Financial Overview</h3>
                    <a href="<?php echo e(route('admin.loans')); ?>">Manage Loans →</a>
                </div>

                <div class="card-body">
                    <div class="quick-actions">

                        <div class="quick-action">
                            <div class="quick-icon">💵</div>
                            <div class="quick-text">
                                <strong>Loan Amount</strong>
                                <span>All applications</span>
                                <strong style="margin-top:4px;">
                                    ₹<?php echo e(number_format($totalLoanAmount, 2)); ?>

                                </strong>
                            </div>
                        </div>

                        <div class="quick-action">
                            <div class="quick-icon">📤</div>
                            <div class="quick-text">
                                <strong>Disbursed</strong>
                                <span>Disbursed loan value</span>
                                <strong style="margin-top:4px;">
                                    ₹<?php echo e(number_format($totalDisbursedAmount, 2)); ?>

                                </strong>
                            </div>
                        </div>

                        <div class="quick-action">
                            <div class="quick-icon">📊</div>
                            <div class="quick-text">
                                <strong>Outstanding</strong>
                                <span>Current active balance</span>
                                <strong style="margin-top:4px;">
                                    ₹<?php echo e(number_format($totalOutstandingAmount, 2)); ?>

                                </strong>
                            </div>
                        </div>

                        <div class="quick-action">
                            <div class="quick-icon">🧾</div>
                            <div class="quick-text">
                                <strong>Processing Fees</strong>
                                <span>Total configured fees</span>
                                <strong style="margin-top:4px;">
                                    ₹<?php echo e(number_format($totalProcessingFees, 2)); ?>

                                </strong>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

            <div class="card">
                <div class="card-header">
                    <h3>Loan Status</h3>
                    <a href="<?php echo e(route('admin.loans')); ?>">View All →</a>
                </div>

                <div class="card-body">

                    <div class="kyc-row">
                        <div class="kyc-left">
                            <div class="kyc-icon">⏳</div>
                            <div class="kyc-name">Pending</div>
                        </div>
                        <div class="kyc-count"><?php echo e($pendingLoans); ?></div>
                    </div>

                    <div class="kyc-row">
                        <div class="kyc-left">
                            <div class="kyc-icon">✓</div>
                            <div class="kyc-name">Approved</div>
                        </div>
                        <div class="kyc-count"><?php echo e($approvedLoans); ?></div>
                    </div>

                    <div class="kyc-row">
                        <div class="kyc-left">
                            <div class="kyc-icon">●</div>
                            <div class="kyc-name">Active</div>
                        </div>
                        <div class="kyc-count"><?php echo e($activeLoans); ?></div>
                    </div>

                    <div class="kyc-row">
                        <div class="kyc-left">
                            <div class="kyc-icon">⚠</div>
                            <div class="kyc-name">Overdue</div>
                        </div>
                        <div class="kyc-count"><?php echo e($overdueLoans); ?></div>
                    </div>

                    <div class="kyc-row">
                        <div class="kyc-left">
                            <div class="kyc-icon">✓</div>
                            <div class="kyc-name">Completed</div>
                        </div>
                        <div class="kyc-count"><?php echo e($completedLoans); ?></div>
                    </div>

                </div>
            </div>

        </div>


        <!-- =================================================
             RECENT NOTIFICATIONS
        ================================================== -->

        <?php
            $dashboardNotifications = Auth::user()
                ->notifications()
                ->latest()
                ->take(5)
                ->get();
        ?>

        <div class="card" style="margin-bottom:18px;">

            <div class="card-header">
                <h3>Recent Notifications</h3>

                <a href="<?php echo e(route('notifications.index')); ?>">
                    View All →
                </a>
            </div>

            <div class="card-body" style="padding:10px 18px;">

                <?php $__empty_1 = true; $__currentLoopData = $dashboardNotifications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $notification): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                    <?php
                        $notificationData = $notification->data ?? [];

                        $notificationTitle = data_get(
                            $notificationData,
                            'title',
                            'Notification'
                        );

                        $notificationMessage = data_get(
                            $notificationData,
                            'message',
                            ''
                        );

                        $notificationLevel = data_get(
                            $notificationData,
                            'level',
                            'info'
                        );

                        if (!in_array(
                            $notificationLevel,
                            ['success', 'warning', 'error', 'info'],
                            true
                        )) {
                            $notificationLevel = 'info';
                        }

                        $notificationLoan = data_get(
                            $notificationData,
                            'loan_number'
                        );
                    ?>

                    <div
                        style="
                            display:flex;
                            align-items:flex-start;
                            gap:11px;
                            padding:12px 0;
                            border-bottom:1px solid #edf1f6;
                        "
                    >

                        <div
                            style="
                                width:30px;
                                height:30px;
                                flex:none;
                                display:flex;
                                align-items:center;
                                justify-content:center;
                                border-radius:8px;
                                background:
                                    <?php echo e($notificationLevel === 'success'
                                        ? '#e8f8ef'
                                        : ($notificationLevel === 'warning'
                                            ? '#fff4df'
                                            : ($notificationLevel === 'error'
                                                ? '#fff1f2'
                                                : '#eaf2ff'))); ?>;
                                font-size:12px;
                            "
                        >
                            <?php echo e($notificationLevel === 'success'
                                    ? '✓'
                                    : ($notificationLevel === 'warning'
                                        ? '⚠'
                                        : ($notificationLevel === 'error'
                                            ? '!'
                                            : '🔔'))); ?>

                        </div>

                        <div style="min-width:0;flex:1;">

                            <div
                                style="
                                    display:flex;
                                    align-items:flex-start;
                                    justify-content:space-between;
                                    gap:10px;
                                "
                            >

                                <strong
                                    style="
                                        color:#344966;
                                        font-size:9px;
                                        font-weight:800;
                                        line-height:1.35;
                                    "
                                >
                                    <?php echo e($notificationTitle); ?>

                                </strong>

                                <?php if(!$notification->read_at): ?>
                                    <span
                                        style="
                                            flex:none;
                                            width:6px;
                                            height:6px;
                                            margin-top:3px;
                                            border-radius:50%;
                                            background:#1769e0;
                                        "
                                        title="Unread"
                                    ></span>
                                <?php endif; ?>

                            </div>

                            <div
                                style="
                                    margin-top:3px;
                                    color:#7d8da1;
                                    font-size:8px;
                                    line-height:1.45;
                                "
                            >
                                <?php echo e($notificationMessage); ?>

                            </div>

                            <div
                                style="
                                    margin-top:4px;
                                    color:#a0acba;
                                    font-size:7px;
                                "
                            >
                                <?php echo e($notification->created_at?->diffForHumans() ?? ''); ?>


                                <?php if($notificationLoan): ?>
                                    · <?php echo e($notificationLoan); ?>

                                <?php endif; ?>
                            </div>

                        </div>

                        <?php if(!$notification->read_at): ?>
                            <form
                                method="POST"
                                action="<?php echo e(route('notifications.read', $notification->id)); ?>"
                                style="flex:none;"
                            >
                                <?php echo csrf_field(); ?>

                                <button
                                    type="submit"
                                    style="
                                        border:0;
                                        background:#edf5ff;
                                        color:#1769e0;
                                        border-radius:7px;
                                        padding:6px 8px;
                                        font-size:7px;
                                        font-weight:800;
                                        cursor:pointer;
                                    "
                                >
                                    Open
                                </button>
                            </form>
                        <?php endif; ?>

                    </div>

                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                    <div
                        style="
                            padding:28px 10px;
                            text-align:center;
                            color:#9aa6b6;
                            font-size:9px;
                        "
                    >
                        <div style="font-size:20px;margin-bottom:7px;">
                            🔔
                        </div>

                        <strong
                            style="
                                display:block;
                                color:#536982;
                                font-size:11px;
                                margin-bottom:3px;
                            "
                        >
                            No notifications
                        </strong>

                        New loan and payment updates will appear here.
                    </div>

                <?php endif; ?>

            </div>

        </div>


        <!-- =================================================
             RECENT LOANS
        ================================================== -->

        <div class="card" style="margin-bottom:18px;">

            <div class="card-header">
                <h3>Recent Loans</h3>
                <a href="<?php echo e(route('admin.loans')); ?>">View All →</a>
            </div>

            <div class="table-wrap">
                <table>

                    <thead>
                        <tr>
                            <th>Loan</th>
                            <th>Client</th>
                            <th>Amount</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                    </thead>

                    <tbody>

                        <?php $__empty_1 = true; $__currentLoopData = $recentLoans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $loan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                            <?php
                                $loanStatus = strtolower((string) $loan->status);

                                $loanBadgeClass = match ($loanStatus) {
                                    'active', 'disbursed', 'completed' => 'badge-green',
                                    'pending', 'approved' => 'badge-orange',
                                    'overdue', 'rejected' => 'badge-red',
                                    default => 'badge-gray',
                                };
                            ?>

                            <tr>

                                <td>
                                    <strong>
                                        <?php echo e($loan->loan_number); ?>

                                    </strong>
                                </td>

                                <td>
                                    <?php echo e($loan->user->name ?? 'Unknown'); ?>

                                </td>

                                <td>
                                    ₹<?php echo e(number_format((float) $loan->loan_amount, 2)); ?>

                                </td>

                                <td>
                                    <span class="badge <?php echo e($loanBadgeClass); ?>">
                                        <span class="dot"></span>
                                        <?php echo e(ucfirst(str_replace('_', ' ', $loan->status))); ?>

                                    </span>
                                </td>

                                <td>
                                    <a
                                        href="<?php echo e(route('admin.loans.show', $loan)); ?>"
                                        class="view-btn"
                                    >
                                        View
                                    </a>
                                </td>

                            </tr>

                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                            <tr>
                                <td
                                    colspan="5"
                                    style="text-align:center;padding:30px;color:#9aa6b6;"
                                >
                                    No loans found.
                                </td>
                            </tr>

                        <?php endif; ?>

                    </tbody>

                </table>
            </div>

        </div>


        <!-- =================================================
             DASHBOARD GRID
        ================================================== -->

        <div class="dashboard-grid">


            <!-- QUICK ACTIONS -->

            <div class="card">

                <div class="card-header">

                    <h3>
                        Quick Actions
                    </h3>

                    <span>
                        Manage
                    </span>

                </div>


                <div class="card-body">

                    <div class="quick-actions">


                        <a
                            href="<?php echo e(route('admin.clients')); ?>"
                            class="quick-action"
                        >

                            <div class="quick-icon">
                                👥
                            </div>

                            <div class="quick-text">

                                <strong>
                                    Clients
                                </strong>

                                <span>
                                    View all clients
                                </span>

                            </div>

                        </a>


                        <a
                            href="<?php echo e(route('admin.applications')); ?>"
                            class="quick-action"
                        >

                            <div class="quick-icon">
                                📋
                            </div>

                            <div class="quick-text">

                                <strong>
                                    Applications
                                </strong>

                                <span>
                                    Review applications
                                </span>

                            </div>

                        </a>


                        <a
                            href="<?php echo e(route('admin.clients')); ?>"
                            class="quick-action"
                        >

                            <div class="quick-icon">
                                🪪
                            </div>

                            <div class="quick-text">

                                <strong>
                                    KYC Verification
                                </strong>

                                <span>
                                    Verify client KYC
                                </span>

                            </div>

                        </a>


                        <a
                            href="<?php echo e(route('admin.payments')); ?>"
                            class="quick-action"
                        >

                            <div class="quick-icon">
                                💳
                            </div>

                            <div class="quick-text">

                                <strong>
                                    Payments
                                </strong>

                                <span>
                                    View payment history
                                </span>

                            </div>

                        </a>


                        <?php if(Route::has('admin.emi-cards')): ?>

                        <a
                            href="<?php echo e(route('admin.emi-cards')); ?>"
                            class="quick-action"
                        >

                            <div class="quick-icon">
                                🔐
                            </div>

                            <div class="quick-text">

                                <strong>
                                    EMI Cards
                                </strong>

                                <span>
                                    Manage EMI cards
                                </span>

                            </div>

                        </a>

                        <?php else: ?>

                        <a
                            href="<?php echo e(route('admin.clients')); ?>"
                            class="quick-action"
                        >

                            <div class="quick-icon">
                                🔐
                            </div>

                            <div class="quick-text">

                                <strong>
                                    EMI Cards
                                </strong>

                                <span>
                                    Manage EMI cards
                                </span>

                            </div>

                        </a>

                        <?php endif; ?>


                        <a
                            href="<?php echo e(route('admin.loans')); ?>"
                            class="quick-action"
                        >

                            <div class="quick-icon">
                                💰
                            </div>

                            <div class="quick-text">

                                <strong>
                                    Loans
                                </strong>

                                <span>
                                    Manage loan applications
                                </span>

                            </div>

                        </a>


                        <a
                            href="<?php echo e(route('admin.clients')); ?>"
                            class="quick-action"
                        >

                            <div class="quick-icon">
                                🔍
                            </div>

                            <div class="quick-text">

                                <strong>
                                    Client Search
                                </strong>

                                <span>
                                    Find a client
                                </span>

                            </div>

                        </a>


                    </div>

                </div>

            </div>



            <!-- KYC STATUS -->

            <div class="card">

                <div class="card-header">

                    <h3>
                        KYC Overview
                    </h3>

                    <a href="<?php echo e(route('admin.clients')); ?>">
                        View All →
                    </a>

                </div>


                <div class="card-body">


                    <div class="kyc-row">

                        <div class="kyc-left">

                            <div class="kyc-icon">
                                ⏳
                            </div>

                            <div class="kyc-name">
                                Pending Verification
                            </div>

                        </div>

                        <div class="kyc-count">
                            <?php echo e($pendingKyc); ?>

                        </div>

                    </div>


                    <div class="kyc-row">

                        <div class="kyc-left">

                            <div class="kyc-icon">
                                ✓
                            </div>

                            <div class="kyc-name">
                                Verified
                            </div>

                        </div>

                        <div class="kyc-count">
                            <?php echo e($verifiedKyc); ?>

                        </div>

                    </div>


                    <div class="kyc-row">

                        <div class="kyc-left">

                            <div class="kyc-icon">
                                ✕
                            </div>

                            <div class="kyc-name">
                                Rejected
                            </div>

                        </div>

                        <div class="kyc-count">
                            <?php echo e($rejectedKyc); ?>

                        </div>

                    </div>


                </div>

            </div>


        </div>



        <!-- =================================================
             RECENT CLIENTS
        ================================================== -->

        <div class="card" style="margin-bottom:18px;">


            <div class="card-header">

                <h3>
                    Recent Clients
                </h3>

                <a href="<?php echo e(route('admin.clients')); ?>">
                    View All →
                </a>

            </div>


            <div class="table-wrap">


                <table>

                    <thead>

                        <tr>

                            <th>
                                Client
                            </th>

                            <th>
                                Mobile
                            </th>

                            <th>
                                Registered
                            </th>

                            <th>
                                KYC
                            </th>

                            <th>
                                Action
                            </th>

                        </tr>

                    </thead>


                    <tbody>


                        <?php $__empty_1 = true; $__currentLoopData = $recentClients; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $client): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                            <?php

                                $initial =
                                    strtoupper(
                                        substr(
                                            $client->name,
                                            0,
                                            1
                                        )
                                    );

                                $kyc =
                                    $client->clientKyc;

                            ?>


                            <tr>


                                <td>

                                    <div class="client">

                                        <div class="client-avatar">

                                            <?php echo e($initial); ?>


                                        </div>


                                        <div>

                                            <div class="client-name">

                                                <?php echo e($client->name); ?>


                                            </div>

                                            <div class="client-email">

                                                <?php echo e($client->email); ?>


                                            </div>

                                        </div>

                                    </div>

                                </td>


                                <td>

                                    <?php echo e($client->mobile ?? '-'); ?>


                                </td>


                                <td>

                                    <?php echo e($client->created_at
                                        ? $client->created_at
                                            ->format('d M Y')
                                        : '-'); ?>


                                </td>


                                <td>

                                    <?php if(
                                        $kyc &&
                                        $kyc->status === 'verified'
                                    ): ?>

                                        <span
                                            class="badge badge-green"
                                        >

                                            <span class="dot"></span>

                                            Verified

                                        </span>

                                    <?php elseif(
                                        $kyc &&
                                        $kyc->status === 'rejected'
                                    ): ?>

                                        <span
                                            class="badge badge-red"
                                        >

                                            <span class="dot"></span>

                                            Rejected

                                        </span>

                                    <?php elseif($kyc): ?>

                                        <span
                                            class="badge badge-orange"
                                        >

                                            <span class="dot"></span>

                                            Pending

                                        </span>

                                    <?php else: ?>

                                        <span
                                            class="badge badge-gray"
                                        >

                                            Not Submitted

                                        </span>

                                    <?php endif; ?>

                                </td>


                                <td>

                                    <a
                                        href="<?php echo e(route(
                                            'admin.clients.show',
                                            $client
                                        )); ?>"
                                        class="view-btn"
                                    >
                                        View
                                    </a>

                                </td>


                            </tr>


                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                            <tr>

                                <td
                                    colspan="5"
                                    style="
                                        text-align:center;
                                        padding:30px;
                                        color:#9aa6b6;
                                    "
                                >

                                    No clients found.

                                </td>

                            </tr>

                        <?php endif; ?>


                    </tbody>

                </table>


            </div>

        </div>



        <!-- =================================================
             RECENT APPLICATIONS + PAYMENTS
        ================================================== -->

        <div class="dashboard-grid">


            <!-- APPLICATIONS -->

            <div class="card">


                <div class="card-header">

                    <h3>
                        Recent Applications
                    </h3>

                    <a href="<?php echo e(route('admin.applications')); ?>">
                        View All →
                    </a>

                </div>


                <div class="table-wrap">


                    <table>

                        <thead>

                            <tr>

                                <th>
                                    Client
                                </th>

                                <th>
                                    KYC
                                </th>

                                <th>
                                    Date
                                </th>

                            </tr>

                        </thead>


                        <tbody>


                            <?php $__empty_1 = true; $__currentLoopData = $recentApplications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $application): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                                <tr>


                                    <td>

                                        <div class="client">

                                            <div class="client-avatar">

                                                <?php echo e(strtoupper(
                                                        substr(
                                                            $application->name,
                                                            0,
                                                            1
                                                        )
                                                    )); ?>


                                            </div>


                                            <div>

                                                <div class="client-name">

                                                    <?php echo e($application->name); ?>


                                                </div>

                                                <div class="client-email">

                                                    <?php echo e($application->email); ?>


                                                </div>

                                            </div>

                                        </div>

                                    </td>


                                    <td>

                                        <?php if(
                                            $application->clientKyc &&
                                            $application->clientKyc->status
                                                === 'verified'
                                        ): ?>

                                            <span
                                                class="badge badge-green"
                                            >
                                                Verified
                                            </span>

                                        <?php elseif(
                                            $application->clientKyc &&
                                            $application->clientKyc->status
                                                === 'rejected'
                                        ): ?>

                                            <span
                                                class="badge badge-red"
                                            >
                                                Rejected
                                            </span>

                                        <?php elseif(
                                            $application->clientKyc
                                        ): ?>

                                            <span
                                                class="badge badge-orange"
                                            >
                                                Pending
                                            </span>

                                        <?php else: ?>

                                            <span
                                                class="badge badge-gray"
                                            >
                                                Not Submitted
                                            </span>

                                        <?php endif; ?>

                                    </td>


                                    <td>

                                        <?php echo e($application->created_at
                                                ? $application->created_at
                                                    ->format('d M Y')
                                                : '-'); ?>


                                    </td>


                                </tr>


                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                                <tr>

                                    <td
                                        colspan="3"
                                        style="
                                            text-align:center;
                                            padding:25px;
                                            color:#9aa6b6;
                                        "
                                    >
                                        No applications found.
                                    </td>

                                </tr>

                            <?php endif; ?>


                        </tbody>

                    </table>


                </div>


            </div>



            <!-- PAYMENTS -->

            <div class="card">


                <div class="card-header">

                    <h3>
                        Recent Payments
                    </h3>

                    <a href="<?php echo e(route('admin.payments')); ?>">
                        View All →
                    </a>

                </div>


                <div class="table-wrap">


                    <table>

                        <thead>

                            <tr>

                                <th>
                                    Client
                                </th>

                                <th>
                                    Amount
                                </th>

                                <th>
                                    Status
                                </th>

                            </tr>

                        </thead>


                        <tbody>


                            <?php $__empty_1 = true; $__currentLoopData = $recentPayments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>

                                <tr>


                                    <td>

                                        <?php echo e($payment->user->name
                                            ?? 'Unknown'); ?>


                                    </td>


                                    <td>

                                        <span class="amount">

                                            ₹<?php echo e(number_format(
                                                    $payment->amount ?? 0,
                                                    2
                                                )); ?>


                                        </span>

                                    </td>


                                    <td>

                                        <?php if(
                                            $payment->status === 'paid'
                                        ): ?>

                                            <span
                                                class="badge badge-green"
                                            >

                                                <span class="dot"></span>

                                                Paid

                                            </span>

                                        <?php elseif(
                                            $payment->status === 'pending'
                                        ): ?>

                                            <span
                                                class="badge badge-orange"
                                            >

                                                <span class="dot"></span>

                                                Pending

                                            </span>

                                        <?php elseif(
                                            $payment->status === 'failed'
                                        ): ?>

                                            <span
                                                class="badge badge-red"
                                            >

                                                <span class="dot"></span>

                                                Failed

                                            </span>

                                        <?php else: ?>

                                            <span
                                                class="badge badge-gray"
                                            >

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


                                            </span>

                                        <?php endif; ?>

                                    </td>


                                </tr>


                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>

                                <tr>

                                    <td
                                        colspan="3"
                                        style="
                                            text-align:center;
                                            padding:25px;
                                            color:#9aa6b6;
                                        "
                                    >

                                        No payments found.

                                    </td>

                                </tr>

                            <?php endif; ?>


                        </tbody>

                    </table>


                </div>


            </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 C:\laragon\www\emi-card\resources\views/admin/dashboard.blade.php ENDPATH**/ ?>