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

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">{% trans "Import Products" %}</h1>
        <div class="btn-toolbar mb-2 mb-md-0">
            <a href="{% url 'inventory' %}" class="btn btn-secondary">
                <i class="bi bi-arrow-left"></i> {% trans "Back to Inventory" %}
            </a>
        </div>
    </div>

    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">{% trans "Upload Excel File" %}</h5>
                </div>
                <div class="card-body">
                    <div class="alert alert-info">
                        <i class="bi bi-info-circle"></i> {% trans "Excel Format Instructions:" %}<br>
                        <ul>
                            <li><strong>{% trans "Column A" %}:</strong> {% trans "Name (English) - Required" %}</li>
                            <li><strong>{% trans "Column B" %}:</strong> {% trans "Name (Arabic) - Optional" %}</li>
                            <li><strong>{% trans "Column C" %}:</strong> {% trans "SKU/Barcode - Required & Unique" %}</li>
                            <li><strong>{% trans "Column D" %}:</strong> {% trans "Cost Price - Optional (Default 0)" %}</li>
                            <li><strong>{% trans "Column E" %}:</strong> {% trans "Sale Price - Required" %}</li>
                            <li><strong>{% trans "Column F" %}:</strong> {% trans "Category Name (English) - Required (Created if missing)" %}</li>
                            <li><strong>{% trans "Column G" %}:</strong> {% trans "Unit Name (English) - Optional (Created if missing)" %}</li>
                            <li><strong>{% trans "Column H" %}:</strong> {% trans "Stock Quantity - Optional (Default 0)" %}</li>
                        </ul>
                        <small>{% trans "Please skip the first row (header)." %}</small>
                    </div>

                    <form method="post" enctype="multipart/form-data">
                        {% csrf_token %}
                        {% for field in form %}
                        <div class="mb-3">
                            <label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}</label>
                            {{ field }}
                            {% if field.help_text %}
                                <div class="form-text">{{ field.help_text }}</div>
                            {% endif %}
                            {% for error in field.errors %}
                                <div class="text-danger">{{ error }}</div>
                            {% endfor %}
                        </div>
                        {% endfor %}
                        <button type="submit" class="btn btn-primary w-100">
                            <i class="bi bi-upload"></i> {% trans "Import Products" %}
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
