{% extends "base.html" %}

{% block title %}{{ title }} - Admin{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1>{{ title }}</h1>
    <a href="{{ url_for('admin_dashboard') }}" class="btn btn-outline-secondary">Back to Dashboard</a>
</div>

<div class="row">
    <div class="col-md-8">
        <div class="card">
            <div class="card-body">
                <form method="POST">
                    {{ form.hidden_tag() }}
                    
                    <div class="mb-3">
                        {{ form.title.label(class="form-label") }}
                        {{ form.title(class="form-control") }}
                        {% if form.title.errors %}
                            <div class="text-danger">
                                {% for error in form.title.errors %}
                                    <small>{{ error }}</small>
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                {{ form.category.label(class="form-label") }}
                                {{ form.category(class="form-select") }}
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        {{ form.excerpt.label(class="form-label") }}
                        {{ form.excerpt(class="form-control", rows="3", placeholder="Auto-generated if left blank") }}
                        <div class="form-text">Brief description shown in blog listings</div>
                    </div>
                    
                    <div class="mb-3">
                        {{ form.content.label(class="form-label") }}
                        {{ form.content(class="form-control") }}
                        {% if form.content.errors %}
                            <div class="text-danger">
                                {% for error in form.content.errors %}
                                    <small>{{ error }}</small>
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                    
                    <div class="d-flex gap-2">
                        {{ form.submit(class="btn btn-primary") }}
                        {% if post %}
                            <a href="{{ url_for('blog_post', post_id=post.id) }}" 
                               class="btn btn-outline-info" target="_blank">Preview</a>
                        {% endif %}
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="card">
            <div class="card-header">
                <h6 class="mb-0">Writing Tips</h6>
            </div>
            <div class="card-body">
                <ul class="small">
                    <li>Use clear, descriptive titles</li>
                    <li>Break up long paragraphs</li>
                    <li>Include code examples when relevant</li>
                    <li>Add personal insights and experiences</li>
                </ul>
            </div>
        </div>
        
        <div class="card mt-3">
            <div class="card-header">
                <h6 class="mb-0">Markdown Support</h6>
            </div>
            <div class="card-body">
                <p class="small">You can use basic HTML in your posts:</p>
                <code>&lt;strong&gt;bold&lt;/strong&gt;</code><br>
                <code>&lt;em&gt;italic&lt;/em&gt;</code><br>
                <code>&lt;code&gt;code&lt;/code&gt;</code><br>
                <code>&lt;pre&gt;code block&lt;/pre&gt;</code>
            </div>
        </div>
    </div>
</div>
{% endblock %}