<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Client Portal | IMMIA FINANCE LIMITED</title>
    
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    
    <style>
        :root {
            --zedbank-blue: #0077C5;
            --zedbank-blue-dark: #005A94;
        }

        .bg-zedbank-blue { background-color: var(--zedbank-blue); }
        .bg-zedbank-blue-dark { background-color: var(--zedbank-blue-dark); }
        .text-zedbank-blue { color: var(--zedbank-blue); }

        .sidebar { transition: all 0.3s ease; }
        @media (max-width: 768px) {
            .sidebar { transform: translateX(-100%); }
            .sidebar.active { transform: translateX(0); }
        }
        
        .card-hover { transition: all 0.3s ease; }
        .card-hover:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        
        .notification-dot { animation: pulse 2s infinite; }
        @keyframes pulse {
            0% { opacity: 1; }
            50% { opacity: 0.5; }
            100% { opacity: 1; }
        }
        
        .text-truncate-safe {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            min-width: 0;
        }
    </style>
</head>
<body class="bg-gray-50">
   <?php
    $customer = Auth::guard('customer')->user();
    ?>

    <button id="mobile-menu-button" class="lg:hidden fixed top-4 left-4 z-50 bg-zedbank-blue text-white p-3 rounded-lg shadow-lg">
        <i class="fas fa-bars"></i>
    </button>

    <div id="sidebar" class="sidebar fixed inset-y-0 left-0 z-40 w-64 bg-zedbank-blue shadow-lg text-white">
        <div class="p-6 border-b border-zedbank-blue-dark">
            <div class="flex items-center space-x-3">
                <div class="w-10 h-10 bg-white rounded-lg flex items-center justify-center">
                    <i class="fas fa-hand-holding-usd text-zedbank-blue text-lg"></i>
                </div>
                <div>
                    <h1 class="text-xl font-bold">IMMIA FINANCE</h1>
                    <p class="text-blue-100 text-xs">Client Portal</p>
                </div>
            </div>
        </div>
        
        <nav class="p-4 space-y-2">
            <a href="<?php echo e(route('customer.dashboard')); ?>" class="flex items-center space-x-3 p-3 bg-zedbank-blue-dark rounded-lg font-medium">
                <i class="fas fa-tachometer-alt w-5"></i>
                <span>Dashboard</span>
            </a>
            <a href="<?php echo e(route('customer.applications.index')); ?>" class="flex items-center space-x-3 p-3 hover:bg-zedbank-blue-dark rounded-lg font-medium">
                <i class="fas fa-file-invoice-dollar w-5"></i>
                <span>My Applications</span>
                <?php if(count($activeApplications) > 0): ?>
                <span class="ml-auto bg-white text-zedbank-blue text-xs px-2 py-1 rounded-full"><?php echo e(count($activeApplications)); ?></span>
                <?php endif; ?>
            </a>
            <a href="<?php echo e(route('customer.loans.index')); ?>" class="flex items-center space-x-3 p-3 hover:bg-zedbank-blue-dark rounded-lg font-medium">
                <i class="fas fa-hand-holding-usd w-5"></i>
                <span>My Loans</span>
                <?php if($loanStats['active_loans_count'] > 0): ?>
                <span class="ml-auto bg-green-400 text-white text-xs px-2 py-1 rounded-full font-bold"><?php echo e($loanStats['active_loans_count']); ?></span>
                <?php endif; ?>
            </a>
            <a href="<?php echo e(route('customer.loan.application.show')); ?>" class="flex items-center space-x-3 p-3 hover:bg-zedbank-blue-dark rounded-lg font-medium">
                <i class="fas fa-paper-plane w-5"></i>
                <span>Apply for Loan</span>
            </a>
            <a href="<?php echo e(route('customer.payments.method')); ?>" class="flex items-center space-x-3 p-3 hover:bg-zedbank-blue-dark rounded-lg font-medium">
                <i class="fas fa-money-bill-wave w-5"></i>
                <span>Make Payment</span>
            </a>
            <a href="<?php echo e(route('customer.transactions.history')); ?>" class="flex items-center space-x-3 p-3 hover:bg-zedbank-blue-dark rounded-lg font-medium">
                <i class="fas fa-history w-5"></i>
                <span>Transaction History</span>
            </a>
            <a href="<?php echo e(route('customer.profile.show')); ?>" class="flex items-center space-x-3 p-3 hover:bg-zedbank-blue-dark rounded-lg font-medium">
                <i class="fas fa-user-cog w-5"></i>
                <span>Profile Settings</span>
            </a>
            <form method="POST" action="<?php echo e(route('customer.logout')); ?>" class="mt-8">
                <?php echo csrf_field(); ?>
                <button type="submit" class="flex items-center space-x-3 p-3 hover:bg-red-600 rounded-lg font-medium w-full text-left">
                    <i class="fas fa-sign-out-alt w-5"></i>
                    <span>Logout</span>
                </button>
            </form>
        </nav>
    </div>

    <div class="lg:ml-64">
        <header class="bg-zedbank-blue shadow-sm border-b border-zedbank-blue-dark">
            <div class="flex justify-between items-center px-4 sm:px-6 py-4">
                <div class="min-w-0 flex-1">
                    <h1 class="text-xl sm:text-2xl font-bold text-white text-truncate-safe">Dashboard</h1>
                    <p class="text-blue-50 text-sm text-truncate-safe">Welcome back, <?php echo e($customer->customer); ?></p>
                </div>
                
                <div class="flex items-center space-x-4">
                    <div class="relative">
                        <button class="p-2 text-white hover:bg-zedbank-blue-dark rounded-full relative">
                            <i class="fas fa-bell text-xl"></i>
                            <span class="absolute top-1 right-1 w-2 h-2 bg-red-500 rounded-full notification-dot"></span>
                        </button>
                    </div>
                    <div class="flex items-center space-x-3 p-2 rounded-lg bg-zedbank-blue-dark text-white">
    <div class="w-8 h-8 rounded-full overflow-hidden border border-white flex items-center justify-center bg-zedbank-blue">
        <?php if($customer->docpath): ?>
            
            <img src="https://zedbankos.cloud/manageportal/api/customer/profile/<?php echo e($customer->id); ?>/photo" 
                 alt="Profile" 
                 class="w-full h-full object-cover">
        <?php else: ?>
            
            <i class="fas fa-user text-sm"></i>
        <?php endif; ?>
    </div>
    <span class="font-medium hidden sm:block"><?php echo e($customer->customer); ?></span>
