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

{% block title %}Update Charge Number - AI ML Operations{% endblock %}

{% block content %}
<div class="section">
    <div class="container">
        <div style="margin-bottom: 2rem;">
            <a href="{% url 'contract_detail' charge_number.contract.slug %}" class="btn" style="padding: 0.5rem 1.5rem; font-size: 0.9rem;">Back to {{ charge_number.contract.name }}</a>
        </div>

        <h1 class="section-title" style="text-align: left;">Update Charge Number: {{ charge_number.slug }}</h1>

        {% if form.errors %}
        <div class="alert alert-danger" style="max-width: 600px; margin-bottom: 1.5rem; padding: 1rem; border: 1px solid #ff4444; border-radius: 4px; background: rgba(255, 68, 68, 0.1);">
            <ul style="margin: 0; padding-left: 20px; color: #ff4444;">
            {% for field in form %}
                {% for error in field.errors %}
                    <li><strong>{{ field.label }}:</strong> {{ error }}</li>
                {% endfor %}
            {% endfor %}
            {% for error in form.non_field_errors %}
                <li>{{ error }}</li>
            {% endfor %}
            </ul>
        </div>
        {% endif %}

        <div class="card" style="max-width: 600px;">
            <form method="post" action="{% url 'update_charge_number' charge_number.slug %}">
                {% csrf_token %}
                {{ form.as_p }}
                <button type="submit" class="btn" style="margin-top: 1rem;">Update Charge Number</button>
            </form>
        </div>
    </div>
</div>
{% endblock %}
