<?php
    use Illuminate\Support\Str;
?>

<?php $__env->startSection('title', $tenant->name.' — catalog'); ?>

<?php $__env->startSection('content'); ?>
    <h1 class="text-2xl font-semibold tracking-tight"><?php echo e($tenant->name); ?></h1>

    <?php if(! empty($catalogIntroMarkdown)): ?>
        <div class="prose prose-stone prose-sm mt-4 max-w-none">
            <?php echo Str::markdown($catalogIntroMarkdown); ?>

        </div>
    <?php endif; ?>

    <p class="mt-4 max-w-2xl text-xs leading-relaxed text-stone-500">
        <?php if(auth()->guard()->check()): ?>
            <a href="<?php echo e(route('learn.catalog', $tenant)); ?>" class="font-medium text-teal-800 underline decoration-teal-800/30 hover:decoration-teal-800">Open learner catalog</a>
            <span class="text-stone-400"> — </span>
            same programs with your progress and enrollments.
        <?php else: ?>
            You can browse this page without an account.
            <a href="<?php echo e(route('space.login', $tenant)); ?>" class="font-medium text-teal-800 underline decoration-teal-800/30 hover:decoration-teal-800">Log in</a>
            or
            <a href="<?php echo e(route('space.register', $tenant)); ?>" class="font-medium text-teal-800 underline decoration-teal-800/30 hover:decoration-teal-800">register</a>
            for this space to open courses and use <strong class="font-medium text-stone-600">Enroll free</strong> where a coach has enabled it.
        <?php endif; ?>
    </p>

    <?php if($reflectionsEnabled && $latestReflection): ?>
        <div class="mt-8 rounded-2xl border border-amber-200 bg-amber-50/80 px-4 py-4">
            <p class="text-xs font-medium uppercase tracking-wide text-amber-900">Today&rsquo;s reflection</p>
            <?php if($latestReflection->title): ?>
                <p class="mt-1 font-semibold text-stone-900"><?php echo e($latestReflection->title); ?></p>
            <?php endif; ?>
            <p class="mt-2 text-sm text-stone-700"><?php echo e(Str::limit(strip_tags($latestReflection->body), 240)); ?></p>
            <?php if(auth()->guard()->check()): ?>
                <a href="<?php echo e(route('learn.reflections.show', [$tenant, $latestReflection])); ?>"
                    class="mt-3 inline-flex rounded-full bg-amber-700 px-4 py-2 text-sm font-medium text-white hover:bg-amber-800">Open reflection</a>
            <?php else: ?>
                <p class="mt-2 text-xs text-stone-600">Log in to respond to the coach&rsquo;s prompt.</p>
            <?php endif; ?>
        </div>
    <?php endif; ?>

    <p class="mt-8 text-sm font-medium text-stone-800">Programs &amp; courses</p>
    <p class="mt-1 text-xs text-stone-500">Featured items appear first. Course order uses popularity when your space tracks catalog views.</p>

    <?php $__currentLoopData = $programs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $program): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <section class="mt-8">
            <h2 class="text-lg font-semibold text-stone-900">
                <?php echo e($program->title); ?>

                <?php if($program->is_featured): ?>
                    <span class="ml-2 rounded-full bg-teal-100 px-2 py-0.5 text-xs font-medium text-teal-800">Featured</span>
                <?php endif; ?>
            </h2>
            <?php if($program->summary): ?>
                <p class="mt-1 text-sm text-stone-600"><?php echo e($program->summary); ?></p>
            <?php endif; ?>
            <ul class="mt-4 space-y-2">
                <?php $__currentLoopData = $program->courses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $course): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li class="rounded-xl border border-stone-200 bg-white px-4 py-3 shadow-sm">
                        <div class="flex flex-wrap items-start justify-between gap-3">
                            <div>
                                <span class="font-medium text-stone-900"><?php echo e($course->title); ?></span>
                                <?php if($course->is_featured): ?>
                                    <span class="ml-2 text-xs font-medium text-teal-700">Featured</span>
                                <?php endif; ?>
                                <?php if($trackCatalogViews && $course->catalog_view_count > 0): ?>
                                    <span class="ml-2 text-xs text-stone-400"><?php echo e($course->catalog_view_count); ?> opens</span>
                                <?php endif; ?>
                                <?php if($course->summary): ?>
                                    <p class="mt-0.5 text-sm text-stone-600"><?php echo e($course->summary); ?></p>
                                <?php endif; ?>
                            </div>
                            <?php if(auth()->guard()->check()): ?>
                                <form method="POST" action="<?php echo e(route('public.catalog.track', $tenant)); ?>" class="shrink-0">
                                    <?php echo csrf_field(); ?>
                                    <input type="hidden" name="course_id" value="<?php echo e($course->id); ?>">
                                    <input type="hidden" name="redirect_to" value="<?php echo e(\Illuminate\Support\Facades\URL::route('learn.course', [$tenant, $course], false)); ?>">
                                    <button type="submit" class="text-sm font-medium text-teal-700 hover:underline">Open course</button>
                                </form>
                            <?php else: ?>
                                <a href="<?php echo e(route('space.login', $tenant)); ?>" class="shrink-0 text-sm font-medium text-teal-700 hover:underline">Log in to enroll</a>
                            <?php endif; ?>
                        </div>
                    </li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        </section>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

    <?php if($standaloneCourses->isNotEmpty()): ?>
        <section class="mt-8">
            <h2 class="text-lg font-semibold text-stone-900">Single courses</h2>
            <p class="mt-1 text-sm text-stone-600">Not grouped in a program.</p>
            <ul class="mt-4 space-y-2">
                <?php $__currentLoopData = $standaloneCourses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $course): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li class="rounded-xl border border-stone-200 bg-white px-4 py-3 shadow-sm">
                        <div class="flex flex-wrap items-start justify-between gap-3">
                            <div>
                                <span class="font-medium text-stone-900"><?php echo e($course->title); ?></span>
                                <?php if($course->is_featured): ?>
                                    <span class="ml-2 text-xs font-medium text-teal-700">Featured</span>
                                <?php endif; ?>
                                <?php if($trackCatalogViews && $course->catalog_view_count > 0): ?>
                                    <span class="ml-2 text-xs text-stone-400"><?php echo e($course->catalog_view_count); ?> opens</span>
                                <?php endif; ?>
                                <?php if($course->summary): ?>
                                    <p class="mt-0.5 text-sm text-stone-600"><?php echo e($course->summary); ?></p>
                                <?php endif; ?>
                            </div>
                            <?php if(auth()->guard()->check()): ?>
                                <form method="POST" action="<?php echo e(route('public.catalog.track', $tenant)); ?>" class="shrink-0">
                                    <?php echo csrf_field(); ?>
                                    <input type="hidden" name="course_id" value="<?php echo e($course->id); ?>">
                                    <input type="hidden" name="redirect_to" value="<?php echo e(\Illuminate\Support\Facades\URL::route('learn.course', [$tenant, $course], false)); ?>">
                                    <button type="submit" class="text-sm font-medium text-teal-700 hover:underline">Open course</button>
                                </form>
                            <?php else: ?>
                                <a href="<?php echo e(route('space.login', $tenant)); ?>" class="shrink-0 text-sm font-medium text-teal-700 hover:underline">Log in to enroll</a>
                            <?php endif; ?>
                        </div>
                    </li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        </section>
    <?php endif; ?>

    <?php if($programs->isEmpty() && $standaloneCourses->isEmpty()): ?>
        <p class="mt-8 text-stone-600">Nothing published yet.</p>
    <?php endif; ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/nurudinwahablartey/Projects/lms/resources/views/public/catalog.blade.php ENDPATH**/ ?>