{% extends "admin/base.html" %}

{% block title %}Site Settings - Admin - {{ site_name() }}{% endblock %}

{% block admin_content %}
<hgroup>
    <h1>Site Settings</h1>
    <p>Configure your site's name, tagline, and other metadata</p>
</hgroup>

{% if sites_list %}
<label for="site_selector">Site</label>
<select id="site_selector" onchange="window.location.href='/admin/settings?site=' + this.value">
    {% for site in sites_list %}
    <option value="{{ site.key }}"{% if site.key == selected_site %} selected{% endif %}>{{ site.label }}</option>
    {% endfor %}
</select>
<small class="sk-text-muted">Select which site to configure</small>
{% endif %}

<form method="post" action="/admin/settings">
    {% if sites_list %}
    <input type="hidden" name="_site" value="{{ selected_site }}">
    {% endif %}

    <label for="site_name">Site Name</label>
    <input type="text" id="site_name" name="site_name" value="{{ settings.site_name }}" required>
    <small class="sk-text-muted">The name displayed in the header and browser title</small>

    <label for="site_tagline">Site Tagline</label>
    <input type="text" id="site_tagline" name="site_tagline" value="{{ settings.site_tagline }}">
    <small class="sk-text-muted">A short description or slogan for your site</small>

    {% if not selected_site %}
    <label for="site_copyright_holder">Copyright Holder</label>
    <input type="text" id="site_copyright_holder" name="site_copyright_holder" value="{{ settings.site_copyright_holder }}">
    <small class="sk-text-muted">Name displayed in the copyright notice (defaults to site name if empty)</small>

    <label for="site_copyright_start_year">Copyright Start Year</label>
    <input type="number" id="site_copyright_start_year" name="site_copyright_start_year" value="{{ settings.site_copyright_start_year }}" min="1900" max="2100">
    <small class="sk-text-muted">If different from current year, will show a range (e.g., 2020-2026)</small>

    <label for="robots_txt">robots.txt</label>
    <textarea id="robots_txt" name="robots_txt" rows="6" placeholder="User-agent: *&#10;Allow: /&#10;&#10;Sitemap: https://example.com/sitemap.xml">{{ settings.robots_txt }}</textarea>
    <small class="sk-text-muted">Custom robots.txt content. Leave empty to use the default.</small>

    {% if theme_data %}
    <label for="site_theme">Theme</label>
    <select id="site_theme" name="site_theme">
        <option value=""{% if not theme_data.active %} selected{% endif %}>Default (no theme)</option>
        {% for theme in theme_data.themes %}
        <option value="{{ theme.directory_name }}"{% if theme_data.active == theme.directory_name %} selected{% endif %}>
            {{ theme.name }}{% if theme.version %} (v{{ theme.version }}){% endif %}
        </option>
        {% endfor %}
    </select>
    <small class="sk-text-muted">Select a theme to change your site's appearance</small>
    {% endif %}
    {% endif %}

    <div class="sk-form-actions">
        <button type="submit">Save Settings</button>
    </div>
</form>
{% endblock %}
