{% extends "base.html" %}

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

{% block content %}
<div class="section mt-5 pt-8">
    <div class="container">
        <div class="row">
            <div class="col-12 mb-4">
                <div class="d-flex justify-content-between align-items-center">
                    <h1>Vista previa del artículo</h1>
                    <div>
                        <a href="{{ url_for('admin.manage_articles') }}" class="btn btn-outline-secondary">
                            <i class="fas fa-arrow-left me-2"></i> Volver a la lista
                        </a>
                        <a href="{{ url_for('admin.edit_article', article_id=article.id) }}" class="btn btn-primary ms-2">
                            <i class="fas fa-edit me-2"></i> Editar artículo
                        </a>
                    </div>
                </div>
                <hr>
            </div>
        </div>
        
        <div class="row">
            <div class="col-12">
                <div class="card shadow-sm">
                    <div class="card-body">
                        <div class="w-full d-flex justify-content-center">
                            <div class="article-featured-image mb-4">                            
                                {% if article.featured_image %}
                                    <img src="{{ url_for('uploaded_file', filename=article.featured_image) }}" class="img-fluid rounded mb-4" alt="{{ article.title }}">
                                {% else %}
                                    <img src="https://via.placeholder.com/1200x630/007BFF/FFFFFF?text=Imagen+del+Art%C3%ADculo" 
                                         alt="{{ article.title }}" class="img-fluid rounded">
                                {% endif %}
                            </div>
                        </div>
                        <div class="preview-header mb-4">
                            <h1 class="article-title">{{ article.title }}</h1>
                            <div class="article-meta">
                                <span class="date"><i class="far fa-calendar me-1"></i> {{ article.created_at }}</span>
                                {% if article.is_published %}
                                    <span class="badge bg-success ms-3">Publicado</span>
                                {% else %}
                                    <span class="badge bg-secondary ms-3">Borrador</span>
                                {% endif %}
                            </div>
                        </div>
                        
                        <div class="article-summary mb-4">
                            <div class="card bg-light">
                                <div class="card-body">
                                    <strong>Resumen:</strong> {{ article.summary }}
                                </div>
                            </div>
                        </div>
                        
                        <div class="article-content">
                            {{ article.content|safe }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_styles %}
<style>
    .preview-header {
        border-bottom: 1px solid #eee;
        padding-bottom: 1rem;
    }
    
    .article-title {
        font-size: 2.5rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
        color: #333;
    }
    
    .article-meta {
        color: #6c757d;
        font-size: 0.9rem;
    }
    
    .article-content {
        line-height: 1.8;
        font-size: 1.1rem;
    }
    
    .article-content h2 {
        margin-top: 2rem;
        margin-bottom: 1rem;
        font-weight: 600;
    }
    
    .article-content img {
        max-width: 100%;
        height: auto;
        margin: 1.5rem 0;
        border-radius: 0.25rem;
    }
</style>
{% endblock %}
