<?php $__env->startSection('title', $show->seo_title ?: $show->title); ?>
<?php $__env->startSection('description', $show->meta_description ?: \Illuminate\Support\Str::limit(strip_tags($show->overview), 155)); ?>

<?php $__env->startSection('content'); ?>
<?php
    $media = app(\App\Services\MediaStorageService::class);
    $backdropUrl = $media->url($show->backdrop_path);
    $posterUrl = $media->url($show->poster_path) ?: 'https://placehold.co/600x900?text=No+Poster';
    $playerAd = ($ads['player_sponsor'] ?? collect())->first();
?>

<div class="movie-detail-page">
    <section class="movie-detail-hero" style="--movie-backdrop: url('<?php echo e($backdropUrl); ?>')">
        <div class="movie-detail-backdrop"></div>
        <div class="movie-detail-overlay"></div>
        <div class="container movie-detail-content">
            <div class="movie-poster-wrap">
                <img class="movie-detail-poster" src="<?php echo e($posterUrl); ?>" alt="<?php echo e($show->title); ?> poster">
                <?php if($show->vote_average): ?>
                    <div class="poster-rating"><span>★</span> <?php echo e(number_format((float) $show->vote_average, 1)); ?></div>
                <?php endif; ?>
            </div>
            <div class="movie-detail-copy">
                <div class="detail-eyebrow"><span>Web series</span></div>
                <h1><?php echo e($show->title); ?></h1>
                <div class="movie-meta">
                    <?php if($show->first_air_date): ?><span><?php echo e($show->first_air_date->format('Y')); ?></span><?php endif; ?>
                    <span><?php echo e($show->seasons->where('is_active', 1)->count()); ?> seasons</span>
                </div>
                <?php if($show->genres->isNotEmpty()): ?>
                    <div class="chips movie-chips">
                        <?php $__currentLoopData = $show->genres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $genre): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><a href="<?php echo e(route('genre', $genre)); ?>"><?php echo e($genre->name); ?></a><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                <?php endif; ?>
                <p class="movie-overview"><?php echo e($show->overview ?: 'No overview is available for this series yet.'); ?></p>
                <div class="movie-actions"><a class="browse-btn" href="<?php echo e(route('shows')); ?>">Browse web series</a></div>
            </div>
        </div>
    </section>

    <div class="container detail-body-grid player-layout">
        <div class="detail-main-column">
            <?php echo $__env->make('front.partials.ad', ['slot' => 'details_top'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
            <div id="video-player"></div>
            <?php echo $__env->make('front.partials.embed-player', [
                'title' => $selectedEpisode
                    ? $show->title.' — S'.$selectedEpisode->season->season_number.' E'.$selectedEpisode->episode_number
                    : $show->title,
                'embedUrl' => $embedUrl ?? null,
            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

            <?php $showRuntime = optional($selectedEpisode)->runtime; ?>
            <?php echo $__env->make('front.partials.server-switcher', [
                'embedProviders' => $embedProviders ?? [],
                'selectedServer' => $selectedServer ?? null,
            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

            <?php echo $__env->make('front.partials.player-stats', [
                'statsType' => 'show',
                'statsId' => $show->id,
                'statsDate' => optional($show->first_air_date)->format('M d Y'),
                'statsRuntime' => $showRuntime ? intdiv((int) $showRuntime, 60).'h '.((int) $showRuntime % 60).'m' : null,
                'statsRating' => $show->vote_average,
            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

            <?php echo $__env->make('front.partials.reactions', [
                'reactionType' => 'show',
                'reactionId' => $show->id,
            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

            <?php echo $__env->make('front.partials.top-cast', ['castItems' => $show->top_cast ?? []], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

            <section class="seasons-section">
                <div class="section-head"><h2>Seasons & Episodes</h2></div>
                <?php $__empty_1 = true; $__currentLoopData = $show->seasons->where('is_active', 1); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $season): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <details class="season">
                        <summary><?php echo e($season->title); ?> <small><?php echo e($season->episodes->where('is_active', 1)->count()); ?> episodes</small></summary>
                        <div class="episodes">
                            <?php $__currentLoopData = $season->episodes->where('is_active', 1); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $episode): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php
                                    $episodeUrl = route('show', $show) . '?' . http_build_query([
                                        'season' => $season->season_number,
                                        'episode' => $episode->episode_number,
                                        'server' => $selectedServer,
                                    ]);
                                    $isSelected = optional($selectedEpisode)->id === $episode->id;
                                ?>
                                <a class="episode-play-card <?php echo e($isSelected ? 'is-active' : ''); ?>" href="<?php echo e($episodeUrl); ?>#video-player">
                                    <div>
                                        <h3>E<?php echo e($episode->episode_number); ?> · <?php echo e($episode->title); ?></h3>
                                        <p><?php echo e($episode->overview ?: 'Watch this episode.'); ?></p>
                                    </div>
                                    <span><?php echo e($isSelected ? 'Playing' : 'Play'); ?> ▶</span>
                                </a>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                    </details>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <div class="premium-panel"><p>Season information will be added soon.</p></div>
                <?php endif; ?>
            </section>
            <?php echo $__env->make('front.partials.ad', ['slot' => 'details_bottom'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
        </div>

        <aside class="detail-sidebar related-sidebar">
            <section class="related-panel premium-panel">
                <div class="sidebar-title"><span></span><h2>More web series</h2></div>
                <?php if(($relatedShows ?? collect())->isNotEmpty()): ?>
                    <div class="related-list related-list-large">
                        <?php $__currentLoopData = $relatedShows; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $related): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <a href="<?php echo e(route('show', $related)); ?>">
                                <img src="<?php echo e($media->url($related->poster_path) ?: 'https://placehold.co/160x240?text=No+Poster'); ?>" alt="<?php echo e($related->title); ?>">
                                <div>
                                    <strong><?php echo e($related->title); ?></strong>
                                    <small><?php echo e(optional($related->first_air_date)->format('Y') ?: 'Coming soon'); ?> <b>★ <?php echo e($related->vote_average ?: 'N/A'); ?></b></small>
                                    <?php if($related->genres->isNotEmpty()): ?><span><?php echo e($related->genres->take(2)->pluck('name')->join(' · ')); ?></span><?php endif; ?>
                                </div>
                            </a>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                <?php else: ?>
                    <p class="sidebar-empty">More web series will appear here.</p>
                <?php endif; ?>
                <a class="sidebar-browse-all" href="<?php echo e(route('shows')); ?>">Browse all web series <span>→</span></a>
            </section>
        </aside>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('front.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/megashopltd/moviedocks.com/resources/views/front/show.blade.php ENDPATH**/ ?>