{% extends "base.html" %}
{% load static i18n widget_tweaks %}

{% block title %}{{ form_title }} - Invest{% endblock %}

{% block content %}
<div class="mb-4">
    <a href="{% url 'invest-dashboard' %}" class="text-stone-400 hover:text-stone-700 text-sm"><i class="fas fa-arrow-left mr-1"></i> 返回仪表盘</a>
</div>

<div class="max-w-xl bg-white rounded-xl shadow-sm p-6">
    <h1 class="text-xl font-bold text-stone-900 mb-1">{{ form_title }}</h1>
    <p class="text-xs text-stone-400 mb-6">价格留空时，成本将按交易日的市场收盘价估算。</p>

    <form method="post" class="space-y-4">
        {% csrf_token %}
        {% for field in form %}
        <div>
            <label class="block text-xs font-semibold text-stone-500 uppercase tracking-widest mb-1.5">{{ field.label }}</label>
            {{ field|add_class:"w-full border border-stone-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-200" }}
            {% if field.help_text %}<p class="text-xs text-stone-400 mt-1">{{ field.help_text }}</p>{% endif %}
            {% if field.errors %}<p class="text-xs text-red-600 mt-1">{{ field.errors.0 }}</p>{% endif %}
        </div>
        {% endfor %}
        <div class="flex items-center gap-3 pt-2">
            <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white text-sm font-semibold rounded-lg px-4 py-2">保存</button>
            <a href="{% url 'invest-dashboard' %}" class="text-sm text-stone-500 hover:text-stone-700">取消</a>
        </div>
    </form>
</div>
{% endblock %}
