{% extends "admin_base.html" %}
{% block admin_content %}
<div class="admin-toolbar">
    <h2>Code Farm - Eras</h2>
</div>

<p class="hint-text admin-settings-intro">Starting an Era snapshots a fresh visible leaderboard (coins/harvests this Era) for every farm. Real coin balances, prestige, stars, and Legacy/Mastery upgrades are never touched or reset. Ending an Era ranks farms by Era score, awards Stars to the top 10, and records the results permanently.</p>

{% if era_active %}
<div class="admin-field">
    <p><strong>Era {{ era_number }}: {{ era_name }}</strong> is running.</p>
    <p class="hint-text">Started {{ format_date(era_started_at, true) }}, scheduled to end {{ format_date(era_ends_at, true) }}.</p>
</div>
<form method="POST" action="/admin/game/era/end">
    <button type="submit" class="btn btn-danger" data-confirm="End the current Era now? This ranks every farm, awards Stars to the top 10, and resets the visible Era leaderboard. Real balances are never affected.">End Era</button>
</form>
{% else %}
<p class="hint-text">No Era is currently running. The Era leaderboard board and Era-exclusive crops stay dormant until one is started.</p>
<form method="POST" action="/admin/game/era/start" class="admin-settings-form">
    <div class="admin-field">
        <label for="era-name">Era name</label>
        <input type="text" id="era-name" name="name" maxlength="60" required placeholder="e.g. Genesis">
    </div>
    <div class="admin-field">
        <label for="era-duration">Duration (days)</label>
        <input type="number" id="era-duration" name="duration_days" min="1" max="180" value="28">
    </div>
    <button type="submit" class="btn btn-primary" data-confirm="Start a new Code Farm Era? This resets every farm's visible Era coins/harvests counters to zero (real coins and prestige are untouched).">Start Era</button>
</form>
{% endif %}
{% endblock %}
