{% extends 'base.html' %}
{% block title %}Add Discount - Rapha-Bethel BNPS{% endblock %}
{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h3 mb-0">{% if object %}Edit{% else %}Add{% endif %} Discount</h1>
        <a href="{% url 'finance:discount_list' %}" class="btn btn-outline-secondary"><i class="fas fa-arrow-left me-2"></i>Back</a>
    </div>
    <div class="row justify-content-center">
        <div class="col-md-7">
            <div class="card shadow">
                <div class="card-header py-3 bg-primary text-white"><h6 class="m-0"><i class="fas fa-tags me-2"></i>Discount Details</h6></div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        {% if form.errors %}<div class="alert alert-danger">Please correct the errors below.</div>{% endif %}
                        <div class="row mb-3">
                            <div class="col-md-6"><label class="form-label fw-bold">Name (EN) <span class="text-danger">*</span></label>{{ form.name }}</div>
                            <div class="col-md-6"><label class="form-label fw-bold">Name (FR)</label>{{ form.name_fr }}</div>
                        </div>
                        <div class="row mb-3">
                            <div class="col-md-6"><label class="form-label fw-bold">Discount Type</label>{{ form.discount_type }}</div>
                            <div class="col-md-6"><label class="form-label fw-bold">Value <span class="text-danger">*</span></label>{{ form.value }}</div>
                        </div>
                        <div class="row mb-3">
                            <div class="col-md-6"><label class="form-label fw-bold">Applies To</label>{{ form.applies_to }}</div>
                        </div>
                        <div class="mb-3"><label class="form-label fw-bold">Specific Fees</label>{{ form.specific_fees }}</div>
                        <div class="mb-3"><label class="form-label fw-bold">Description</label>{{ form.description }}</div>
                        <div class="form-check mb-3">{{ form.is_active }}<label class="form-check-label fw-bold ms-2">Active</label></div>
                        <div class="d-flex justify-content-end gap-2 mt-4">
                            <a href="{% url 'finance:discount_list' %}" class="btn btn-secondary">Cancel</a>
                            <button type="submit" class="btn btn-primary"><i class="fas fa-save me-2"></i>Save Discount</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% block extra_js %}
<script>document.querySelectorAll('input:not(.form-check-input):not([type="submit"]), select, textarea').forEach(el => { el.classList.add(el.tagName === 'SELECT' ? 'form-select' : 'form-control'); });</script>
{% endblock %}
{% endblock %}
