{% extends "admin/login_base.html" %}
{% load i18n admin_static %}

{% block content %}
<div class="login-shell">
    <div class="login-brand">
        <div class="login-brand-inner">
            <div class="login-brand-logo">⚡</div>
            <h1>智捷ERP</h1>
            <p class="login-brand-tagline">SmartJet ERP</p>
            <p class="login-brand-desc">高效管理 · 智能协同 · 企业互联</p>
            <ul class="login-brand-features">
                <li>销售 / 采购 / 库存一体化</li>
                <li>组织架构与审批流程</li>
                <li>数据驱动经营决策</li>
            </ul>
        </div>
    </div>

    <div class="login-panel">
        <div class="login-card">
            <div class="login-card-header">
                <h2>欢迎登录</h2>
                <p>请输入您的账号和密码</p>
            </div>

            {% if form.errors and not form.non_field_errors %}
            <div class="login-error">
                {% if form.errors.items|length == 1 %}请修正以下错误。{% else %}请修正以下错误。{% endif %}
            </div>
            {% endif %}

            {% if form.non_field_errors %}
            {% for error in form.non_field_errors %}
            <div class="login-error">{{ error }}</div>
            {% endfor %}
            {% endif %}

            {% if user.is_authenticated %}
            <div class="login-error">
                您已以 {{ user.get_username }} 登录，但无权访问此页面。请使用其他账号登录。
            </div>
            {% endif %}

            <form action="{{ app_path }}" method="post" id="login-form" class="login-form">
                {% csrf_token %}
                <div class="login-field">
                    <label for="id_username">用户名</label>
                    {{ form.username }}
                </div>
                <div class="login-field">
                    <label for="id_password">密码</label>
                    {{ form.password }}
                    <input type="hidden" name="next" value="{{ next }}" />
                </div>
                <button type="submit" class="login-submit">登 录</button>
            </form>

            <div class="login-demo">
                <div class="login-demo-title">演示账号</div>
                <div class="login-demo-row">
                    <span>用户名</span><code>xinmi_admin</code>
                </div>
                <div class="login-demo-row">
                    <span>密&nbsp;&nbsp;&nbsp;码</span><code>admin123456</code>
                </div>
            </div>

            <div class="login-footer-link">
                <a href="http://code.xinmi.cloud/" target="_blank" rel="noopener">智捷ERP · 新觅源码库</a>
            </div>
        </div>
    </div>
</div>
{% endblock %}
