{% extends "admin/base.html" %}
{% block content %}
<div class="portal-v4-page portal-template-preview">
  <section class="portal-v4-hero portal-template-hero">
    <div><span class="portal-eyebrow">FORMULÁRIO · {{ form_template.get_purpose_display }}</span><h1>{{ form_template.name }}</h1><p>{{ form_template.intro_text|default:form_template.description }}</p></div>
    <div class="portal-v4-actions"><a href="{% url 'admin:template_library_formtemplate_change' form_template.pk %}"><span class="material-symbols-outlined">edit</span>Editar formulário</a><a href="{% url 'template_center' %}"><span class="material-symbols-outlined">arrow_back</span>Biblioteca</a></div>
  </section>
  <div class="portal-template-form-shell">
    <div class="portal-template-form-card">
      {% for field in form_fields %}
      <div class="portal-template-field {% if field.field_type == 'textarea' %}is-wide{% endif %}">
        <label>{{ field.label }}{% if field.required %}<em>*</em>{% endif %}</label>
        {% if field.field_type == 'textarea' %}<textarea rows="4" placeholder="{{ field.placeholder }}" disabled></textarea>
        {% elif field.field_type == 'select' %}<select disabled><option>Selecionar…</option>{% for option in field.option_list %}<option>{{ option }}</option>{% endfor %}</select>
        {% elif field.field_type == 'radio' %}<div class="portal-template-options">{% for option in field.option_list %}<span>○ {{ option }}</span>{% endfor %}</div>
        {% elif field.field_type == 'checkbox' %}<div class="portal-template-options"><span>□ {{ field.placeholder|default:field.label }}</span></div>
        {% elif field.field_type == 'file' %}<input type="file" disabled>
        {% else %}<input type="{{ field.field_type|default:'text' }}" placeholder="{{ field.placeholder }}" value="{{ field.default_value }}" disabled>{% endif %}
        {% if field.help_text %}<small>{{ field.help_text }}</small>{% endif %}
      </div>
      {% empty %}<p class="portal-v4-empty">Este formulário ainda não tem campos.</p>{% endfor %}
      <div class="portal-template-form-actions"><button type="button" disabled>Enviar formulário</button><small>{{ form_template.success_message }}</small></div>
    </div>
  </div>
</div>
{% endblock %}
