{% from "_form_helpers.html" import render_field %}
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card">
            <div class="card-body">
                <form id="fsh-converter-form" method="POST" enctype="multipart/form-data" class="form">
                    {{ form.hidden_tag() }}
                    {{ render_field(form.package) }}
                    {{ render_field(form.input_mode) }}
                    <div id="file-upload" style="display: none;">
                        {{ render_field(form.fhir_file) }}
                    </div>
                    <div id="text-input" style="display: none;">
                        {{ render_field(form.fhir_text) }}
                    </div>
                    {{ render_field(form.output_style) }}
                    {{ render_field(form.log_level) }}
                    {{ render_field(form.fhir_version) }}
                    {{ render_field(form.fishing_trip) }}
                    {{ render_field(form.dependencies, placeholder="One per line, e.g., hl7.fhir.us.core@6.1.0") }}
                    {{ render_field(form.indent_rules) }}
                    {{ render_field(form.meta_profile) }}
                    {{ render_field(form.alias_file) }}
                    {{ render_field(form.no_alias) }}
                    <div class="d-grid gap-2 d-sm-flex">
                        {{ form.submit(class="btn btn-success", id="submit-btn") }}
                        <a href="{{ url_for('index') }}" class="btn btn-secondary">Back</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% if error %}
<div class="alert alert-danger mt-4">{{ error }}</div>
{% endif %}
{% if fsh_output %}
<div class="alert alert-success mt-4">Conversion successful!</div>
<h3 class="mt-4">FSH Output</h3>
<pre class="p-3">{{ fsh_output }}</pre>
<a href="{{ url_for('download_fsh') }}" class="btn btn-primary">Download FSH</a>
{% if comparison_report %}
<h3 class="mt-4">Fishing Trip Comparison Report</h3>
<a href="{{ url_for('static', filename='uploads/fsh_output/fshing-trip-comparison.html') }}" class="badge bg-primary text-white text-decoration-none mb-3" target="_blank">Click here for SUSHI Validation</a>
<div class="card">
    <div class="card-body">
        {% if comparison_report.differences %}
        <p class="text-warning">Differences found in round-trip validation:</p>
        <ul>
            {% for diff in comparison_report.differences %}
            <li>{{ diff.path }}: {{ diff.description }}</li>
            {% endfor %}
        </ul>
        {% else %}
        <p class="text-success">No differences found in round-trip validation.</p>
        {% endif %}
    </div>
</div>
{% endif %}
{% endif %}