

<?php $__env->startSection('title', 'NEX Finserv | 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'); ?>
<link rel="stylesheet" href="<?php echo e(asset('admin/css/dashboard.css')); ?>">
<?php $__env->stopPush(); ?>



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

<div class="dashboard-page">

    

    <div class="welcome">

        <h2>Dashboard Overview</h2>

        <p>
            Monitor clients, applications, loans, KYC verification and payments from one place.
        </p>

    </div>


    

    <div class="stats-grid">

        
        <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>


        
        <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>


        
        <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>


        
        <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 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>


    

    <?php

        /*
         * Only existing dashboard variables are used.
         * No new database query / controller logic required.
         */

        $loanGraphValues = [
            (float) $pendingLoans,
            (float) $approvedLoans,
            (float) $activeLoans,
            (float) $overdueLoans,
            (float) $completedLoans,
        ];

        $loanGraphMax = max(1, max($loanGraphValues));

        $pendingPercent =
            $totalLoans > 0
                ? min(100, ($pendingLoans / $totalLoans) * 100)
                : 0;

        $approvedPercent =
            $totalLoans > 0
                ? min(100, ($approvedLoans / $totalLoans) * 100)
                : 0;

        $activePercent =
            $totalLoans > 0
                ? min(100, ($activeLoans / $totalLoans) * 100)
                : 0;

        $overduePercent =
            $totalLoans > 0
                ? min(100, ($overdueLoans / $totalLoans) * 100)
                : 0;

        $completedPercent =
            $totalLoans > 0
                ? min(100, ($completedLoans / $totalLoans) * 100)
                : 0;

    ?>


    <div class="analytics-grid">

        

        <div class="dashboard-card">

            <div class="dashboard-card-header">

                <div class="dashboard-card-title">

                    <h3>
                        Loan Overview
                    </h3>

                    <p>
                        Current loan portfolio status
                    </p>

                </div>

                <a href="<?php echo e(route('admin.loans')); ?>">
                    Manage Loans →
                </a>

            </div>


            <div class="dashboard-card-body">

                <div class="loan-graph">

                    <div class="graph-summary">

                        <div class="graph-summary-item">
                            <span>Total Loan Value</span>
                            <strong>
                                <?php echo e(money($totalLoanAmount)); ?>

                            </strong>
                        </div>

                        <div class="graph-summary-item">
                            <span>Disbursed</span>
                            <strong>
                                <?php echo e(money($totalDisbursedAmount)); ?>

                            </strong>
                        </div>

                        <div class="graph-summary-item">
                            <span>Outstanding</span>
                            <strong>
                                <?php echo e(money($totalOutstandingAmount)); ?>

                            </strong>
                        </div>

                    </div>


                    <div class="graph-area">

                        <div class="graph-grid">

                            <div class="graph-line"></div>
                            <div class="graph-line"></div>
                            <div class="graph-line"></div>
                            <div class="graph-line"></div>
                            <div class="graph-line"></div>

                        </div>


                        <div class="graph-bars">


                            
                            <div class="graph-column">

                                <?php
                                    $height =
                                        max(
                                            5,
                                            ($pendingLoans / $loanGraphMax) * 100
                                        );
                                ?>

                                <span
                                    class="graph-value"
                                    style="
                                        --bar-height: <?php echo e($height); ?>%;
                                    "
                                >
                                    <?php echo e($pendingLoans); ?>

                                </span>

                                <div
                                    class="graph-bar"
                                    style="height: <?php echo e($height); ?>%;"
                                ></div>

                            </div>


                            
                            <div class="graph-column">

                                <?php
                                    $height =
                                        max(
                                            5,
                                            ($approvedLoans / $loanGraphMax) * 100
                                        );
                                ?>

                                <span
                                    class="graph-value"
                                    style="
                                        --bar-height: <?php echo e($height); ?>%;
                                    "
                                >
                                    <?php echo e($approvedLoans); ?>

                                </span>

                                <div
                                    class="graph-bar"
                                    style="height: <?php echo e($height); ?>%;"
                                ></div>

                            </div>


                            
                            <div class="graph-column">

                                <?php
                                    $height =
                                        max(
                                            5,
                                            ($activeLoans / $loanGraphMax) * 100
                                        );
                                ?>

                                <span
                                    class="graph-value"
                                    style="
                                        --bar-height: <?php echo e($height); ?>%;
                                    "
                                >
                                    <?php echo e($activeLoans); ?>

                                </span>

                                <div
                                    class="graph-bar"
                                    style="height: <?php echo e($height); ?>%;"
                                ></div>

                            </div>


                            
                            <div class="graph-column">

                                <?php
                                    $height =
                                        max(
                                            5,
                                            ($overdueLoans / $loanGraphMax) * 100
                                        );
                                ?>

                                <span
                                    class="graph-value"
                                    style="
                                        --bar-height: <?php echo e($height); ?>%;
                                    "
                                >
                                    <?php echo e($overdueLoans); ?>

                                </span>

                                <div
                                    class="graph-bar"
                                    style="height: <?php echo e($height); ?>%;"
                                ></div>

                            </div>


                            
                            <div class="graph-column">

                                <?php
                                    $height =
                                        max(
                                            5,
                                            ($completedLoans / $loanGraphMax) * 100
                                        );
                                ?>

                                <span
                                    class="graph-value"
                                    style="
                                        --bar-height: <?php echo e($height); ?>%;
                                    "
                                >
                                    <?php echo e($completedLoans); ?>

                                </span>

                                <div
                                    class="graph-bar"
                                    style="height: <?php echo e($height); ?>%;"
                                ></div>

                            </div>

                        </div>


                        <div class="graph-labels">

                            <span>Pending</span>
                            <span>Approved</span>
                            <span>Active</span>
                            <span>Overdue</span>
                            <span>Completed</span>

                        </div>

                    </div>

                </div>

            </div>

        </div>


        

        <div class="dashboard-card">

            <div class="dashboard-card-header">

                <div class="dashboard-card-title">

                    <h3>
                        Loan Status
                    </h3>

                    <p>
                        Portfolio distribution
                    </p>

                </div>

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

            </div>


            <div class="dashboard-card-body">

                <div class="status-list">


                    
                    <div class="status-item">

                        <div class="status-name">

                            <span class="status-dot dot-pending"></span>

                            Pending

                        </div>

                        <div class="status-track">

                            <div
                                class="status-fill fill-pending"
                                style="width:<?php echo e($pendingPercent); ?>%;"
                            ></div>

                        </div>

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

                        </div>

                    </div>


                    
                    <div class="status-item">

                        <div class="status-name">

                            <span class="status-dot dot-approved"></span>

                            Approved

                        </div>

                        <div class="status-track">

                            <div
                                class="status-fill fill-approved"
                                style="width:<?php echo e($approvedPercent); ?>%;"
                            ></div>

                        </div>

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

                        </div>

                    </div>


                    
                    <div class="status-item">

                        <div class="status-name">

                            <span class="status-dot dot-active"></span>

                            Active

                        </div>

                        <div class="status-track">

                            <div
                                class="status-fill fill-active"
                                style="width:<?php echo e($activePercent); ?>%;"
                            ></div>

                        </div>

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

                        </div>

                    </div>


                    
                    <div class="status-item">

                        <div class="status-name">

                            <span class="status-dot dot-overdue"></span>

                            Overdue

                        </div>

                        <div class="status-track">

                            <div
                                class="status-fill fill-overdue"
                                style="width:<?php echo e($overduePercent); ?>%;"
                            ></div>

                        </div>

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

                        </div>

                    </div>


                    
                    <div class="status-item">

                        <div class="status-name">

                            <span class="status-dot dot-completed"></span>

                            Completed

                        </div>

                        <div class="status-track">

                            <div
                                class="status-fill fill-completed"
                                style="width:<?php echo e($completedPercent); ?>%;"
                            ></div>

                        </div>

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

                        </div>

                    </div>


                </div>

            </div>

        </div>

    </div>


    

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

        <div class="dashboard-card-header">

            <div class="dashboard-card-title">

                <h3>
                    Financial Overview
                </h3>

                <p>
                    Loan portfolio financial summary
                </p>

            </div>

            <a href="<?php echo e(route('admin.loans')); ?>">
                Manage Loans →
            </a>

        </div>


        <div class="dashboard-card-body">

            <div class="finance-grid">


                <div class="finance-item">

                    <div class="finance-icon">
                        💵
                    </div>

                    <span>
                        Total Loan Amount
                    </span>

                    <strong>
                        <?php echo e(money($totalLoanAmount)); ?>

                    </strong>

                </div>


                <div class="finance-item">

                    <div class="finance-icon">
                        📤
                    </div>

                    <span>
                        Total Disbursed
                    </span>

                    <strong>
                        <?php echo e(money($totalDisbursedAmount)); ?>

                    </strong>

                </div>


                <div class="finance-item">

                    <div class="finance-icon">
                        📊
                    </div>

                    <span>
                        Outstanding
                    </span>

                    <strong>
                        <?php echo e(money($totalOutstandingAmount)); ?>

                    </strong>

                </div>


                <div class="finance-item">

                    <div class="finance-icon">
                        🧾
                    </div>

                    <span>
                        Processing Fees
                    </span>

                    <strong>
                        <?php echo e(money($totalProcessingFees)); ?>

                    </strong>

                </div>


            </div>

        </div>

    </div>


    

    <div class="bottom-grid">


        

        <div class="dashboard-card">

            <div class="dashboard-card-header">

                <div class="dashboard-card-title">

                    <h3>
                        KYC Overview
                    </h3>

                    <p>
                        Client verification status
                    </p>

                </div>

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

            </div>


            <div class="dashboard-card-body">

                <div class="kyc-list">


                    <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>


        

        <div class="dashboard-card">

            <div class="dashboard-card-header">

                <div class="dashboard-card-title">

                    <h3>
                        Quick Actions
                    </h3>

                    <p>
                        Frequently used management tools
                    </p>

                </div>

                <span style="
                    color:#9aa6b6;
                    font-size:8px;
                    font-weight:800;
                ">
                    Manage
                </span>

            </div>


            <div class="dashboard-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>


                </div>

            </div>

        </div>

    </div>


    

    <?php

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

    ?>


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

        <div class="dashboard-card-header">

            <div class="dashboard-card-title">

                <h3>
                    Recent Notifications
                </h3>

                <p>
                    Latest system and loan updates
                </p>

            </div>

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

        </div>


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

            <div class="notification-list">

                <?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'
                            );

                        $notificationBg =
                            $notificationLevel === 'success'
                                ? '#e8f8ef'
                                : (
                                    $notificationLevel === 'warning'
                                        ? '#fff4df'
                                        : (
                                            $notificationLevel === 'error'
                                                ? '#fff1f2'
                                                : '#eaf2ff'
                                        )
                                );

                        $notificationIcon =
                            $notificationLevel === 'success'
                                ? '✓'
                                : (
                                    $notificationLevel === 'warning'
                                        ? '⚠'
                                        : (
                                            $notificationLevel === 'error'
                                                ? '!'
                                                : '🔔'
                                        )
                                );

                    ?>


                    <div class="notification-row">

                        <div
                            class="notification-icon"
                            style="
                                background:<?php echo e($notificationBg); ?>;
                            "
                        >
                            <?php echo e($notificationIcon); ?>

                        </div>


                        <div class="notification-content">

                            <div class="notification-title">
                                <?php echo e($notificationTitle); ?>

                            </div>

                            <div class="notification-message">
                                <?php echo e($notificationMessage); ?>

                            </div>

                            <div class="notification-time">

                                <?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
                                )); ?>"
                            >

                                <?php echo csrf_field(); ?>

                                <button
                                    type="submit"
                                    class="notification-open"
                                >
                                    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>

    </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**/ ?>