

<?php $__env->startSection('title', 'Enrollment — ' . ($enrollment->user->name ?? 'Unknown')); ?>
<?php $__env->startSection('page-title', 'Enrollment Details'); ?>
<?php $__env->startSection('page-subtitle', ($enrollment->user->name ?? 'Unknown') . ' — ' . ($enrollment->course->title ?? 'Unknown Course')); ?>

<?php $__env->startSection('hero-actions'); ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('manage self-paced enrollments')): ?>
    <?php if(!$enrollment->canAccess()): ?>
    <form action="<?php echo e(route('self-paced.dashboard.enrollments.activate', $enrollment)); ?>" method="POST" class="inline">
        <?php echo csrf_field(); ?>
        <button type="submit"
                class="inline-flex items-center gap-2 px-4 py-2 bg-green-500 hover:bg-green-600 text-white text-sm font-semibold rounded-lg transition shadow">
            <i class="fas fa-play"></i> Activate
        </button>
    </form>
    <?php endif; ?>
    <?php if(!$enrollment->isCompleted() && !$enrollment->isCancelled()): ?>
    <form action="<?php echo e(route('self-paced.dashboard.enrollments.cancel', $enrollment)); ?>" method="POST" class="inline"
          onsubmit="return confirm('Cancel this enrollment?')">
        <?php echo csrf_field(); ?>
        <button type="submit"
                class="inline-flex items-center gap-2 px-4 py-2 bg-red-500 hover:bg-red-600 text-white text-sm font-semibold rounded-lg transition shadow">
            <i class="fas fa-ban"></i> Cancel
        </button>
    </form>
    <?php endif; ?>
    <?php if($enrollment->isPendingPayment() || $enrollment->isPaymentFailed()): ?>
    <form action="<?php echo e(route('self-paced.dashboard.enrollments.check-payment', $enrollment)); ?>" method="POST" class="inline">
        <?php echo csrf_field(); ?>
        <button type="submit"
                class="inline-flex items-center gap-2 px-4 py-2 bg-teal-500 hover:bg-teal-600 text-white text-sm font-semibold rounded-lg transition shadow">
            <i class="fas fa-rotate"></i> Check Payment
        </button>
    </form>
    <?php endif; ?>
    <?php endif; ?>
    <a href="<?php echo e(route('self-paced.dashboard.enrollments.index')); ?>"
       class="inline-flex items-center gap-2 px-4 py-2 bg-white/10 hover:bg-white/20 text-white text-sm font-medium rounded-lg transition border border-white/30">
        <i class="fas fa-arrow-left"></i> Back
    </a>
