<!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="content-stack">
            <section class="hero-section">
                <div class="section-kicker">Control center</div>
                <h1 class="hero-title">Welcome to Goondex</h1>
                <p class="hero-subtitle">Full-library sync with seamless enrichment</p>

                <div class="hero-actions">
                    <button type="button" class="btn btn-light-primary" onclick="bulkImportAll()">
                        Full Import
                        <div class="hoverEffect"><div></div></div>
                    </button>

                    <button type="button" class="btn-secondary" onclick="syncAll()">
                        Sync Library
                        <div class="hoverEffect"><div></div></div>
                    </button>
                </div>
            </section>

            <div class="row g-4 align-items-stretch">
                <div class="col-12 col-xl-8">
                    <section class="surface-panel content-stack h-100">
                        <div class="section-header">
                            <div>
                                <div class="section-kicker">Search everything</div>
                                <div class="section-title">Global search</div>
                            </div>
                            <div class="section-hint">Performers, studios, scenes, tags</div>
                        </div>

                        <section class="search-section mb-0">
                            <input type="text" id="global-search" class="input"
                                   placeholder="Search performers, studios, scenes, or tags...">
                            <div id="global-search-results" class="search-results"></div>
                        </section>
                    </section>
                </div>

                <div class="col-12 col-xl-4">
                    <section class="surface-panel content-stack h-100">
                        <div class="section-header">
                            <div>
                                <div class="section-kicker">Quick commands</div>
                                <div class="section-title">One-click control</div>
                            </div>
                        </div>

                        <div class="d-grid gap-2">
                            <button type="button" class="btn btn-light-primary w-100" onclick="bulkImportAll()">
                                Full Import
                                <div class="hoverEffect"><div></div></div>
                            </button>
                            <button type="button" class="btn-secondary w-100" onclick="syncAll()">
                                Sync Library
                                <div class="hoverEffect"><div></div></div>
                            </button>
                        </div>
                        <p class="section-hint mb-0">Safe defaults with progress feedback.</p>
                    </section>
                </div>
            </div>

            <section class="surface-panel">
                <div class="section-header">
                    <div>
                        <div class="section-kicker">Library health</div>
                        <div class="section-title">Live snapshot</div>
                    </div>
                    <div class="section-hint">Counts update as imports finish</div>
                </div>

                <div class="stats-grid">
                    <!-- Performers -->
                    <div class="stat-card">
                        <div class="stat-icon">👤</div>
                        <div class="stat-content">
                            <div class="stat-value">{{.PerformerCount}}</div>
                            <div class="stat-label">Performers</div>
                        </div>
                        <div class="stat-actions">
                            <a href="/performers" class="stat-link">View all →</a>
                            <button class="btn-small" onclick="bulkImportPerformers()">
                                Import all
                                <div class="hoverEffect"><div></div></div>
                            </button>
                        </div>
                    </div>

                    <!-- Studios -->
                    <div class="stat-card">
                        <div class="stat-icon">🏢</div>
                        <div class="stat-content">
                            <div class="stat-value">{{.StudioCount}}</div>
                            <div class="stat-label">Studios</div>
                        </div>
                        <div class="stat-actions">
                            <a href="/studios" class="stat-link">View all →</a>
                        </div>
                    </div>

                    <!-- Scenes -->
                    <div class="stat-card">
                        <div class="stat-icon">🎬</div>
                        <div class="stat-content">
                            <div class="stat-value">{{.SceneCount}}</div>
                            <div class="stat-label">Scenes</div>
                        </div>
                        <div class="stat-actions">
                            <a href="/scenes" class="stat-link">View all →</a>
                            <button class="btn-small" onclick="aeImportSceneByName()">
                                Quick import
                                <div class="hoverEffect"><div></div></div>
                            </button>
                        </div>
                    </div>

                    <!-- Movies -->
                    <div class="stat-card">
                        <div class="stat-icon">🎞️</div>
                        <div class="stat-content">
                            <div class="stat-value">{{.MovieCount}}</div>
                            <div class="stat-label">Movies</div>
                        </div>
                        <div class="stat-actions">
                            <a href="/movies" class="stat-link">View all →</a>
                        </div>
                    </div>
                </div>
            </section>

            <section class="surface-panel content-stack">
                <div class="section-header">
                    <div>
                        <div class="section-kicker">Pipeline</div>
                        <div class="section-title">Library Import & Sync</div>
                    </div>
                    <div class="section-hint">Run a full import, then sync regularly.</div>
                </div>

                <p class="help-text mb-0">
                    Enrichment runs behind the scenes. Keep everything fresh with sync after imports.
                </p>

                <div class="import-buttons">
                    <button type="button" class="btn" onclick="bulkImportAll()">
                        Import Everything
                        <div class="hoverEffect"><div></div></div>
                    </button>
                    <button type="button" class="btn-secondary" onclick="bulkImportPerformers()">
                        Import Performers
                        <div class="hoverEffect"><div></div></div>
                    </button>
                    <button type="button" class="btn-secondary" onclick="bulkImportStudios()">
                        Import Studios
                        <div class="hoverEffect"><div></div></div>
                    </button>
                    <button type="button" class="btn-secondary" onclick="bulkImportScenes()">
                        Import Scenes
                        <div class="hoverEffect"><div></div></div>
                    </button>
                    <button type="button" class="btn-secondary" onclick="syncAll()">
                        Sync All
                        <div class="hoverEffect"><div></div></div>
                    </button>
                </div>

                <div id="import-all-import-status" class="status-banner" style="margin-top: 0.75rem;"></div>
                <div id="sync-import-status" class="status-banner" style="margin-top: 0.75rem;"></div>
            </section>

            <section class="surface-panel content-stack">
                <div class="section-header">
                    <div>
                        <div class="section-kicker">Adult Empire</div>
                        <div class="section-title">Direct imports</div>
                    </div>
                    <div class="section-hint">Built-in progress feedback for manual pulls.</div>
                </div>

                <div class="import-buttons">
                    <button class="btn-secondary" onclick="aeImportPerformerByName()">
                        Import Performer by Name
                        <div class="hoverEffect"><div></div></div>
                    </button>
                    <button class="btn-secondary" onclick="aeImportPerformerByURL()">
                        Import Performer by URL
                        <div class="hoverEffect"><div></div></div>
                    </button>
                    <button class="btn-secondary" onclick="aeImportSceneByName()">
                        Import Scene by Title
                        <div class="hoverEffect"><div></div></div>
                    </button>
                    <button class="btn-secondary" onclick="aeImportSceneByURL()">
                        Import Scene by URL
                        <div class="hoverEffect"><div></div></div>
                    </button>
                </div>

                <p class="help-text">
                    Movies: scraper not finished yet. Use performer/scene imports for now.
                </p>

                <div id="ae-status" class="status-banner"></div>
            </section>
        </main>
    </div>

    {{template "html-scripts" .}}
</body>
</html>
