<!DOCTYPE html>
<html lang="en">
<head>
    {{template "html-head" .}}
</head>
<body class="app-shell">
    {{template "navbar" .}}

    <div class="app-body container-fluid px-3 px-lg-4 px-xxl-5">
        <main class="container">
        <div class="page-header">
            <h2>Movies</h2>
            <form class="search-form" action="/movies" method="get">
                <input type="text" name="q" class="input" placeholder="Search movies..." value="{{.Query}}">
                <button type="submit" class="btn">Search<div class="hoverEffect"><div></div></div></button>
            </form>
        </div>

        {{if .Movies}}
        <div class="gx-card-grid movie-card-grid">
            {{range .Movies}}
            <div class="gx-card movie-card" onclick="location.href='/movies/{{.Movie.ID}}'">
                <div class="gx-card-thumb"
                     style="background-image: url('{{if .Movie.ImageURL}}{{.Movie.ImageURL}}{{else}}/static/img/placeholder-movie.jpg{{end}}'); background-color: #1a1a1a;">
                </div>

                <div class="gx-card-body">
                    <div class="gx-card-title">{{.Movie.Title}}</div>

                    {{if .Movie.Date}}
                    <div class="gx-card-meta">📅 {{.Movie.Date}}</div>
                    {{end}}

                    <div class="gx-card-meta">{{.SceneCount}} scenes</div>

                    {{if .StudioName}}
                    <div class="gx-card-meta">
                        🎬 {{.StudioName}}
                    </div>
                    {{end}}

                    {{if .Movie.Duration}}
                    <div class="gx-card-tags">
                        <span class="gx-card-tag">{{.Movie.Duration}} min</span>
                        {{if .Movie.Source}}
                        <span class="gx-card-tag">{{.Movie.Source}}</span>
                        {{end}}
                    </div>
                    {{end}}
                </div>
            </div>
            {{end}}
        </div>
        {{else}}
        <div class="empty-state">
            <p>No movies found.</p>
            {{if .Query}}
            <p>Try a different search term or <a href="/movies">view all movies</a>.</p>
            {{else}}
            <p>Movies will appear here once imported from TPDB or Adult Empire.</p>
            {{end}}
        </div>
        {{end}}
        </main>
    </div>
    {{template "html-scripts" .}}
</body>
</html>
