{% extends "holdfast/sov/base.html" %}
{% load i18n %}

{% block holdfast_content %}
    <div class="alert alert-secondary">
        {% blocktranslate %}These are the live settings. The fuel bands colour the dashboard <em>and</em> decide when Discord is told, from the same numbers &mdash; so the board and the channel can never disagree about what counts as urgent.{% endblocktranslate %}
    </div>

    <form method="post" action="{% url 'holdfast:sov_settings_save' %}">
        {% csrf_token %}

        <div class="holdfast-section-title">{% translate "Fuel bands (days remaining)" %}</div>
        <div class="row g-3 mb-4">
            <div class="col-md-4">
                <label class="form-label">{% translate "Amber below" %}</label>
                <input type="number" step="0.5" min="0.5" name="fuel_warning_days" class="form-control"
                       value="{{ config.fuel_warning_days|floatformat:'-2' }}">
            </div>
            <div class="col-md-4">
                <label class="form-label">{% translate "Red below" %}</label>
                <input type="number" step="0.5" min="0.5" name="fuel_danger_days" class="form-control"
                       value="{{ config.fuel_danger_days|floatformat:'-2' }}">
            </div>
            <div class="col-md-4">
                <label class="form-label">{% translate "Critical below" %}</label>
                <input type="number" step="0.5" min="0.5" name="fuel_critical_days" class="form-control"
                       value="{{ config.fuel_critical_days|floatformat:'-2' }}">
            </div>
        </div>

        <div class="holdfast-section-title">{% translate "ADM" %}</div>
        <div class="row g-3 mb-4">
            <div class="col-md-4">
                <label class="form-label">{% translate "Warn when ADM falls below" %}</label>
                <input type="number" step="0.1" min="0" name="adm_alert_threshold" class="form-control"
                       value="{% if config.adm_alert_threshold is not None %}{{ config.adm_alert_threshold|floatformat:'-2' }}{% endif %}">
                <div class="form-text">{% translate "Leave blank to turn ADM warnings off entirely." %}</div>
            </div>
        </div>

        <div class="holdfast-section-title">{% translate "Notifications" %}</div>
        <div class="form-check form-switch mb-2">
            <input class="form-check-input" type="checkbox" name="notify_upgrade_offline" id="nuo" {% if config.notify_upgrade_offline %}checked{% endif %}>
            <label class="form-check-label" for="nuo">{% translate "Warn when an upgrade drops out for lack of fuel, power or workforce" %}</label>
        </div>
        <div class="form-check form-switch mb-2">
            <input class="form-check-input" type="checkbox" name="notify_upgrade_den_caused" id="nud" {% if config.notify_upgrade_den_caused %}checked{% endif %}>
            <label class="form-check-label" for="nud">{% translate "Say so separately when a mercenary den siphoning that system is the likely cause" %}</label>
        </div>
        <div class="form-check form-switch mb-4">
            <input class="form-check-input" type="checkbox" name="sov_discord_enabled" id="sde" {% if config.sov_discord_enabled %}checked{% endif %}>
            <label class="form-check-label" for="sde">{% translate "Post sovereignty alerts to Discord" %}</label>
        </div>

        {% include "holdfast/partials/_routing.html" %}

        <button class="btn btn-primary">{% translate "Save" %}</button>
    </form>

    <form method="post" action="{% url 'holdfast:sov_settings_test' %}" class="mt-3">
        {% csrf_token %}
        <button class="btn btn-outline-secondary btn-sm">
            <i class="fab fa-discord"></i> {% translate "Send test alerts" %}
        </button>
        <span class="holdfast-sub ms-2">{% translate "one sample per category in this section" %}</span>
    </form>
{% endblock %}
