<!-- templates/core/dynamic_form_test.html -->
{% extends 'core/base.html' %}
{% load static %}

{% block title %}Dynamic Form Preview - SwiftPOS{% endblock %}

{% block topbar_title %}
Dynamic Form Preview
{% endblock %}

{% block content %}
<div class="container-fluid px-0">

    <div class="d-flex flex-wrap justify-content-between align-items-center mb-3 gap-2">
        <div>
            <h5 class="mb-0">Dynamic Form Preview</h5>
            <div class="text-muted small">
                This shows how your custom fields are rendered for staff.
            </div>
        </div>
        <a href="{% url 'field_builder' %}" class="btn btn-outline-secondary btn-sm">
            <i class="fas fa-sliders"></i> Back to Field Builder
        </a>
    </div>

    <div class="row g-3">
        <div class="col-lg-8">
            <div class="card">
                <div class="card-header">
                    <h6 class="card-title mb-0">Form</h6>
                </div>
                <div class="card-body">
                    <form id="dynamicForm" method="post">
                        {% csrf_token %}
                        {{ form_html|safe }}

                        <div class="mt-4 d-flex justify-content-end gap-2">
                            <button type="button" class="btn btn-outline-secondary btn-sm" onclick="document.getElementById('dynamicForm').reset();">
                                <i class="fas fa-undo me-1"></i>Reset
                            </button>
                            <button type="submit" class="btn btn-primary btn-sm">
                                <i class="fas fa-save me-1"></i>Submit
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-lg-4">
            <div class="card">
                <div class="card-header">
                    <h6 class="card-title mb-0">How it works</h6>
                </div>
                <div class="card-body">
                    <p class="small mb-2">
                        This preview renders the HTML generated from your field builder.
                    </p>
                    <ul class="small mb-0">
                        <li>Any field marked <strong>Required</strong> will be validated server-side.</li>
                        <li>Order is based on the <strong>Display Order</strong> value in each field.</li>
                        <li>Receipt / report visibility is controlled in the field settings.</li>
                    </ul>
                </div>
            </div>

            <div class="sp-soft-section mt-2">
                <div class="small fw-semibold mb-1">Tip</div>
                <div class="small">
                    Test this form the same way cashiers will use it, then adjust your fields if something feels confusing.
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
