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

<?php $__env->startSection('content'); ?>
<?php
    $media = app(\App\Services\MediaStorageService::class);
    $backdropUrl = $media->url($movie->backdrop_path);
    $posterUrl = $media->url($movie->poster_path) ?: 'https://placehold.co/600x900?text=No+Poster';
    $trailerUrl = $movie->trailer_url ?: ($movie->trailer_key ? 'https://www.youtube.com/watch?v='.$movie->trailer_key : null);
    $playerAd = ($ads['player_sponsor'] ?? collect())->first();
    $sponsorTarget = optional($playerAd)->target_url;
?>

<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($movie->title); ?> poster">
                <?php if($movie->vote_average): ?>
                    <div class="poster-rating"><span>★</span> <?php echo e(number_format((float) $movie->vote_average, 1)); ?></div>
                <?php endif; ?>
            </div>

            <div class="movie-detail-copy">
                <div class="detail-eyebrow">
                    <span><?php echo e($movie->is_featured ? 'Featured release' : 'Now showing'); ?></span>
                    <?php if($movie->content_rating): ?><span><?php echo e($movie->content_rating); ?></span><?php endif; ?>
                </div>

                <h1><?php echo e($movie->title); ?></h1>

                <div class="movie-meta">
                    <?php if($movie->release_date): ?><span><?php echo e($movie->release_date->format('Y')); ?></span><?php endif; ?>
                    <?php if($movie->runtime): ?><span><?php echo e($movie->runtime); ?> min</span><?php endif; ?>
                    <?php if($movie->language): ?><span><?php echo e(strtoupper($movie->language)); ?></span><?php endif; ?>
                    <?php if($movie->quality_badge): ?><span><?php echo e($movie->quality_badge); ?></span><?php endif; ?>
                </div>

                <?php if($movie->genres->isNotEmpty()): ?>
                    <div class="chips movie-chips">
                        <?php $__currentLoopData = $movie->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($movie->overview ?: 'No overview is available for this movie yet.'); ?></p>

                <div class="movie-actions">
                    <?php if($trailerUrl): ?>
                        <a class="watch-trailer-btn" href="<?php echo e($trailerUrl); ?>" target="_blank" rel="noopener">
                            <span class="play-icon">▶</span> Watch trailer
                        </a>
                    <?php endif; ?>
                    <a class="browse-btn" href="<?php echo e(route('movies')); ?>">Browse movies</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(); ?>

            <?php echo $__env->make('front.partials.embed-player', [
                'title' => $movie->title,
                'embedUrl' => $embedUrl ?? null,
            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

            <?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' => 'movie',
                'statsId' => $movie->id,
                'statsDate' => optional($movie->release_date)->format('M d Y'),
                'statsRuntime' => $movie->runtime ? intdiv((int) $movie->runtime, 60).'h '.((int) $movie->runtime % 60).'m' : null,
                'statsRating' => $movie->vote_average,
            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

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

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

            <?php if($sponsorTarget): ?>
                <section class="download-library" aria-label="Download quality options">
                    <div class="download-library-heading">
                        <div>
                            <small>Available download links</small>
                            <h2>Download <?php echo e($movie->title); ?></h2>
                        </div>
                        <span>Multiple qualities</span>
                    </div>

                    <div class="download-file-grid">
                        <?php $__currentLoopData = [
                            ['label' => '480p', 'format' => 'WEB-DL', 'codec' => 'H.264', 'audio' => 'AAC 2.0', 'size' => 'SD'],
                            ['label' => '720p', 'format' => 'WEB-DL', 'codec' => 'H.264', 'audio' => 'AAC 2.0', 'size' => 'HD'],
                            ['label' => '1080p', 'format' => 'WEB-DL', 'codec' => 'H.264', 'audio' => 'AAC 5.1', 'size' => 'Full HD'],
                            ['label' => '2K', 'format' => 'WEB-DL', 'codec' => 'H.265', 'audio' => 'AAC 5.1', 'size' => 'Quad HD'],
                            ['label' => '4K', 'format' => 'WEB-DL', 'codec' => 'H.265', 'audio' => 'AAC 5.1', 'size' => 'Ultra HD'],
                        ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $quality): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <article class="download-file-card">
                                <div class="download-file-topline">
                                    <h3><?php echo e($movie->title); ?> <?php echo e(optional($movie->release_date)->format('Y') ? '('.optional($movie->release_date)->format('Y').')' : ''); ?></h3>
                                    <?php if($loop->last): ?><span class="download-new-badge">NEW</span><?php endif; ?>
                                </div>
                                <div class="download-file-quality">
                                    <strong><?php echo e($quality['label']); ?></strong>
                                    <span>•</span>
                                    <b><?php echo e($quality['size']); ?></b>
                                    <?php if($movie->language): ?><em><?php echo e(strtoupper($movie->language)); ?></em><?php endif; ?>
                                </div>
                                <p>
                                    <span><?php echo e($quality['format']); ?></span> •
                                    <i><?php echo e($quality['audio']); ?></i> •
                                    <b><?php echo e($quality['codec']); ?></b> •
                                    <u>SoftSub</u>
                                </p>
                                <div class="download-file-actions">
                                    <a class="file-download-btn" href="<?php echo e($sponsorTarget); ?>" target="_blank" rel="sponsored nofollow noopener">Download</a>
                                    <a class="file-watch-btn" href="<?php echo e($sponsorTarget); ?>" target="_blank" rel="sponsored nofollow noopener">Watch Online</a>
                                </div>
                            </article>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </section>
            <?php endif; ?>

            <?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>Movie details</h2></div>
                <dl class="compact-facts">
                    <div><dt>Release</dt><dd><?php echo e(optional($movie->release_date)->format('M d, Y') ?: 'Coming soon'); ?></dd></div>
                    <div><dt>Runtime</dt><dd><?php echo e($movie->runtime ? $movie->runtime.' min' : 'N/A'); ?></dd></div>
                    <div><dt>Rating</dt><dd>★ <?php echo e($movie->vote_average ?: 'N/A'); ?></dd></div>
                    <?php if($movie->quality_badge): ?><div><dt>Quality</dt><dd><?php echo e($movie->quality_badge); ?></dd></div><?php endif; ?>
                </dl>
            </section>
        </aside>
    </div>

    <?php if(($relatedMovies ?? collect())->isNotEmpty()): ?>
        <section class="container suggestion-section">
            <div class="suggestion-heading">
                <div><small>You may also like</small><h2>More movies</h2></div>
                <div class="slider-controls">
                    <button type="button" data-slider-prev aria-label="Previous movies">‹</button>
                    <button type="button" data-slider-next aria-label="Next movies">›</button>
                </div>
            </div>
            <div class="suggestion-slider" data-movie-slider>
                <?php $__currentLoopData = $relatedMovies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $related): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <a class="suggestion-card" href="<?php echo e(route('movie', $related)); ?>">
                        <div class="suggestion-poster">
                            <img src="<?php echo e($media->url($related->poster_path) ?: 'https://placehold.co/400x600?text=No+Poster'); ?>" alt="<?php echo e($related->title); ?>">
                            <span class="suggestion-play">▶</span>
                            <?php if($related->vote_average): ?><b>★ <?php echo e(number_format((float)$related->vote_average, 1)); ?></b><?php endif; ?>
                        </div>
                        <strong><?php echo e($related->title); ?></strong>
                        <small><?php echo e(optional($related->release_date)->format('Y') ?: 'Coming soon'); ?><?php if($related->runtime): ?> · <?php echo e($related->runtime); ?> min <?php endif; ?></small>
                    </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </section>
    <?php endif; ?>
<?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/movie.blade.php ENDPATH**/ ?>