

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


<?php $__env->startSection('hero'); ?>
<div class="bg-gradient-to-r from-indigo-600 to-purple-700 shadow-md">
    <div class="max-w-full mx-auto px-4 sm:px-6 lg:px-8 py-8">

        <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6">
            <div>
                <h1 class="text-2xl font-bold text-white">
                    <i class="fas fa-graduation-cap mr-2"></i>
                    Self-Paced Learning Portal
                </h1>
                <p class="text-indigo-200 mt-1 text-sm">
                    Welcome back, <?php echo e(auth()->user()->name); ?>. Here's what's happening today.
                </p>
            </div>
            <div class="flex flex-wrap gap-2">
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('create self-paced courses')): ?>
                <a href="<?php echo e(route('self-paced.dashboard.courses.create')); ?>"
                   class="inline-flex items-center gap-2 px-4 py-2 bg-white text-indigo-700 font-semibold text-sm rounded-lg hover:bg-indigo-50 transition shadow">
                    <i class="fas fa-plus"></i> New Course
                </a>
                <?php endif; ?>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('manage self-paced exams')): ?>
                <a href="<?php echo e(route('self-paced.dashboard.exams.index')); ?>"
                   class="inline-flex items-center gap-2 px-4 py-2 bg-white/10 text-white font-medium text-sm rounded-lg hover:bg-white/20 transition border border-white/30">
                    <i class="fas fa-plus"></i> Add Question
                </a>
                <?php endif; ?>
            </div>
        </div>

        
        <div class="grid grid-cols-2 md:grid-cols-4 gap-4">

            <div class="bg-white/10 backdrop-blur-sm rounded-xl p-4 border border-white/20">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-indigo-200 text-xs font-medium uppercase tracking-wide">Total Courses</p>
                        <p class="text-3xl font-bold text-white mt-1"><?php echo e($stats['total_courses']); ?></p>
                        <p class="text-indigo-300 text-xs mt-0.5"><?php echo e($stats['published_courses']); ?> published</p>
                    </div>
                    <i class="fas fa-book-open text-3xl text-white/30"></i>
                </div>
            </div>

            <div class="bg-white/10 backdrop-blur-sm rounded-xl p-4 border border-white/20">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-indigo-200 text-xs font-medium uppercase tracking-wide">Active Enrollments</p>
                        <p class="text-3xl font-bold text-white mt-1"><?php echo e($stats['active_enrollments']); ?></p>
                        <p class="text-indigo-300 text-xs mt-0.5"><?php echo e($stats['total_enrollments']); ?> total</p>
                    </div>
                    <i class="fas fa-users text-3xl text-white/30"></i>
                </div>
            </div>

            <div class="bg-white/10 backdrop-blur-sm rounded-xl p-4 border border-white/20">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-indigo-200 text-xs font-medium uppercase tracking-wide">Exams Taken</p>
                        <p class="text-3xl font-bold text-white mt-1"><?php echo e($stats['exams_taken']); ?></p>
                        <p class="text-indigo-300 text-xs mt-0.5">submitted attempts</p>
                    </div>
                    <i class="fas fa-clipboard-check text-3xl text-white/30"></i>
                </div>
            </div>

            <div class="bg-white/10 backdrop-blur-sm rounded-xl p-4 border border-white/20">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-indigo-200 text-xs font-medium uppercase tracking-wide">Certificates Issued</p>
                        <p class="text-3xl font-bold text-white mt-1"><?php echo e($stats['certificates_issued']); ?></p>
                        <p class="text-indigo-300 text-xs mt-0.5">valid certificates</p>
                    </div>
                    <i class="fas fa-certificate text-3xl text-white/30"></i>
                </div>
            </div>

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


