<?php $__env->startSection('content'); ?>
    <!-- My Subscription Section Start -->
    <section class="section-padding section-bg fix">
        <div class="container">
            <div class="dashboard-layout">
                <?php echo $__env->make('student.partials.sidebar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

                <!-- Main Content Start -->
                <div class="dashboard-main">
                    <div class="d-flex flex-wrap justify-content-between align-items-center mb-4 gap-3">
                        <div class="section-title wow fadeInUp mb-0">
                            <h6><?php echo e(__('frontend.subscriptions')); ?></h6>
                            <h2><?php echo e(__('frontend.my_subscription')); ?></h2>
                        </div>
                        <a href="<?php echo e(route('subscriptions.index')); ?>" class="theme-btn btn-sm">
                            <i class="fa-solid fa-layer-group me-1"></i> <?php echo e(__('frontend.browse_all_plans')); ?>

                        </a>
                    </div>

                    <?php if($activeSubscription && $activeSubscription->isActive()): ?>
                        <!-- Active Subscription Card -->
                        <div class="card border-0 shadow-sm rounded-4 mb-4 text-white p-4" style="background: linear-gradient(135deg, #0A5C36 0%, #147A46 100%);">
                            <div class="d-flex justify-content-between align-items-start">
                                <div>
                                    <span class="badge bg-white text-success text-uppercase px-3 py-2 fw-bold mb-2"><?php echo e(__('frontend.current_active_plan')); ?></span>
                                    <h2 class="fw-bold mb-1 text-white"><?php echo e($activeSubscription->plan->name); ?></h2>
                                    <p class="mb-0 opacity-75"><?php echo e($activeSubscription->plan->description ?? __('frontend.unlock_access_desc')); ?></p>
                                </div>
                                <div class="text-end">
                                    <?php if($activeSubscription->ends_at): ?>
                                        <div class="fs-3 fw-bold"><?php echo e($activeSubscription->remaining_days); ?> <?php echo e(__('frontend.days')); ?></div>
                                        <small class="opacity-75"><?php echo e(__('frontend.remaining')); ?></small>
                                    <?php else: ?>
                                        <div class="badge bg-success fs-6"><?php echo e(__('frontend.lifetime_plan')); ?></div>
                                    <?php endif; ?>
                                </div>
                            </div>

                            <hr class="my-3 opacity-25">

                            <div class="row text-center">
                                <div class="col-md-4 mb-2 mb-md-0">
                                    <small class="d-block opacity-75"><?php echo e(__('frontend.started_date')); ?></small>
                                    <strong><?php echo e($activeSubscription->starts_at ? $activeSubscription->starts_at->format('M d, Y') : 'N/A'); ?></strong>
                                </div>
                                <div class="col-md-4 mb-2 mb-md-0">
                                    <small class="d-block opacity-75"><?php echo e(__('frontend.expiration_date')); ?></small>
                                    <strong><?php echo e($activeSubscription->ends_at ? $activeSubscription->ends_at->format('M d, Y') : __('frontend.lifetime_plan')); ?></strong>
                                </div>
                                <div class="col-md-4">
                                    <small class="d-block opacity-75"><?php echo e(__('frontend.billing_period')); ?></small>
                                    <strong class="text-capitalize"><?php echo e(str_replace('_', ' ', $activeSubscription->plan->billing_period)); ?></strong>
                                </div>
                            </div>
                        </div>

                        <!-- Accessible Courses via Active Subscription Card -->
                        <div class="card border-0 shadow-sm rounded-4 p-4 mb-4 bg-white">
                            <div class="d-flex justify-content-between align-items-center mb-3">
                                <h5 class="fw-bold mb-0 text-dark"><i class="fa-solid fa-book-open text-success me-2"></i> <?php echo e(__('frontend.included_courses_in_plan')); ?></h5>
                                <span class="badge bg-light text-dark border"><?php echo e($activeSubscription->plan->courses->count()); ?> <?php echo e(__('frontend.courses_and_live_classes')); ?></span>
                            </div>

                            <div class="alert alert-warning py-2 mb-4 small d-flex align-items-center" style="border-radius: 8px;">
                                <i class="fa-solid fa-triangle-exclamation me-2 fs-6"></i>
                                <span><?php echo e(__('frontend.subscription_notice')); ?></span>
                            </div>

                            <div class="row g-3">
                                <?php $__empty_1 = true; $__currentLoopData = $activeSubscription->plan->courses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $course): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <div class="col-md-6">
                                        <div class="border rounded-3 p-3 d-flex justify-content-between align-items-center bg-light">
                                            <div>
                                                <h6 class="fw-bold mb-1 text-dark"><?php echo e($course->title); ?></h6>
                                                <?php if($course->liveClasses()->exists()): ?>
                                                    <span class="badge bg-danger">Live Course</span>
                                                <?php else: ?>
                                                    <span class="badge bg-secondary">Course</span>
                                                <?php endif; ?>
                                            </div>
                                            <form action="<?php echo e(route('subscriptions.enroll', $course->id)); ?>" method="POST">
                                                <?php echo csrf_field(); ?>
                                                <button type="submit" class="btn btn-sm btn-outline-primary fw-bold" style="border-radius: 6px;">
                                                    <?php echo e(__('frontend.start_course')); ?> <i class="fa-solid fa-arrow-right ms-1"></i>
                                                </button>
                                            </form>
                                        </div>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <div class="col-12 text-muted">No specific courses assigned to this plan yet.</div>
                                <?php endif; ?>
                            </div>
                        </div>
                    <?php else: ?>
                        <!-- No Active Subscription Card -->
                        <div class="card border-0 shadow-sm rounded-4 text-center p-5 mb-4 bg-white">
                            <div class="mb-3">
                                <i class="fa-solid fa-id-card text-muted" style="font-size: 3.5rem;"></i>
                            </div>
                            <h4 class="fw-bold mb-2 text-dark"><?php echo e(__('frontend.no_active_subscription')); ?></h4>
                            <p class="text-muted mb-4"><?php echo e(__('frontend.no_active_subscription_desc')); ?></p>
                            <div>
                                <a href="<?php echo e(route('subscriptions.index')); ?>" class="theme-btn">
                                    <i class="fa-solid fa-plus-circle me-1"></i> <?php echo e(__('frontend.choose_subscription_plan')); ?>

                                </a>
                            </div>
                        </div>
                    <?php endif; ?>

                    <!-- Subscription History Card -->
                    <div class="card border-0 shadow-sm rounded-4 p-4 bg-white">
                        <h5 class="fw-bold mb-3 text-dark"><?php echo e(__('frontend.subscription_history')); ?></h5>
                        <div class="table-responsive">
                            <table class="table align-middle">
                                <thead class="table-light">
                                    <tr>
                                        <th>#</th>
                                        <th>Plan Name</th>
                                        <th>Period</th>
                                        <th>Date</th>
                                        <th>Amount</th>
                                        <th>Status</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__empty_1 = true; $__currentLoopData = $subscriptionHistory; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sub): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                        <tr>
                                            <td><?php echo e($loop->iteration); ?></td>
                                            <td><strong><?php echo e($sub->plan->name ?? 'N/A'); ?></strong></td>
                                            <td class="text-capitalize"><?php echo e(str_replace('_', ' ', $sub->plan->billing_period ?? '')); ?></td>
                                            <td><?php echo e($sub->starts_at ? $sub->starts_at->format('M d, Y') : 'N/A'); ?></td>
                                            <td><?php echo e(currency_symbol()); ?><?php echo e(number_format($sub->payment->amount ?? $sub->plan->effective_price ?? 0, 2)); ?></td>
                                            <td>
                                                <?php if($sub->status === 'active' && $sub->isActive()): ?>
                                                    <span class="badge bg-success">Active</span>
                                                <?php elseif($sub->status === 'pending_approval'): ?>
                                                    <span class="badge bg-warning text-dark">Pending Approval</span>
                                                <?php elseif($sub->status === 'cancelled'): ?>
                                                    <span class="badge bg-secondary">Cancelled</span>
                                                <?php else: ?>
                                                    <span class="badge bg-danger">Expired</span>
                                                <?php endif; ?>
                                            </td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <tr>
                                            <td colspan="6" class="text-center text-muted py-3">No subscription history found.</td>
                                        </tr>
                                    <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </section>
    <!-- My Subscription Section End -->
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.student', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/mahmudul/Codecanyone/edu_ex_full/Eduex_laravel/resources/views/student/subscription.blade.php ENDPATH**/ ?>