<?php $__env->stopSection(); ?>

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

    
    <div class="grid grid-cols-1 lg:grid-cols-3 gap-5">

        
        <div class="lg:col-span-2 bg-white rounded-xl shadow-sm border border-gray-100 p-6">
            <h2 class="text-sm font-semibold text-gray-800 mb-5 flex items-center gap-2">
                <i class="fas fa-id-card text-indigo-500"></i> Enrollment Information
            </h2>

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

                
                <div>
                    <p class="text-xs text-gray-400 mb-1 flex items-center gap-1">
                        <i class="fas fa-user text-gray-300"></i> Trainee
                    </p>
                    <div class="flex items-center gap-2">
                        <span class="w-8 h-8 bg-purple-100 rounded-full flex items-center justify-center text-sm font-bold text-purple-600 flex-shrink-0">
                            <?php echo e(strtoupper(substr($enrollment->user->name ?? 'U', 0, 1))); ?>

                        </span>
                        <div>
                            <p class="text-sm font-semibold text-gray-800"><?php echo e($enrollment->user->name ?? '—'); ?></p>
                            <p class="text-xs text-gray-400"><?php echo e($enrollment->user->email ?? '—'); ?></p>
                        </div>
                    </div>
                </div>

                
                <div>
                    <p class="text-xs text-gray-400 mb-1 flex items-center gap-1">
                        <i class="fas fa-book text-gray-300"></i> Course
                    </p>
                    <a href="<?php echo e(route('self-paced.dashboard.courses.show', $enrollment->course)); ?>"
                       class="text-sm font-semibold text-indigo-600 hover:text-indigo-800 transition">
                        <?php echo e($enrollment->course->title ?? '—'); ?>

                    </a>
                </div>

                
                <div>
                    <p class="text-xs text-gray-400 mb-1 flex items-center gap-1">
                        <i class="fas fa-circle-info text-gray-300"></i> Status
                    </p>
                    <?php
                        $statusMap = [
                            'active'          => ['bg-green-100 text-green-700',  'fa-circle-check',   'Active'],
                            'completed'       => ['bg-blue-100 text-blue-700',    'fa-graduation-cap', 'Completed'],
                            'pending_payment' => ['bg-amber-100 text-amber-700',  'fa-clock',          'Pending Payment'],
                            'payment_failed'  => ['bg-red-100 text-red-700',      'fa-circle-xmark',   'Payment Failed'],
                            'cancelled'       => ['bg-gray-100 text-gray-500',    'fa-ban',            'Cancelled'],
                        ];
                        [$cls, $icon, $label] = $statusMap[$enrollment->status] ?? ['bg-gray-100 text-gray-500', 'fa-circle', ucfirst($enrollment->status)];
                    ?>
                    <span class="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-sm font-semibold <?php echo e($cls); ?>">
                        <i class="fas <?php echo e($icon); ?>"></i> <?php echo e($label); ?>

                    </span>
                </div>

                
                <div>
                    <p class="text-xs text-gray-400 mb-1 flex items-center gap-1">
                        <i class="fas fa-hashtag text-gray-300"></i> Payment Reference
                    </p>
                    <p class="text-sm font-mono text-gray-700"><?php echo e($enrollment->payment_reference ?? '—'); ?></p>
                </div>

                
                <div>
                    <p class="text-xs text-gray-400 mb-1 flex items-center gap-1">
                        <i class="fas fa-mobile-screen text-gray-300"></i> Payment Method
                    </p>
                    <p class="text-sm text-gray-700">
                        <?php echo e($enrollment->payment_method === 'mtn_momo' ? 'MTN Mobile Money' : ucfirst(str_replace('_', ' ', $enrollment->payment_method))); ?>

                    </p>
                </div>

                
                <div>
                    <p class="text-xs text-gray-400 mb-1 flex items-center gap-1">
                        <i class="fas fa-money-bill text-gray-300"></i> Amount Paid
                    </p>
                    <?php if($enrollment->amount_paid > 0): ?>
                        <p class="text-sm font-semibold text-gray-800">
                            <?php echo e($enrollment->course->currency ?? 'UGX'); ?> <?php echo e(number_format($enrollment->amount_paid)); ?>

                        </p>
                    <?php else: ?>
                        <span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700">
                            <i class="fas fa-gift text-xs"></i> Free
                        </span>
                    <?php endif; ?>
                </div>

                
                <div>
                    <p class="text-xs text-gray-400 mb-1 flex items-center gap-1">
                        <i class="fas fa-calendar-check text-gray-300"></i> Payment Date
                    </p>
                    <p class="text-sm text-gray-700"><?php echo e($enrollment->payment_date?->format('d M Y, H:i') ?? '—'); ?></p>
                </div>

                
                <div>
                    <p class="text-xs text-gray-400 mb-1 flex items-center gap-1">
                        <i class="fas fa-calendar text-gray-300"></i> Enrolled At
                    </p>
                    <p class="text-sm text-gray-700"><?php echo e($enrollment->enrolled_at?->format('d M Y, H:i') ?? '—'); ?></p>
                </div>

                
                <div>
                    <p class="text-xs text-gray-400 mb-1 flex items-center gap-1">
                        <i class="fas fa-flag-checkered text-gray-300"></i> Completed At
                    </p>
                    <p class="text-sm text-gray-700"><?php echo e($enrollment->completed_at?->format('d M Y, H:i') ?? '—'); ?></p>
                </div>

            </div>
        </div>

        
        <div class="space-y-4">

            
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
                <h2 class="text-sm font-semibold text-gray-800 mb-4 flex items-center gap-2">
                    <i class="fas fa-chart-line text-teal-500"></i> Learning Progress
                </h2>
                <div class="mb-3">
                    <div class="flex items-center justify-between mb-1.5">
                        <span class="text-xs text-gray-500">Overall Progress</span>
                        <span class="text-sm font-bold text-indigo-700"><?php echo e($progressPercentage); ?>%</span>
                    </div>
                    <div class="w-full bg-gray-100 rounded-full h-2.5">
                        <div class="bg-indigo-500 h-2.5 rounded-full transition-all"
                             style="width: <?php echo e($progressPercentage); ?>%"></div>
                    </div>
                </div>

                
                <?php if($enrollment->topicTimers->isNotEmpty()): ?>
                <div class="space-y-2 mt-3">
                    <?php $__currentLoopData = $enrollment->topicTimers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $timer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="flex items-center justify-between text-xs">
                        <span class="text-gray-600 truncate flex-1 mr-2"><?php echo e($timer->topic->title ?? 'Topic'); ?></span>
                        <span class="text-gray-400 flex-shrink-0">
                            <?php
                                $h = intdiv($timer->elapsed_seconds, 3600);
                                $m = intdiv($timer->elapsed_seconds % 3600, 60);
                            ?>
                            <?php echo e($h > 0 ? "{$h}h " : ''); ?><?php echo e($m); ?>m
                        </span>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
                <?php else: ?>
                <p class="text-xs text-gray-400 mt-2">No time tracked yet.</p>
                <?php endif; ?>
            </div>

            
            <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
                <h2 class="text-sm font-semibold text-gray-800 mb-3 flex items-center gap-2">
                    <i class="fas fa-certificate text-amber-500"></i> Certificate
                </h2>
                <?php if($enrollment->certificate): ?>
                    <div class="space-y-2 text-xs">
                        <div class="flex justify-between">
                            <span class="text-gray-400">Certificate #</span>
                            <span class="font-mono font-semibold text-gray-700"><?php echo e($enrollment->certificate->certificate_number); ?></span>
                        </div>
                        <div class="flex justify-between">
                            <span class="text-gray-400">Issue Date</span>
                            <span class="text-gray-700"><?php echo e($enrollment->certificate->issue_date?->format('d M Y') ?? '—'); ?></span>
                        </div>
                        <div class="flex justify-between">
                            <span class="text-gray-400">Status</span>
                            <?php if($enrollment->certificate->is_revoked): ?>
                                <span class="text-red-600 font-semibold">Revoked</span>
                            <?php else: ?>
                                <span class="text-green-600 font-semibold">Valid</span>
                            <?php endif; ?>
                        </div>
                    </div>
                    <a href="<?php echo e(route('self-paced.dashboard.certificates.show', $enrollment->certificate)); ?>"
                       class="mt-3 flex items-center gap-1.5 text-xs text-indigo-600 hover:text-indigo-800 font-medium transition">
                        <i class="fas fa-arrow-right"></i> View Certificate
                    </a>
                <?php else: ?>
                    <p class="text-xs text-gray-400">No certificate issued yet.</p>
                <?php endif; ?>
            </div>

        </div>
    </div>

    
    <div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
        <div class="flex items-center justify-between px-5 py-4 border-b border-gray-100">
            <h2 class="text-sm font-semibold text-gray-800 flex items-center gap-2">
                <i class="fas fa-clipboard-question text-purple-500"></i> Exam Attempts
            </h2>
            <span class="text-xs text-gray-400"><?php echo e($enrollment->examAttempts->count()); ?> attempt(s)</span>
        </div>

        <?php if($enrollment->examAttempts->isEmpty()): ?>
        <div class="px-5 py-10 text-center">
            <i class="fas fa-clipboard text-4xl text-gray-200 mb-3 block"></i>
            <p class="text-gray-400 text-sm">No exam attempts yet.</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">Started At</th>
                        <th class="bg-blue-50 text-blue-700 font-semibold text-left px-4 py-3 text-xs uppercase tracking-wide">Submitted At</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">Score</th>
                        <th class="bg-teal-50 text-teal-700 font-semibold text-left px-4 py-3 text-xs uppercase tracking-wide">Result</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-50">
                    <?php $__currentLoopData = $enrollment->examAttempts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $attempt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr class="<?php echo e($i % 2 === 0 ? 'bg-white' : 'bg-gray-50/50'); ?>">
                        <td class="px-4 py-3 text-gray-400 text-xs"><?php echo e($i + 1); ?></td>
                        <td class="px-4 py-3 text-xs text-gray-600"><?php echo e($attempt->started_at?->format('d M Y, H:i') ?? '—'); ?></td>
                        <td class="px-4 py-3 text-xs text-gray-600"><?php echo e($attempt->submitted_at?->format('d M Y, H:i') ?? '—'); ?></td>
                        <td class="px-4 py-3">
                            <?php
                                $attemptStatusMap = [
                                    'in_progress' => 'bg-amber-100 text-amber-700',
                                    'submitted'   => 'bg-blue-100 text-blue-700',
                                    'timed_out'   => 'bg-red-100 text-red-700',
                                    'abandoned'   => 'bg-gray-100 text-gray-500',
                                ];
                            ?>
                            <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium <?php echo e($attemptStatusMap[$attempt->status] ?? 'bg-gray-100 text-gray-500'); ?>">
                                <?php echo e(ucfirst(str_replace('_', ' ', $attempt->status))); ?>

                            </span>
                        </td>
                        <td class="px-4 py-3 text-xs text-gray-700">
                            <?php if($attempt->result): ?>
                                <?php echo e($attempt->result->correct_answers); ?>/<?php echo e($attempt->result->total_questions); ?>

                                (<?php echo e($attempt->result->score_percentage); ?>%)
                            <?php else: ?>
                                <span class="text-gray-300">—</span>
                            <?php endif; ?>
                        </td>
                        <td class="px-4 py-3">
                            <?php if($attempt->result): ?>
                                <?php if($attempt->result->passed): ?>
                                    <span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold bg-green-100 text-green-700">
                                        <i class="fas fa-check text-xs"></i> PASS
                                    </span>
                                <?php else: ?>
                                    <span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold bg-red-100 text-red-700">
                                        <i class="fas fa-times text-xs"></i> FAIL
                                    </span>
                                <?php endif; ?>
                            <?php else: ?>
                                <span class="text-gray-300 text-xs">—</span>
                            <?php endif; ?>
                        </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/enrollments/show.blade.php ENDPATH**/ ?>