<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Configuration — Felhom Hub</title>
    <link rel="stylesheet" href="/style.css">
</head>
<body>
    <div class="container">
        <header>
            <h1>Felhom Hub</h1>
            <nav class="nav-links">
                <a href="/" class="nav-link">Dashboard</a>
                <a href="/configs" class="nav-link">Customers</a>
                <a href="/apps" class="nav-link">Apps</a>
                <a href="/configuration" class="nav-link active">Configuration</a>
            </nav>
        </header>

        <h2 style="margin-bottom: 1rem;">Configuration</h2>

        {{if eq .Flash "assets_refreshed"}}
        <div class="flash flash-success">Assets refreshed successfully from image seed.</div>
        {{end}}
        {{if eq .Flash "assets_error"}}
        <div class="flash flash-error">Asset refresh failed. Check server logs for details.</div>
        {{end}}
        {{if eq .Flash "assets_not_configured"}}
        <div class="flash flash-error">Asset manager is not configured.</div>
        {{end}}

        <!-- Assets section -->
        <section class="card">
            <h3 style="margin-top: 0;">Assets</h3>
            <p class="text-muted" style="margin-bottom: 1rem;">
                App logos and screenshots served to controllers. Assets are seeded from the Docker image
                and synced to controllers daily via the asset manifest API.
            </p>
            <div class="info-grid">
                <div class="info-item">
                    <span class="label">Files in manifest</span>
                    <span class="value">{{.AssetCount}}</span>
                </div>
                <div class="info-item">
                    <span class="label">Manifest generated</span>
                    <span class="value" style="font-family: var(--font-mono); font-size: 0.85em;">{{if .AssetLastSync}}{{.AssetLastSync}}{{else}}—{{end}}</span>
                </div>
            </div>
            <form method="POST" action="/configuration" style="margin-top: 1rem;">
                <input type="hidden" name="_csrf" value="{{.CSRFToken}}">
                <input type="hidden" name="action" value="refresh_assets">
                <button type="submit" class="btn" onclick="this.disabled=true;this.textContent='Refreshing…';this.form.submit();">Refresh Assets from Image</button>
            </form>
            <p class="text-muted" style="margin-top: 0.75rem; font-size: 0.8rem;">
                Re-reads the baked-in asset seed directory and updates changed files.
                Controllers will pick up changes on their next daily sync or manual trigger.
            </p>
        </section>

        <footer style="margin-top: 2rem; color: var(--text-muted); font-size: 0.8rem; text-align: center;">
            Felhom Hub <span style="font-family: var(--font-mono)">v{{hubVersion}}</span>
        </footer>
    </div>
</body>
</html>
