{{define "content"}}
<h2>AUTARCH</h2>

<div class="stats-grid">
    <div class="stat-card">
        <h3>Status</h3>
        {{if .Data.Installed}}
            <span class="badge badge-ok">Installed</span>
            <p><strong>Version:</strong> {{.Data.Version}}</p>
        {{else}}
            <span class="badge badge-err">Not Installed</span>
        {{end}}
        <p><strong>Service:</strong>
            {{if .Data.Running}}
                <span class="badge badge-ok">Running</span>
            {{else}}
                <span class="badge badge-err">Stopped</span>
            {{end}}
        </p>
    </div>
    <div class="stat-card">
        <h3>Info</h3>
        <p><strong>Port:</strong> {{.Data.Port}}</p>
        <p><strong>Uptime:</strong> {{.Data.Uptime}}</p>
        {{if .Data.UpdateAvailable}}
            <p><span class="badge badge-ok">Update Available: {{.Data.LatestVersion}}</span></p>
        {{end}}
    </div>
</div>

<h3>Actions</h3>
<div style="display:flex;gap:.5rem;flex-wrap:wrap">
    {{if not .Data.Installed}}
        <form method="POST" action="/autarch/install"><button class="btn btn-primary">Install</button></form>
    {{else}}
        {{if .Data.Running}}
            <form method="POST" action="/autarch/stop"><button class="btn">Stop</button></form>
            <form method="POST" action="/autarch/restart"><button class="btn">Restart</button></form>
        {{else}}
            <form method="POST" action="/autarch/start"><button class="btn btn-primary">Start</button></form>
        {{end}}
        {{if .Data.UpdateAvailable}}
            <form method="POST" action="/autarch/update"><button class="btn btn-primary">Update</button></form>
        {{end}}
        <form method="POST" action="/autarch/uninstall" onsubmit="return confirm('Uninstall AUTARCH?')">
            <button class="btn">Uninstall</button>
        </form>
    {{end}}
</div>
{{end}}
