{% extends "base.html" %}

{% block title %}{{ title }}{% endblock %}

{% block content %}
<div class="section">
    <div class="container">
        <div class="row">
            <div class="col-12 mb-4 admin-header">
                <h1>{{ title }}</h1>
            </div>
        </div>
        
        <div class="row">
            <div class="col-md-8 mx-auto">
                <div class="card shadow-sm">
                    <div class="card-body">
                        <form method="POST" action="">
                            {{ form.hidden_tag() }}
                            
                            <div class="mb-3">
                                {{ form.question.label(class="form-label") }}
                                {{ form.question(class="form-control") }}
                                {% if form.question.errors %}
                                <div class="invalid-feedback d-block">
                                    {% for error in form.question.errors %}
                                    <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                                {% endif %}
                            </div>
                            
                            <div class="mb-3">
                                {{ form.answer.label(class="form-label") }}
                                {{ form.answer(class="form-control", rows=6) }}
                                {% if form.answer.errors %}
                                <div class="invalid-feedback d-block">
                                    {% for error in form.answer.errors %}
                                    <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                                {% endif %}
                                <small class="text-muted">Puede utilizar formato HTML básico para dar estilo al texto.</small>
                            </div>
                            
                            <div class="row mb-3">
                                <div class="col-md-6">
                                    {{ form.order.label(class="form-label") }}
                                    {{ form.order(class="form-control") }}
                                    <small class="text-muted">Las preguntas aparecerán en orden ascendente según este número.</small>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-check mt-4">
                                        {{ form.is_active(class="form-check-input") }}
                                        {{ form.is_active.label(class="form-check-label") }}
                                    </div>
                                </div>
                            </div>
                            
                            <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                                <a href="{{ url_for('admin.manage_faqs') }}" class="btn btn-secondary me-md-2">Cancelar</a>
                                {{ form.submit(class="btn btn-primary") }}
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block scripts %}
<script>
    // Podríamos agregar un editor WYSIWYG aquí para el campo de respuesta
    // Por ejemplo, con TinyMCE, CKEditor, etc.
</script>
{% endblock %}