<?php $__env->startSection('content'); ?>
<div class="space-y-6">

    
    <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
        <h2 class="text-base font-semibold text-gray-800 mb-4 flex items-center gap-2">
            <i class="fas fa-bolt text-amber-500"></i> Quick Actions
        </h2>
        <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3">

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('create self-paced courses')): ?>
            <a href="<?php echo e(route('self-paced.dashboard.courses.create')); ?>"
               class="flex flex-col items-center gap-2 p-4 bg-indigo-50 hover:bg-indigo-100 rounded-xl text-center transition group">
                <span class="w-10 h-10 bg-indigo-100 group-hover:bg-indigo-200 rounded-full flex items-center justify-center transition">
                    <i class="fas fa-plus text-indigo-600"></i>
                </span>
                <span class="text-xs font-medium text-gray-700">New Course</span>
            </a>
            <?php endif; ?>

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view self-paced courses')): ?>
            <a href="<?php echo e(route('self-paced.dashboard.courses.index')); ?>"
               class="flex flex-col items-center gap-2 p-4 bg-blue-50 hover:bg-blue-100 rounded-xl text-center transition group">
                <span class="w-10 h-10 bg-blue-100 group-hover:bg-blue-200 rounded-full flex items-center justify-center transition">
                    <i class="fas fa-book-open text-blue-600"></i>
                </span>
                <span class="text-xs font-medium text-gray-700">All Courses</span>
            </a>
            <?php endif; ?>

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('manage self-paced exams')): ?>
            <a href="<?php echo e(route('self-paced.dashboard.exams.index')); ?>"
               class="flex flex-col items-center gap-2 p-4 bg-purple-50 hover:bg-purple-100 rounded-xl text-center transition group">
                <span class="w-10 h-10 bg-purple-100 group-hover:bg-purple-200 rounded-full flex items-center justify-center transition">
                    <i class="fas fa-question-circle text-purple-600"></i>
                </span>
                <span class="text-xs font-medium text-gray-700">Add Question</span>
            </a>
            <?php endif; ?>

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view self-paced enrollments')): ?>
            <a href="<?php echo e(route('self-paced.dashboard.enrollments.index')); ?>"
               class="flex flex-col items-center gap-2 p-4 bg-green-50 hover:bg-green-100 rounded-xl text-center transition group">
                <span class="w-10 h-10 bg-green-100 group-hover:bg-green-200 rounded-full flex items-center justify-center transition">
                    <i class="fas fa-users text-green-600"></i>
                </span>
                <span class="text-xs font-medium text-gray-700">Enrollments</span>
            </a>
            <?php endif; ?>

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view self-paced results')): ?>
            <a href="<?php echo e(route('self-paced.dashboard.results.index')); ?>"
               class="flex flex-col items-center gap-2 p-4 bg-amber-50 hover:bg-amber-100 rounded-xl text-center transition group">
                <span class="w-10 h-10 bg-amber-100 group-hover:bg-amber-200 rounded-full flex items-center justify-center transition">
                    <i class="fas fa-chart-bar text-amber-600"></i>
                </span>
                <span class="text-xs font-medium text-gray-700">View Results</span>
            </a>
            <?php endif; ?>

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('manage self-paced certificates')): ?>
            <a href="<?php echo e(route('self-paced.dashboard.certificates.index')); ?>"
               class="flex flex-col items-center gap-2 p-4 bg-rose-50 hover:bg-rose-100 rounded-xl text-center transition group">
                <span class="w-10 h-10 bg-rose-100 group-hover:bg-rose-200 rounded-full flex items-center justify-center transition">
                    <i class="fas fa-certificate text-rose-600"></i>
                </span>
                <span class="text-xs font-medium text-gray-700">Certificates</span>
            </a>
            <?php endif; ?>

        </div>
    </div>

    
    <div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
        <div class="flex items-center justify-between px-6 py-4 border-b border-gray-100">
            <h2 class="text-base font-semibold text-gray-800 flex items-center gap-2">
                <i class="fas fa-clock text-indigo-500"></i> Recent Enrollments
            </h2>
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view self-paced enrollments')): ?>
            <a href="<?php echo e(route('self-paced.dashboard.enrollments.index')); ?>"
               class="text-xs text-indigo-600 hover:text-indigo-800 font-medium transition">
                View all <i class="fas fa-arrow-right ml-1"></i>
            </a>
            <?php endif; ?>
        </div>

        <?php if($recentEnrollments->isEmpty()): ?>
            <div class="px-6 py-12 text-center">
                <i class="fas fa-users text-4xl text-gray-200 mb-3 block"></i>
                <p class="text-gray-400 text-sm">No enrollments yet.</p>
                <p class="text-gray-300 text-xs mt-1">Enrollments will appear here once learners register.</p>
            </div>
        <?php else: ?>
            <div class="overflow-x-auto">
                <table class="w-full text-sm">
                    <thead>
                        <tr>
                            <th class="bg-indigo-50 text-indigo-700 font-semibold text-left px-4 py-3 text-xs uppercase tracking-wide">#</th>
                            <th class="bg-purple-50 text-purple-700 font-semibold text-left px-4 py-3 text-xs uppercase tracking-wide">Learner</th>
                            <th class="bg-blue-50 text-blue-700 font-semibold text-left px-4 py-3 text-xs uppercase tracking-wide">Course</th>
                            <th class="bg-green-50 text-green-700 font-semibold text-left px-4 py-3 text-xs uppercase tracking-wide">Status</th>
                            <th class="bg-amber-50 text-amber-700 font-semibold text-left px-4 py-3 text-xs uppercase tracking-wide">Amount Paid</th>
                            <th class="bg-rose-50 text-rose-700 font-semibold text-left px-4 py-3 text-xs uppercase tracking-wide">Enrolled</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-50">
                        <?php $__currentLoopData = $recentEnrollments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $enrollment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr class="<?php echo e($i % 2 === 0 ? 'bg-white' : 'bg-gray-50/50'); ?> hover:bg-indigo-50/30 transition">
                            <td class="px-4 py-3 text-gray-400 text-xs"><?php echo e($i + 1); ?></td>
                            <td class="px-4 py-3">
                                <div class="flex items-center gap-2">
                                    <span class="w-7 h-7 bg-indigo-100 rounded-full flex items-center justify-center text-xs font-bold text-indigo-600 flex-shrink-0">
                                        <?php echo e(strtoupper(substr($enrollment->user->name ?? 'U', 0, 1))); ?>

                                    </span>
                                    <div>
                                        <p class="font-medium text-gray-800 text-xs"><?php echo e($enrollment->user->name ?? '—'); ?></p>
                                        <p class="text-gray-400 text-xs"><?php echo e($enrollment->user->email ?? ''); ?></p>
                                    </div>
                                </div>
                            </td>
                            <td class="px-4 py-3">
                                <p class="font-medium text-gray-700 text-xs"><?php echo e($enrollment->course->title ?? '—'); ?></p>
                            </td>
                            <td class="px-4 py-3">
                                <?php
                                    $statusColors = [
                                        'active'          => 'bg-green-100 text-green-700',
                                        'completed'       => 'bg-blue-100 text-blue-700',
                                        'pending_payment' => 'bg-amber-100 text-amber-700',
                                        'payment_failed'  => 'bg-red-100 text-red-700',
                                        'cancelled'       => 'bg-gray-100 text-gray-600',
                                    ];
                                    $color = $statusColors[$enrollment->status] ?? 'bg-gray-100 text-gray-600';
                                ?>
                                <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium <?php echo e($color); ?>">
                                    <?php echo e(ucfirst(str_replace('_', ' ', $enrollment->status))); ?>

                                </span>
                            </td>
                            <td class="px-4 py-3 text-gray-700 text-xs font-medium">
                                <?php echo e($enrollment->amount_paid ? 'UGX ' . number_format($enrollment->amount_paid) : '—'); ?>

                            </td>
                            <td class="px-4 py-3 text-gray-400 text-xs">
                                <?php echo e($enrollment->created_at?->diffForHumans() ?? '—'); ?>

                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        <?php endif; ?>
    </div>

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

<?php echo $__env->make('layouts.self-paced-dashboard', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/www/sshia.org/sshia/resources/views/self-paced/dashboard/index.blade.php ENDPATH**/ ?>