</div>
                </div>
            </div>
        </header>

        <main class="p-4 sm:p-6">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
                <div class="bg-white rounded-xl p-6 shadow-sm border border-gray-100 card-hover relative overflow-hidden">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-gray-500 text-xs font-bold uppercase tracking-wider">Total Balance</p>
                            <p class="text-2xl sm:text-3xl font-bold text-zedbank-blue">ZMW <?php echo e(number_format($loanStats['total_outstanding_balance'], 2)); ?></p>
                        </div>
                        <div class="w-12 h-12 bg-zedbank-blue text-white rounded-xl flex items-center justify-center">
                            <i class="fas fa-wallet text-xl"></i>
                        </div>
                    </div>
                    <div class="mt-4 flex justify-between items-center">
                        <p class="text-[10px] text-gray-400 font-bold uppercase">Total liability</p>
                        <a href="javascript:void(0)" onclick="goToPayment('<?php echo e($loanStats['total_outstanding_balance']); ?>')" class="text-[10px] font-bold text-zedbank-blue hover:underline">PAY FULL <i class="fas fa-chevron-right ml-1"></i></a>
                    </div>
                </div>

                <div class="bg-red-600 rounded-xl p-6 shadow-lg border border-red-700 card-hover text-white">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-red-100 text-xs font-bold uppercase tracking-wider">Total Due Amount</p>
                            <p class="text-2xl sm:text-3xl font-black">ZMW <?php echo e(number_format($loanStats['total_overdue_amount'] ?? 0, 2)); ?></p>
                        </div>
                        <div class="w-12 h-12 bg-white text-red-600 rounded-xl flex items-center justify-center">
                            <i class="fas fa-exclamation-triangle text-xl"></i>
                        </div>
                    </div>
                    <div class="mt-4 flex justify-between items-center">
                        <p class="text-[10px] font-bold uppercase">Arrears + Penalties</p>
                        <a href="javascript:void(0)" onclick="goToPayment('<?php echo e($loanStats['total_overdue_amount'] ?? 0); ?>')" class="bg-white text-red-600 px-2 py-1 rounded text-[10px] font-bold shadow-sm hover:bg-gray-100 transition-colors uppercase">Clear Due</a>
                    </div>
                </div>

                <div class="bg-amber-500 rounded-xl p-6 shadow-lg border border-amber-600 card-hover text-white">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-amber-50 text-xs font-bold uppercase tracking-wider">Next Installment</p>
                            <p class="text-2xl sm:text-3xl font-black">ZMW <?php echo e(number_format($nextInstallment->totalamount, 2)); ?></p>
                        </div>
                        <div class="w-12 h-12 bg-white text-amber-500 rounded-xl flex items-center justify-center">
                            <i class="fas fa-hourglass-half text-xl"></i>
                        </div>
                    </div>
                    <div class="mt-4 flex justify-between items-center text-[10px] font-bold">
                        <span>DUE: <?php echo e($loanStats['next_due_date'] ?? 'N/A'); ?></span>
                        <a href="javascript:void(0)" onclick="goToPayment('<?php echo e($loanStats['total_next_due_amount']); ?>')" class="bg-amber-700 px-2 py-1 rounded hover:bg-amber-800 transition-colors">PAY NOW</a>
                    </div>
                </div>
          
          
            </div>

            <div class="bg-white rounded-xl shadow-sm border mb-8">
                <div class="p-6 border-b border-gray-100">
                    <h2 class="text-lg font-bold text-gray-900">Quick Actions</h2>
                </div>
                <div class="p-6">
                    <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
                        <a href="<?php echo e(route('customer.loan.application.show')); ?>" class="flex flex-col items-center p-4 border border-gray-100 rounded-xl hover:bg-blue-50 card-hover">
                            <div class="w-12 h-12 bg-blue-100 text-blue-600 rounded-lg flex items-center justify-center mb-3">
                                <i class="fas fa-paper-plane text-xl"></i>
                            </div>
                            <span class="text-sm font-bold text-gray-900">Apply for Loan</span>
                        </a>
                        <a href="<?php echo e(route('customer.loans.index')); ?>" class="flex flex-col items-center p-4 border border-gray-100 rounded-xl hover:bg-green-50 card-hover">
                            <div class="w-12 h-12 bg-green-100 text-green-600 rounded-lg flex items-center justify-center mb-3">
                                <i class="fas fa-hand-holding-usd text-xl"></i>
                            </div>
                            <span class="text-sm font-bold text-gray-900">My Loans</span>
                        </a>
                        <a href="#" class="flex flex-col items-center p-4 border border-gray-100 rounded-xl hover:bg-purple-50 card-hover">
                            <div class="w-12 h-12 bg-purple-100 text-purple-600 rounded-lg flex items-center justify-center mb-3">
                                <i class="fas fa-file-alt text-xl"></i>
                            </div>
                            <span class="text-sm font-bold text-gray-900">Documents</span>
                        </a>
                        <a href="#" class="flex flex-col items-center p-4 border border-gray-100 rounded-xl hover:bg-orange-50 card-hover">
                            <div class="w-12 h-12 bg-orange-100 text-orange-600 rounded-lg flex items-center justify-center mb-3">
                                <i class="fas fa-headset text-xl"></i>
                            </div>
                            <span class="text-sm font-bold text-gray-900">Support</span>
                        </a>
                    </div>
                </div>
            </div>

            <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
                <div class="lg:col-span-2 space-y-6">
                    <div class="bg-white rounded-xl shadow-sm border border-gray-100">
                        <div class="p-6 border-b border-gray-100">
                            <h2 class="text-lg font-bold text-gray-900">Active Applications</h2>
                        </div>
                        <div class="p-6">
                            <?php if(count($activeApplications) > 0): ?>
                            <div class="space-y-4">
                                <?php $__currentLoopData = $applicationProgress; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="p-4 bg-gray-50 rounded-xl border border-gray-100">
                                    <div class="flex justify-between items-center mb-2">
                                        <span class="font-bold text-gray-900"><?php echo e($data['application']->product->product); ?></span>
                                        <span class="text-[10px] font-bold bg-<?php echo e($data['status_color']); ?>-100 text-<?php echo e($data['status_color']); ?>-700 px-2 py-0.5 rounded uppercase"><?php echo e($data['status_text']); ?></span>
                                    </div>
                                    <div class="w-full bg-gray-200 h-1.5 rounded-full mb-2">
                                        <div class="bg-<?php echo e($data['status_color']); ?>-600 h-1.5 rounded-full" style="width: <?php echo e($data['progress']); ?>%"></div>
                                    </div>
                                    <div class="flex justify-between text-[10px] font-bold text-gray-400">
                                        <span>#<?php echo e($data['application']->application_number); ?></span>
                                        <span>ZMW <?php echo e(number_format($data['application']->loan_amount, 2)); ?></span>
                                    </div>
                                </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                            <?php else: ?>
                            <div class="text-center py-8 text-gray-400 italic">No active applications found.</div>
                            <?php endif; ?>
                        </div>
                    </div>

                    <div class="bg-white rounded-xl shadow-sm border border-gray-100">
                        <div class="p-6 border-b border-gray-100">
                            <h2 class="text-lg font-bold text-gray-900">Active Loans Summary</h2>
                        </div>
                        <div class="p-6">
                            <?php if($loanStats['active_loans_count'] > 0): ?>
                            <div class="space-y-6">
                                <?php $__currentLoopData = $loanStats['active_loans']->take(3); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $loan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="border border-gray-100 rounded-xl p-5 shadow-sm">
                                    <div class="flex justify-between items-start mb-4">
                                        <div>
                                            <h3 class="text-lg font-bold text-gray-900"><?php echo e($loan->loanType->product ?? 'Loan'); ?></h3>
                                            <p class="text-gray-400 text-xs font-medium">#<?php echo e($loan->loannumber); ?></p>
                                        </div>
                                        <p class="text-xl font-bold text-green-600">ZMW <?php echo e(number_format($loan->amount, 2)); ?></p>
                                    </div>
                                    <div class="w-full bg-gray-100 h-2 rounded-full mb-3">
                                        <div class="bg-green-600 h-2 rounded-full" style="width: <?php echo e($loan->getCollectionProgressAttribute()); ?>%"></div>
                                    </div>
                                    <div class="flex justify-between text-xs font-bold text-gray-500 uppercase">
                                        <span>Paid: ZMW <?php echo e(number_format($loan->totalpaid, 2)); ?></span>
                                        <span>Progress: <?php echo e($loan->getCollectionProgressAttribute()); ?>%</span>
                                    </div>
                                    <a href="<?php echo e(route('customer.loans.show', $loan->loanid)); ?>" class="block mt-4 text-center py-2 bg-gray-50 rounded-lg text-xs font-bold text-zedbank-blue hover:bg-zedbank-blue hover:text-white transition-colors">View Loan Details</a>
                                </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>

                <div class="space-y-6">
                    <div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
                        <div class="p-6 bg-zedbank-blue text-white text-center">
                            <h2 class="text-lg font-bold">Credit Score</h2>
                            <div class="my-6 flex justify-center">
                                <div class="relative w-32 h-32 flex items-center justify-center">
                                    <svg class="w-full h-full transform -rotate-90"><circle cx="64" cy="64" r="58" stroke="currentColor" stroke-width="8" fill="transparent" class="text-blue-800" /><circle cx="64" cy="64" r="58" stroke="currentColor" stroke-width="8" fill="transparent" stroke-dasharray="364.4" stroke-dashoffset="<?php echo e(364.4 - (364.4 * ($creditScoreInfo['current_score'] / 850))); ?>" class="text-green-400" /></svg>
                                    <span class="absolute text-3xl font-black"><?php echo e($creditScoreInfo['current_score']); ?></span>
                                </div>
                            </div>
                            <p class="font-bold uppercase tracking-widest text-sm"><?php echo e($creditScoreInfo['score_band']); ?></p>
                        </div>
                        <div class="p-6 space-y-3">
                            <div class="flex justify-between text-xs font-bold"><span class="text-gray-400 uppercase">Risk</span><span class="<?php echo e($creditScoreInfo['has_good_credit'] ? 'text-green-600' : 'text-red-600'); ?>"><?php echo e($creditScoreInfo['risk_level']); ?></span></div>
                            <div class="flex justify-between text-xs font-bold"><span class="text-gray-400 uppercase">On-Time Rate</span><span class="text-gray-900"><?php echo e($creditScoreInfo['repayment_rate']); ?>%</span></div>
                        </div>
                    </div>

                    <div class="bg-white rounded-xl shadow-sm border border-gray-100">
                        <div class="p-6 border-b border-gray-100"><h2 class="text-sm font-bold uppercase tracking-widest text-gray-900">Recent Activity</h2></div>
                        <div class="p-6">
                            <div class="space-y-4">
                                <?php $__currentLoopData = $recentApplications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $app): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="flex items-start space-x-3">
                                    <div class="w-2 h-2 mt-1.5 rounded-full bg-blue-500"></div>
                                    <div>
                                        <p class="text-sm font-bold text-gray-900"><?php echo e($app->product->product); ?></p>
                                        <p class="text-[10px] text-gray-400 font-bold"><?php echo e($app->created_at->diffForHumans()); ?></p>
                                    </div>
                                </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            
            
        </main>
    </div>

    <form id="redirect-pay-form" action="<?php echo e(route('customer.payments.method')); ?>" method="GET" class="hidden">
        <input type="hidden" name="amount" id="redirect-amount">
    </form>

    <script>
        document.getElementById('mobile-menu-button').addEventListener('click', function() {
            document.getElementById('sidebar').classList.toggle('active');
        });

        // Dynamic Redirection Script
        function goToPayment(amount) {
            document.getElementById('redirect-amount').value = amount;
            document.getElementById('redirect-pay-form').submit();
        }
    </script>
</body>
</html><?php /**PATH /home/topacvbu/public_html/zedbankos.cloud/customer-portal/resources/views/customer/dashboard.blade.php ENDPATH**/ ?>