<?php $__env->startSection('breadcrumb'); ?>
    <?php echo $__env->make('partials.breadcrumb', [
        'page_title' => $pageTitle ?? __('frontend.course_details'),
        'base_url' => route('home'),
    ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>

    <!-- Courses Details Section Start -->
    <section class="mhq-courses-details-section section-padding">
        <div class="container">
            <div class="mhq-courses-details-area">
                <div class="mhq-image wow fadeInUp" data-wow-delay=".3s" style="position: relative; overflow: hidden;">
                    <?php if($course->featured_image): ?>
                        <img src="<?php echo e(asset('storage/' . $course->featured_image)); ?>" alt="<?php echo e($course->title); ?>"
                            style="width: 100%; height: auto; display: block;">
                    <?php else: ?>
                        <img src="<?php echo e(asset('assets/front/img/inner/courses-details/courses-details.jpg')); ?>"
                            alt="<?php echo e($course->title); ?>" style="width: 100%; height: auto; display: block;">
                    <?php endif; ?>
                    <?php if($course->intro_video): ?>
                        <div class="intro-video-overlay"
                            style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.3); opacity: 0; transition: opacity 0.3s ease; cursor: pointer; z-index: 10;">
                            <a href="javascript:void(0)" class="intro-video-play-btn"
                                data-intro-video="<?php echo e(asset('storage/' . $course->intro_video)); ?>"
                                style="color: white; font-size: 60px; text-decoration: none; z-index: 11;">
                                <i class="fa-regular fa-circle-play breathing-animation"></i>
                            </a>
                        </div>
                    <?php endif; ?>
                </div>
                <div class="mhq-courses-details-wrapper">
                    <div class="row">
                        <div class="col-lg-8">
                            <div class="mhq-left-content">
                                <ul class="list-date wow fadeInUp" data-wow-delay=".2s">
                                    <?php if($course->category): ?>
                                        <li>
                                            <h6>
                                                <?php echo e(ucfirst($course->category)); ?>

                                            </h6>
                                        </li>
                                    <?php endif; ?>
                                    <?php if($totalReviews > 0): ?>
                                        <li>
                                            <i class="fa-solid fa-star-sharp"></i>
                                            (<?php echo e($averageRating); ?> - <?php echo e($totalReviews); ?> <?php echo e(__('frontend.all_reviews')); ?>)
                                        </li>
                                    <?php endif; ?>
                                    <?php if($courseStartDate): ?>
                                        <li>
                                            <i class="fas fa-calendar-alt"></i>
                                            <span><?php echo e(__('frontend.starts_in')); ?>: </span>
                                            <span class="countdown-timer"
                                                data-date="<?php echo e($courseStartDate->format('Y-m-d H:i:s')); ?>">
                                                <span class="countdown-days">0</span>d
                                                <span class="countdown-hours">0</span>h
                                                <span class="countdown-minutes">0</span>m
                                                <span class="countdown-seconds">0</span>s
                                            </span>
                                        </li>
                                    <?php endif; ?>
                                </ul>
                                <h3 class="wow fadeInUp" data-wow-delay=".3s">
                                    <?php echo e($course->title); ?>

                                    <?php if($course->is_live_course): ?>
                                        <span class="badge bg-danger ms-2" style="font-size: 14px; vertical-align: middle;">
                                            <i class="fas fa-broadcast-tower me-1"></i> <?php echo e(__('frontend.live')); ?>

                                        </span>
                                    <?php endif; ?>
                                </h3>
                                <div class="courses-details-content">
                                    <ul class="nav">
                                        <li class="nav-item wow fadeInUp" data-wow-delay=".3s">
                                            <a href="#Course" data-bs-toggle="tab" class="nav-link active">
                                                <?php echo e(__('frontend.course_info')); ?>

                                            </a>
                                        </li>
                                        <li class="nav-item wow fadeInUp" data-wow-delay=".5s">
                                            <a href="#Curriculum" data-bs-toggle="tab" class="nav-link">
                                                <?php echo e(__('frontend.curriculum')); ?>

                                            </a>
                                        </li>
                                        <li class="nav-item wow fadeInUp" data-wow-delay=".5s">
                                            <a href="#Instructors" data-bs-toggle="tab" class="nav-link">
                                                <?php echo e(__('frontend.instructors')); ?>

                                            </a>
                                        </li>
                                        <?php if($totalReviews > 0 || $canReview): ?>
                                            <li class="nav-item wow fadeInUp" data-wow-delay=".5s">
                                                <a href="#Reviews" data-bs-toggle="tab" class="nav-link bb-none">
                                                    <?php echo e(__('frontend.all_reviews')); ?>

                                                </a>
                                            </li>
                                        <?php endif; ?>
                                    </ul>
                                    <div class="tab-content">
                                        <div id="Course" class="tab-pane fade show active">
                                            <div class="description-content">
                                                <h3><?php echo e(__('frontend.description')); ?></h3>
                                                <div class="mb-3">
                                                    <?php echo $course->description ?? '<p>' . __('frontend.no_description') . '</p>'; ?>

                                                </div>

                                                <?php if($course->objectives): ?>
                                                    <h3 class="mt-5"><?php echo e(__('frontend.what_learn')); ?></h3>
                                                    <div class="row g-4 mb-5">
                                                        <?php
                                                            $objectives = array_filter(
                                                                array_map('trim', explode("\n", $course->objectives)),
                                                            );
                                                            $midPoint = ceil(count($objectives) / 2);
                                                            $firstColumn = array_slice($objectives, 0, $midPoint);
                                                            $secondColumn = array_slice($objectives, $midPoint);
                                                        ?>
                                                        <div class="col-lg-6">
                                                            <ul class="list-item">
                                                                <?php $__currentLoopData = $firstColumn; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $objective): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <li>
                                                                        <i class="fas fa-check-circle"></i>
                                                                        <?php echo e($objective); ?>

                                                                    </li>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                            </ul>
                                                        </div>
                                                        <?php if(count($secondColumn) > 0): ?>
                                                            <div class="col-lg-6">
                                                                <ul class="list-item">
                                                                    <?php $__currentLoopData = $secondColumn; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $objective): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                        <li>
                                                                            <i class="fas fa-check-circle"></i>
                                                                            <?php echo e($objective); ?>

                                                                        </li>
                                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                </ul>
                                                            </div>
                                                        <?php endif; ?>
                                                    </div>
                                                <?php endif; ?>

                                                <?php if($course->requirements): ?>
                                                    <h3><?php echo e(__('frontend.requirements')); ?></h3>
                                                    <p>
                                                        <?php echo nl2br(e($course->requirements)); ?>

                                                    </p>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div id="Curriculum" class="tab-pane fade">
                                            <div class="course-curriculum-items">
                                                <h3><?php echo e(__('frontend.course_curriculum')); ?></h3>
                                                <div class="courses-faq-items">
                                                    <div class="accordion" id="accordionExample">
                                                        <?php $__currentLoopData = $course->topics; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $topicIndex => $topic): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <div
                                                                class="accordion-item <?php echo e($topicIndex === $course->topics->count() - 1 ? 'mb-0' : ''); ?>">
                                                                <h2 class="accordion-header"
                                                                    id="heading<?php echo e($topic->id); ?>">
                                                                    <button
                                                                        class="accordion-button <?php echo e($topicIndex === 0 ? '' : 'collapsed'); ?>"
                                                                        type="button" data-bs-toggle="collapse"
                                                                        data-bs-target="#collapse<?php echo e($topic->id); ?>"
                                                                        aria-expanded="<?php echo e($topicIndex === 0 ? 'true' : 'false'); ?>"
                                                                        aria-controls="collapse<?php echo e($topic->id); ?>">
                                                                        <?php echo e($topic->title); ?>

                                                                    </button>
                                                                </h2>
                                                                <div id="collapse<?php echo e($topic->id); ?>"
                                                                    class="accordion-collapse collapse <?php echo e($topicIndex === 0 ? 'show' : ''); ?>"
                                                                    aria-labelledby="heading<?php echo e($topic->id); ?>"
                                                                    data-bs-parent="#accordionExample">
                                                                    <div class="accordion-body">
                                                                        <ul>
                                                                            <?php $__currentLoopData = $topic->lessons; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lesson): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                                <li>
                                                                                    <span>
                                                                                        <i class="fas fa-file-alt"></i>
                                                                                        <?php echo e($lesson->title); ?>

                                                                                        <?php if($lesson->is_live): ?>
                                                                                            <span class="badge bg-danger ms-2">
                                                                                                <i class="fas fa-broadcast-tower me-1"></i> <?php echo e(__('frontend.live')); ?>

                                                                                            </span>
                                                                                        <?php endif; ?>
                                                                                        <?php if($lesson->is_preview): ?>
                                                                                            <span
                                                                                                class="badge bg-info ms-2"><?php echo e(__('frontend.preview')); ?></span>
                                                                                        <?php endif; ?>
                                                                                    </span>
                                                                                    <span>
                                                                                        <?php if(
                                                                                            $lesson->is_preview &&
                                                                                                (($lesson->video_type === 'url' && $lesson->video_url) ||
                                                                                                    ($lesson->video_type === 'upload' && $lesson->video_path))): ?>
                                                                                            <a href="javascript:void(0)"
                                                                                                class="lesson-preview-play"
                                                                                                data-video-type="<?php echo e($lesson->video_type); ?>"
                                                                                                data-video-url="<?php echo e($lesson->video_type === 'url' ? $lesson->video_url : asset('storage/' . $lesson->video_path)); ?>"
                                                                                                data-lesson-title="<?php echo e($lesson->title); ?>"
                                                                                                style="cursor: pointer; text-decoration: none;">
                                                                                                <i
                                                                                                    class="fa-regular fa-circle-play text-primary me-2"></i>
                                                                                                <?php if($lesson->duration): ?>
                                                                                                    <?php echo e(gmdate('H:i', $lesson->duration * 60)); ?>

                                                                                                <?php endif; ?>
                                                                                            </a>
                                                                                        <?php else: ?>
                                                                                            <i class="far fa-lock me-2"></i>
                                                                                            <?php if($lesson->duration): ?>
                                                                                                <?php echo e(gmdate('H:i', $lesson->duration * 60)); ?>

                                                                                            <?php endif; ?>
                                                                                        <?php endif; ?>
                                                                                    </span>
                                                                                </li>
                                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                                                            <?php $__currentLoopData = $topic->quizzes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $quiz): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                                <li>
                                                                                    <span>
                                                                                        <i
                                                                                            class="fas fa-question-circle"></i>
                                                                                        <?php echo e(__('frontend.quiz')); ?>: <?php echo e($quiz->title); ?>


                                                                                    </span>
                                                                                    <span>
                                                                                        <i class="far fa-lock"></i>
                                                                                        <?php if($quiz->time_limit): ?>
                                                                                            <?php echo e($quiz->time_limit); ?> min
                                                                                        <?php endif; ?>
                                                                                    </span>
                                                                                </li>
                                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                                                            <?php $__currentLoopData = $topic->assignments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $assignment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                                <li>
                                                                                    <span>
                                                                                        <i class="fas fa-tasks"></i>
                                                                                        <?php echo e(__('frontend.assignment')); ?>:
                                                                                        <?php echo e($assignment->title); ?>

                                                                                        <?php if($assignment->files->count() > 0): ?>
                                                                                            <span
                                                                                                class="badge bg-secondary ms-2"><?php echo e($assignment->files->count()); ?>

                                                                                                <?php echo e(__('frontend.files')); ?></span>
                                                                                        <?php endif; ?>
                                                                                    </span>
                                                                                    <span>
                                                                                        <i class="far fa-lock"></i>
                                                                                    </span>
                                                                                </li>
                                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                        </ul>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                                        <?php if($course->topics->count() === 0): ?>
                                                            <div class="alert alert-info">
                                                                <p><?php echo e(__('frontend.no_curriculum')); ?></p>
                                                            </div>
                                                        <?php endif; ?>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div id="Instructors" class="tab-pane fade">
                                            <div class="instructors-items">
                                                <h3><?php echo e(__('frontend.instructors')); ?></h3>
                                                <?php if($course->instructor): ?>
                                                    <div class="instructors-box-items">
                                                        <div class="thumb">
                                                            <?php if($course->instructor->profile_photo): ?>
                                                                <img src="<?php echo e(asset('storage/' . $course->instructor->profile_photo)); ?>"
                                                                    alt="<?php echo e($course->instructor->name); ?>">
                                                            <?php else: ?>
                                                                <img src="<?php echo e(asset('assets/front/img/inner/courses-details/courses-01.png')); ?>"
                                                                    alt="<?php echo e($course->instructor->name); ?>">
                                                            <?php endif; ?>
                                                        </div>
                                                        <div class="content">
                                                            <h4><?php echo e($course->instructor->name); ?></h4>
                                                            <?php if($course->instructor->specialization): ?>
                                                                <span><?php echo e($course->instructor->specialization); ?></span>
                                                            <?php endif; ?>
                                                            <?php if($course->instructor->bio): ?>
                                                                <p><?php echo e($course->instructor->bio); ?></p>
                                                            <?php else: ?>
                                                                <p><?php echo e(__('frontend.instr_fallback_bio')); ?></p>
                                                            <?php endif; ?>
                                                            <div class="social-icon">
                                                                <a href="#"><i class="fab fa-facebook-f"></i></a>
                                                                <a href="#"><i class="fab fa-instagram"></i></a>
                                                                <a href="#"><i class="fab fa-dribbble"></i></a>
                                                                <a href="#"><i class="fab fa-behance"></i></a>
                                                                <a href="#"><i class="fab fa-linkedin-in"></i></a>
                                                            </div>
                                                        </div>
                                                    </div>
                                                <?php else: ?>
                                                    <div class="alert alert-info">
                                                        <p><?php echo e(__('frontend.instr_not_available')); ?></p>
                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <?php if($totalReviews > 0 || $canReview): ?>
                                            <div id="Reviews" class="tab-pane fade">
                                                <div class="courses-reviews-items">
                                                    <h3><?php echo e(__('frontend.course_reviews')); ?></h3>

                                                    <?php if($totalReviews > 0): ?>
                                                        <div class="courses-reviews-box-items">
                                                            <div class="courses-reviews-box">
                                                                <div class="reviews-box">
                                                                    <h2><span class="count"><?php echo e($averageRating); ?></span>
                                                                    </h2>
                                                                    <div class="star">
                                                                        <?php for($i = 1; $i <= 5; $i++): ?>
                                                                            <i
                                                                                class="fas fa-star<?php echo e($i <= round($averageRating) ? '' : ' color-2'); ?>"></i>
                                                                        <?php endfor; ?>
                                                                    </div>
                                                                    <p><?php echo e($totalReviews); ?>+ <?php echo e(__('frontend.all_reviews')); ?></p>
                                                                </div>
                                                                <div class="reviews-ratting-right">
                                                                    <?php for($rating = 5; $rating >= 1; $rating--): ?>
                                                                        <?php
                                                                            $count = $ratingDistribution[$rating] ?? 0;
                                                                            $percentage =
                                                                                $totalReviews > 0
                                                                                    ? ($count / $totalReviews) * 100
                                                                                    : 0;
                                                                        ?>
                                                                        <div class="reviews-ratting-item">
                                                                            <div class="star">
                                                                                <?php for($i = 1; $i <= 5; $i++): ?>
                                                                                    <i
                                                                                        class="fas fa-star<?php echo e($i <= $rating ? '' : ' color-2'); ?>"></i>
                                                                                <?php endfor; ?>
                                                                            </div>
                                                                            <div class="progress">
                                                                                <div class="progress-value"
                                                                                    style="width: <?php echo e($percentage); ?>%">
                                                                                </div>
                                                                            </div>
                                                                            <span>(<?php echo e($count); ?>)</span>
                                                                        </div>
                                                                    <?php endfor; ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    <?php else: ?>
                                                        <div class="alert alert-info">
                                                            <p><?php echo e(__('frontend.no_reviews_yet')); ?></p>
                                                        </div>
                                                    <?php endif; ?>

                                                    <!-- Review Form for Enrolled Students -->
                                                    <?php if($canReview && !$userReview): ?>
                                                        <div class="review-form-section"
                                                            style="margin-top: 30px; padding: 30px; background: #f8f9fa; border-radius: 10px;">
                                                            <h4 style="margin-bottom: 20px;"><?php echo e(__('frontend.write_review')); ?></h4>
                                                            <form
                                                                action="<?php echo e(route('courses.reviews.store', $course->id)); ?>"
                                                                method="POST" id="reviewForm">
                                                                <?php echo csrf_field(); ?>
                                                                <div class="mb-3">
                                                                    <label class="form-label"
                                                                        style="font-weight: 500;">Rating
                                                                        <span class="text-danger">*</span></label>
                                                                    <div class="rating-input"
                                                                        style="display: flex; gap: 5px; font-size: 30px; cursor: pointer;">
                                                                        <?php for($i = 1; $i <= 5; $i++): ?>
                                                                            <i class="fas fa-star rating-star"
                                                                                data-rating="<?php echo e($i); ?>"
                                                                                style="color: #ddd; transition: color 0.2s;"></i>
                                                                        <?php endfor; ?>
                                                                    </div>
                                                                    <input type="hidden" name="rating" id="ratingInput"
                                                                        value="" required>
                                                                    <small class="text-danger d-none"
                                                                        id="ratingError"><?php echo e(__('frontend.select_rating_error')); ?></small>
                                                                    <?php $__errorArgs = ['rating'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                        <div class="text-danger mt-2"><?php echo e($message); ?>

                                                                        </div>
                                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                                </div>
                                                                <div class="mb-3">
                                                                    <label for="comment" class="form-label"
                                                                        style="font-weight: 500;"><?php echo e(__('frontend.your_review')); ?></label>
                                                                    <textarea name="comment" id="comment" class="form-control" rows="5"
                                                                        placeholder="<?php echo e(__('frontend.share_experience')); ?>"></textarea>
                                                                    <?php $__errorArgs = ['comment'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                        <div class="text-danger mt-2"><?php echo e($message); ?>

                                                                        </div>
                                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                                </div>
                                                                <button type="submit" class="theme-btn py-2 px-4"
                                                                    id="submitReviewBtn">
                                                                    <i class="fa-solid fa-paper-plane me-2"></i>
                                                                    <?php echo e(__('frontend.submit_review')); ?>

                                                                </button>
                                                            </form>
                                                        </div>
                                                    <?php elseif($canReview && $userReview): ?>
                                                        <div class="review-form-section"
                                                            style="margin-top: 30px; padding: 30px; background: #f8f9fa; border-radius: 10px;">
                                                            <h4 style="margin-bottom: 20px;"><?php echo e(__('frontend.your_review')); ?></h4>
                                                            <form
                                                                action="<?php echo e(route('courses.reviews.update', [$course->id, $userReview->id])); ?>"
                                                                method="POST" id="reviewForm">
                                                                <?php echo csrf_field(); ?>
                                                                <?php echo method_field('PUT'); ?>
                                                                <div class="mb-3">
                                                                    <label class="form-label"
                                                                        style="font-weight: 500;">Rating
                                                                        <span class="text-danger">*</span></label>
                                                                    <div class="rating-input"
                                                                        style="display: flex; gap: 5px; font-size: 30px; cursor: pointer;">
                                                                        <?php for($i = 1; $i <= 5; $i++): ?>
                                                                            <i class="fas fa-star rating-star"
                                                                                data-rating="<?php echo e($i); ?>"
                                                                                style="color: <?php echo e($i <= $userReview->rating ? '#FFAE5D' : '#ddd'); ?>; transition: color 0.2s;"></i>
                                                                        <?php endfor; ?>
                                                                    </div>
                                                                    <input type="hidden" name="rating" id="ratingInput"
                                                                        value="<?php echo e($userReview->rating); ?>" required>
                                                                    <?php $__errorArgs = ['rating'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                        <div class="text-danger mt-2"><?php echo e($message); ?>

                                                                        </div>
                                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                                </div>
                                                                <div class="mb-3">
                                                                    <label for="comment" class="form-label"
                                                                        style="font-weight: 500;"><?php echo e(__('frontend.your_review')); ?></label>
                                                                    <textarea name="comment" id="comment" class="form-control" rows="5"
                                                                        placeholder="<?php echo e(__('frontend.share_experience')); ?>"><?php echo e($userReview->comment); ?></textarea>
                                                                    <?php $__errorArgs = ['comment'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                                        <div class="text-danger mt-2"><?php echo e($message); ?>

                                                                        </div>
                                                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                                                </div>
                                                                <button type="submit" class="theme-btn">
                                                                    <i class="fa-solid fa-save me-2"></i>
                                                                    <?php echo e(__('frontend.update_review')); ?>

                                                                </button>
                                                            </form>
                                                        </div>
                                                    <?php elseif(!auth()->check()): ?>
                                                        <div class="alert alert-info" style="margin-top: 30px;">
                                                            <p><a href="<?php echo e(route('login')); ?>"><?php echo e(__('frontend.login')); ?></a> <?php echo e(__('frontend.login_to_review')); ?></p>
                                                        </div>
                                                    <?php endif; ?>

                                                    <!-- Display Reviews -->
                                                    <?php if($totalReviews > 0): ?>
                                                        <div class="reviews-list" style="margin-top: 40px;">
                                                            <h4 style="margin-bottom: 20px;"><?php echo e(__('frontend.all_reviews')); ?>

                                                                (<?php echo e($totalReviews); ?>)
                                                            </h4>
                                                            <?php $__currentLoopData = $reviews; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $review): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <div class="instructors-box-items"
                                                                    style="margin-bottom: 30px; padding: 20px; border: 1px solid #eee; border-radius: 10px;">
                                                                    <div class="thumb">
                                                                        <?php if($review->user->profile_photo): ?>
                                                                            <img src="<?php echo e(asset('storage/' . $review->user->profile_photo)); ?>"
                                                                                alt="<?php echo e($review->user->name); ?>">
                                                                        <?php else: ?>
                                                                            <img src="<?php echo e(asset('assets/front/img/home-1/courses/client-01.png')); ?>"
                                                                                alt="<?php echo e($review->user->name); ?>">
                                                                        <?php endif; ?>
                                                                    </div>
                                                                    <div class="content">
                                                                        <h4><?php echo e($review->user->name); ?></h4>
                                                                        <span><?php echo e($review->created_at->format('M d, Y')); ?></span>
                                                                        <div class="star" style="margin-top: 10px;">
                                                                            <?php for($i = 1; $i <= 5; $i++): ?>
                                                                                <i class="fas fa-star"
                                                                                    style="color: <?php echo e($i <= $review->rating ? '#FFAE5D' : '#ddd'); ?>;"></i>
                                                                            <?php endfor; ?>
                                                                        </div>
                                                                        <?php if($review->comment): ?>
                                                                            <p style="margin-top: 15px;">
                                                                                <?php echo e($review->comment); ?></p>
                                                                        <?php endif; ?>

                                                                        <!-- Instructor Replies -->
                                                                        <?php if($review->replies->where('is_instructor', true)->count() > 0): ?>
                                                                            <div
                                                                                style="margin-top: 20px; padding-top: 20px; border-top: 1px solid #eee;">
                                                                                <?php $__currentLoopData = $review->replies->where('is_instructor', true); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $reply): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                                    <div
                                                                                        style="background: #f8f9fa; padding: 15px; border-radius: 8px; margin-top: 10px;">
                                                                                        <div
                                                                                            style="display: flex; align-items: center; gap: 10px; margin-bottom: 8px;">
                                                                                            <i class="fa-solid fa-chalkboard-user"
                                                                                                style="color: #28a745;"></i>
                                                                                            <strong
                                                                                                style="color: #28a745;"><?php echo e(__('frontend.instr_response')); ?></strong>
                                                                                            <span
                                                                                                style="color: #666; font-size: 0.9em;"><?php echo e($reply->created_at->format('M d, Y')); ?></span>
                                                                                        </div>
                                                                                        <p style="margin: 0; color: #333;">
                                                                                            <?php echo e($reply->reply); ?></p>
                                                                                    </div>
                                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                            </div>
                                                                        <?php endif; ?>
                                                                    </div>
                                                                </div>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </div>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-lg-4">
                            <div class="details-list-area">
                                <ul class="details-list">
                                    <?php if($totalDuration > 0): ?>
                                        <li>
                                            <span>
                                                <i class="far fa-clock me-2"></i>
                                                <?php echo e(__('frontend.total_duration')); ?>

                                            </span>
                                            <?php
                                                $hours = floor($totalDuration / 60);
                                                $minutes = $totalDuration % 60;
                                            ?>
                                            <?php if($hours > 0): ?>
                                                <?php echo e($hours); ?>h <?php echo e($minutes); ?>m
                                            <?php else: ?>
                                                <?php echo e($minutes); ?>m
                                            <?php endif; ?>
                                        </li>
                                    <?php endif; ?>
                                    <li>
                                        <span>
                                            <i class="fas fa-users-class me-2"></i>
                                            <?php echo e(__('frontend.students')); ?>

                                        </span>
                                        <?php if($course->max_students): ?>
                                            <?php echo e(__('frontend.max')); ?> <?php echo e($course->max_students); ?>

                                        <?php else: ?>
                                            <?php echo e(__('frontend.unlimited')); ?>

                                        <?php endif; ?>
                                    </li>
                                    <li>
                                        <span>
                                            <i class="fal fa-book-spells me-2"></i>
                                            <?php echo e(__('frontend.lessons')); ?>

                                        </span>
                                        <?php echo e($lessonCount); ?>

                                    </li>
                                    <?php if($course->difficulty): ?>
                                        <li>
                                            <span>
                                                <i class="far fa-layer-group me-2"></i>
                                                <?php echo e(__('frontend.skill_level')); ?>

                                            </span>
                                            <?php echo e(ucfirst($course->difficulty)); ?>

                                        </li>
                                    <?php endif; ?>
                                    <?php if($course->language): ?>
                                        <li>
                                            <span>
                                                <i class="fas fa-globe me-2"></i>
                                                <?php echo e(__('frontend.language')); ?>

                                            </span>
                                            <?php echo e(ucfirst($course->language)); ?>

                                        </li>
                                    <?php endif; ?>
                                    <?php if($course->certifications || $course->certifications == ''): ?>
                                        <li>
                                            <span>
                                                <i class="fas fa-certificate me-2"></i>
                                                <?php echo e(__('frontend.certifications')); ?>

                                            </span>
                                            <?php echo e(__('frontend.yes')); ?>

                                        </li>
                                    <?php endif; ?>
                                    <?php if($course->schedule_date): ?>
                                        <li>
                                            <span>
                                                <i class="fas fa-chart-line-down me-2"></i>
                                                <?php echo e(__('frontend.start_date')); ?>

                                            </span>
                                            <?php echo e($course->schedule_date->format('d M, Y')); ?>

                                        </li>
                                    <?php endif; ?>
                                    <?php if($course->instructor): ?>
                                        <li>
                                            <span>
                                                <i class="far fa-user me-2"></i>
                                                <?php echo e(__('frontend.instructor')); ?>

                                            </span>
                                            <?php echo e($course->instructor->name); ?>

                                        </li>
                                    <?php endif; ?>
                                </ul>
                                <?php
                                    $rawPrice = $course->sale_price ?? $course->regular_price;
                                    $price =
                                        $course->pricing_model === 'free' ? __('frontend.free') : currency_format($rawPrice ?? 0);
                                ?>
                                <div class="theme-btn w-100 bg-color-4 mb-3 text-center" style="padding: 15px;">
                                    <?php echo e(__('frontend.price')); ?>: <?php echo e($price); ?>

                                </div>
                                <?php if($isEnrolled): ?>
                                    <a href=<?php echo e(route('courses.show', $course->id)); ?>}}" class="theme-btn w-100 style-2"
                                        style="background: #28a745;">
                                        <i class="fas fa-check-circle me-2"></i> <?php echo e(__('frontend.already_enrolled')); ?>

                                    </a>
                                <?php elseif(auth()->check()): ?>
                                    <?php if($course->pricing_model === 'free'): ?>
                                        <a href="<?php echo e(route('courses.checkout', $course->id)); ?>"
                                            class="theme-btn w-100 style-2">
                                            <?php echo e(__('frontend.enroll_now')); ?>

                                        </a>
                                    <?php else: ?>
                                        <a href="<?php echo e(route('courses.checkout', $course->id)); ?>"
                                            class="theme-btn w-100 style-2">
                                            <?php echo e(__('frontend.buy_now')); ?>

                                        </a>
                                    <?php endif; ?>
                                <?php else: ?>
                                    <a href="<?php echo e(route('login')); ?>" class="theme-btn w-100 style-2">
                                        <?php echo e(__('frontend.login_enroll')); ?>

                                    </a>
                                <?php endif; ?>
                                <div class="social-icon d-flex align-items-center">
                                    <span><?php echo e(__('frontend.share')); ?>: </span>
                                    <a href="#"><i class="fab fa-facebook-f"></i></a>
                                    <a href="#"><i class="fab fa-twitter"></i></a>
                                    <a href="#"><i class="fab fa-vimeo-v"></i></a>
                                    <a href="#"><i class="fab fa-pinterest-p"></i></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- Video Modal -->
    <div id="lessonVideoModal" class="modal fade" tabindex="-1" aria-labelledby="lessonVideoModalTitle"
        aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="lessonVideoModalTitle"><?php echo e(__('frontend.lesson_preview')); ?></h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div id="lessonVideoContainer">
                        <video id="lessonVideoPlayer" controls style="width: 100%; max-height: 500px;" class="d-none">
                            Your browser does not support the video tag.
                        </video>
                        <div id="lessonVideoIframe" class="d-none"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Intro Video Modal -->
    <div id="introVideoModal" class="modal fade" tabindex="-1" aria-labelledby="introVideoModalTitle"
        aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="introVideoModalTitle"><?php echo e(__('frontend.course_intro')); ?></h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div id="introVideoContainer">
                        <video id="introVideoPlayer" controls style="width: 100%; max-height: 500px;">
                            Your browser does not support the video tag.
                        </video>
                    </div>
                </div>
            </div>
        </div>
    </div>



    <?php $__env->startPush('scripts'); ?>
        <script>
            $(document).ready(function() {
                const videoModal = new bootstrap.Modal(document.getElementById('lessonVideoModal'));
                const videoPlayer = document.getElementById('lessonVideoPlayer');
                const videoIframe = document.getElementById('lessonVideoIframe');
                const modalTitle = document.getElementById('lessonVideoModalTitle');

                $('.lesson-preview-play').on('click', function(e) {
                    e.preventDefault();
                    const videoType = $(this).data('video-type');
                    const videoUrl = $(this).data('video-url');
                    const lessonTitle = $(this).data('lesson-title');

                    modalTitle.textContent = lessonTitle || 'Lesson Preview';

                    if (videoType === 'url') {
                        let embedUrl = videoUrl;
                        if (videoUrl.includes('youtube.com/watch')) {
                            embedUrl = videoUrl.replace('watch?v=', 'embed/').split('&')[0];
                        } else if (videoUrl.includes('youtu.be/')) {
                            embedUrl = videoUrl.replace('youtu.be/', 'youtube.com/embed/');
                        } else if (videoUrl.includes('vimeo.com/')) {
                            const vimeoId = videoUrl.split('vimeo.com/')[1].split('?')[0];
                            embedUrl = 'https://player.vimeo.com/video/' + vimeoId;
                        }

                        videoPlayer.classList.add('d-none');
                        videoIframe.classList.remove('d-none');
                        videoIframe.innerHTML = '<iframe src="' + embedUrl +
                            '" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen style="width: 100%; height: 500px;"></iframe>';
                    } else {
                        videoIframe.classList.add('d-none');
                        videoPlayer.classList.remove('d-none');
                        videoPlayer.src = videoUrl;
                    }

                    videoModal.show();
                });

                $('#lessonVideoModal').on('hidden.bs.modal', function() {
                    videoPlayer.pause();
                    videoPlayer.src = '';
                    videoIframe.innerHTML = '';
                });

                const introVideoModal = new bootstrap.Modal(document.getElementById('introVideoModal'));
                const introVideoPlayer = document.getElementById('introVideoPlayer');

                $('.intro-video-play-btn').on('click', function(e) {
                    e.preventDefault();
                    const introVideoUrl = $(this).data('intro-video');
                    introVideoPlayer.src = introVideoUrl;
                    introVideoModal.show();
                });

                $('#introVideoModal').on('hidden.bs.modal', function() {
                    introVideoPlayer.pause();
                    introVideoPlayer.src = '';
                });

                // Star rating functionality
                $('.rating-star').on('click', function() {
                    const rating = $(this).data('rating');
                    const container = $(this).closest('.rating-input');
                    const input = container.siblings('#ratingInput');

                    input.val(rating);

                    container.find('.rating-star').each(function() {
                        const starRating = $(this).data('rating');
                        if (starRating <= rating) {
                            $(this).css('color', '#FFAE5D');
                        } else {
                            $(this).css('color', '#ddd');
                        }
                    });
                });

                $('.rating-star').on('mouseenter', function() {
                    const rating = $(this).data('rating');
                    const container = $(this).closest('.rating-input');

                    container.find('.rating-star').each(function() {
                        const starRating = $(this).data('rating');
                        if (starRating <= rating) {
                            $(this).css('color', '#FFAE5D');
                        } else {
                            $(this).css('color', '#ddd');
                        }
                    });
                });

                $('.rating-input').on('mouseleave', function() {
                    const input = $(this).siblings('#ratingInput');
                    const currentRating = parseInt(input.val()) || 0;

                    $(this).find('.rating-star').each(function() {
                        const starRating = $(this).data('rating');
                        if (starRating <= currentRating) {
                            $(this).css('color', '#FFAE5D');
                        } else {
                            $(this).css('color', '#ddd');
                        }
                    });
                });

                // Validate rating before form submission
                $('#reviewForm').on('submit', function(e) {
                    const rating = $('#ratingInput').val();
                    if (!rating || rating === '' || rating === '0') {
                        e.preventDefault();
                        $('#ratingError').removeClass('d-none');
                        ToastMagic?.error('<?php echo e(__('frontend.select_rating_error')); ?>');
                        return false;
                    }
                    $('#ratingError').addClass('d-none');
                });

                // Countdown timer
                const countdownTimer = $('.countdown-timer');
                if (countdownTimer.length > 0) {
                    const targetDate = new Date(countdownTimer.data('date')).getTime();

                    const updateCountdown = function() {
                        const now = new Date().getTime();
                        const distance = targetDate - now;

                        if (distance < 0) {
                            countdownTimer.closest('li').html(
                                '<i class="fas fa-calendar-alt"></i> Course has started');
                            return;
                        }

                        const days = Math.floor(distance / (1000 * 60 * 60 * 24));
                        const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                        const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
                        const seconds = Math.floor((distance % (1000 * 60)) / 1000);

                        countdownTimer.find('.countdown-days').text(days);
                        countdownTimer.find('.countdown-hours').text(hours);
                        countdownTimer.find('.countdown-minutes').text(minutes);
                        countdownTimer.find('.countdown-seconds').text(seconds);
                    };

                    updateCountdown();
                    setInterval(updateCountdown, 1000);
                }
            });
        </script>
    <?php $__env->stopPush(); ?>

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

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