@extends(get_theme().'.layouts')

@section('content')
    <div class="text-center">
        <img class="img-fluid mb-4" src="{{ img_backdrop($backdrop) }}" alt="{{ $movie->title }} {{ to_year($movie->release_date) }}">
        <div class="row mb-3">
            <div class="col d-flex justify-content-center">
                <a href="{{ mopie_route('loading', ['id' => $movie->id ,'title' => $movie->original_title, 'action' => 'play']) }}" class="btn btn-success mx-1">{{ __('utilities.watch_now') }}</a>
                <a href="{{ mopie_route('loading', ['id' => $movie->id ,'title' => $movie->original_title, 'action' => 'register']) }}" class="btn btn-danger mx-1">{{ __('utilities.download') }}</a>
            </div>
        </div>
    </div>

    {{-- Details --}}
    <div class="card mb-3">
        <div class="card-body">
            <div class="row">
                <div class="col-md-2 col-sm-4 col-3">
                    <img class="img-fluid" src="{{ img_poster($movie->poster_path) }}" alt="Poster {{ $movie->title }} {{ to_year($movie->release_date) }}" title="Poster {{ $movie->title }} {{ to_year($movie->release_date) }}">
                </div>
                <div class="col-md-10 col-sm-8 col-9">
                    <div class="entry-title d-flex flex-column-reverse flex-md-row justify-content-between">
                        <h1 class="h2">{{ $movie->title }} <span class="tiny text-muted">{{ to_year($movie->release_date) }}</span></h1>
                    </div>
                    <div class="entry-info mb-3">
                        <div class="__rate">
                            @for ($i = 0; $i < 10; $i++)
                                @if ($i < round($movie->vote_average))
                                    <i class="fa fa-star text-warning"></i>
                                @else
                                    <i class="fa fa-star-o text-muted"></i>
                                @endif
                            @endfor
                        </div>
                        <div class="__info">
                            <span class="text-muted small">{{ $movie->vote_average }}/10</span> <span class="text-muted small">{{ __('utilities.by') }} {{ $movie->vote_count }} {{ __('utilities.users') }}</span>
                        </div>
                    </div>
                    <div class="entry-desciption text-muted">
                        <p>{{ $movie->overview }}</p>
                    </div>
                    <div class="entry-table">
                        <ul class="list-unstyled">
                            <li>{{ __('utilities.released') }}: <span>{{ $movie->release_date }}</span></li>
                            <li>{{ __('utilities.runtime') }}: <span>{{ $movie->runtime }} {{ __('utilities.minutes') }}</span></li>
                            <li>{{ __('utilities.genre') }}: <span>{!! genre_comma($movie->genres) !!}</span></li>
                            <li>{{ __('utilities.stars') }}: <span>{!! star_comma($movie->credits->cast, 5) !!}</span></li>
                            <li>{{ __('utilities.director') }}: <span>{!! director_comma($movie->credits->crew, 5) !!}</span></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <section>
        {{-- Movie Similar --}}
        @isset($movie->similar)
            <div class="card mb-3">
                <div class="card-header">
                    <h5 class="card-title m-0">{{ __('section.title.movie_similar') }}</h5>
                </div>
                <div class="card-body">
                    <div class="row">
                        @foreach (block_id_lists($movie->similar->results) as $item)
                            <div class="col-md-3 mb-3">
                                <div class="media position-relative">
                                    <img class="mr-3" width="50" src="{{ img_poster($item->poster_path) }}" alt="Image {{ $item->title }}" title="Image {{ $item->title }} ({{ to_year($item->release_date ?? '') }})">
                                    <div class="media-body">
                                        <a href="{{ mopie_route('movie.single',['id' => $item->id, 'slug' => str_slug($item->original_title)]) }}" rel="bookmark" title="{{ $item->title }} ({{ to_year($item->release_date ?? '') }})" class="stretched-link">
                                            <h2 class="card-title h6 m-1">{{ $item->title }}</h2>
                                        </a>
                                        <p class="small text-secondary">{{ $item->release_date ?? '' }}</p>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    </div>
                </div>
            </div>
        @endisset

        {{-- Movie recommendations --}}
        @isset($movie->recommendations)
            <div class="card mb-3">
                <div class="card-header">
                    <h5 class="card-title m-0">{{ __('section.title.movie_recommendation') }}</h5>
                </div>
                <div class="card-body">
                    <div class="row">
                        @foreach (block_id_lists($movie->recommendations->results) as $item)
                            <div class="col-md-3 mb-3">
                                <div class="media position-relative">
                                    <img class="mr-3" width="50" src="{{ img_poster($item->poster_path) }}" alt="Image {{ $item->title }}" title="Image {{ $item->title }} ({{ to_year($item->release_date ?? '') }})">
                                    <div class="media-body">
                                        <a href="{{ mopie_route('movie.single',['id' => $item->id, 'slug' => str_slug($item->original_title)]) }}" rel="bookmark" title="{{ $item->title }} ({{ to_year($item->release_date ?? '') }})" class="stretched-link">
                                            <h2 class="card-title h6 m-1">{{ $item->title }}</h2>
                                        </a>
                                        <p class="small text-secondary">{{ $item->release_date ?? '' }}</p>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    </div>
                </div>
            </div>
        @endisset
    </section>
@endsection