{% extends 'base.html' %}
{% load static %}

{% block title %}Blog - ECOLUX BTP{% endblock %}

{% comment %} {% block extra_css %}
{% include 'ecolux_styles.html' %}

{% endblock %} {% endcomment %}

{% block content %}
 {% include "ecolux_styles.html" %}
<!-- Navigation -->
{% include "nav.html" %}

<!-- Header avec image de fond -->
{% include 'partials/page_header.html' with page_title="Notre Blog" page_description="Découvrez nos derniers articles, conseils et actualités du secteur BTP" badge_text="Actualités & Conseils" header_image="assets/img/blog_h.jpg" breadcrumb=breadcrumb_items %}

<!-- Contenu principal -->
<section class="section">
    <div class="container">
        <!-- Filtres de catégories -->
        <div class="filters-container">
            <div class="filters-wrapper">
                <a href="{% url 'app:blog_list' %}" class="filter-btn {% if not current_category %}active{% endif %}">
                    Tous les articles
                </a>
                {% for category in categories %}
                <a href="{% url 'app:blog_list' %}?category={{ category.slug }}" 
                   class="filter-btn {% if current_category.slug == category.slug %}active{% endif %}">
                    {{ category.name }}
                </a>
                {% endfor %}
            </div>
        </div>

        <!-- Articles de blog -->
        <div class="blog-grid">
            {% for post in posts %}
            <article class="blog-card animate-on-scroll">
                <div class="blog-image" 
                     style="background-image: url('{% if post.featured_image %}{{ post.featured_image.url }}{% else %}{% static 'assets/img/blog-default.jpg' %}{% endif %}');">
                </div>
                <div class="blog-content">
                    <div class="blog-meta">
                        <span class="blog-date">{{ post.created_at|date:"d F Y" }}</span>
                        {% if post.category %}
                        <span class="tag">{{ post.category.name }}</span>
                        {% endif %}
                    </div>
                    <h3>
                        <a href="{% url 'app:blog_detail' post.slug %}">{{ post.title }}</a>
                    </h3>
                    <p class="blog-excerpt">{{ post.excerpt|truncatewords:20 }}</p>
                    <div class="blog-footer">
                        {% comment %} <div class="blog-author">
                            <span>Par {{ post.author.get_full_name|default:post.author.username }}</span>
                        </div> {% endcomment %}
                        <a href="{% url 'app:blog_detail' post.slug %}" class="read-more">
                            Lire la suite
                            <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                                <path d="M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"/>
                            </svg>
                        </a>
                    </div>
                </div>
            </article>
            {% empty %}
            <div class="empty-state">
                <div class="empty-icon">📝</div>
                <h3>Aucun article trouvé</h3>
                <p>Nous travaillons sur de nouveaux contenus. Revenez bientôt !</p>
            </div>
            {% endfor %}
        </div>

        <!-- Pagination -->
        {% if posts.has_other_pages %}
        <div class="pagination-container">
            <nav class="pagination">
                {% if posts.has_previous %}
                <a href="?page={{ posts.previous_page_number }}{% if request.GET.category %}&category={{ request.GET.category }}{% endif %}" 
                   class="pagination-btn">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                        <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
                    </svg>
                    Précédent
                </a>
                {% endif %}

                <div class="pagination-info">
                    Page {{ posts.number }} sur {{ posts.paginator.num_pages }}
                </div>

                {% if posts.has_next %}
                <a href="?page={{ posts.next_page_number }}{% if request.GET.category %}&category={{ request.GET.category }}{% endif %}" 
                   class="pagination-btn">
                    Suivant
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                        <path d="M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"/>
                    </svg>
                </a>
                {% endif %}
            </nav>
        </div>
        {% endif %}
    </div>
</section>



<!-- Footer -->
{% include 'partials/footer.html' %}

<!-- WhatsApp Button -->
    <button class="whatsapp-btn" onclick="window.open(`https://wa.me/221779962626?text=${encodeURIComponent('Bonjour ECOLUX BTP, je souhaite obtenir une consultation gratuite pour mon projet de construction.')}`, '_blank');" title="Contactez-nous sur WhatsApp">
        <svg width="32" height="32" viewBox="0 0 24 24" fill="currentColor">
            <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"/>
        </svg>
    </button>

<style>
/* Styles spécifiques à la page blog */
.filters-container {
    margin-bottom: 3rem;
    display: flex;
    justify-content: center;
}

.filters-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: var(--card);
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    color: var(--foreground);
    text-decoration: none;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: var(--transition);
    border: 2px solid transparent;
}

.filter-btn:hover,
.filter-btn.active {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
    color: var(--primary);
    border-color: var(--secondary);
}

.blog-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.blog-excerpt {
    color: rgba(30, 24, 16, 0.7);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.blog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.blog-author {
    font-size: 0.875rem;
    color: rgba(30, 24, 16, 0.6);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: rgba(30, 24, 16, 0.6);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.pagination-container {
    margin-top: 4rem;
    display: flex;
    justify-content: center;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card);
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.pagination-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--secondary);
    color: var(--primary);
    text-decoration: none;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: var(--transition);
}

.pagination-btn:hover {
    background: var(--secondary-light);
    transform: translateY(-2px);
}

.pagination-info {
    font-weight: 600;
    color: var(--foreground);
}

.newsletter-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
    padding: 3rem;
    background: var(--card);
    border-radius: 1.5rem;
    box-shadow: var(--shadow);
}

.newsletter-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary);
}

.newsletter-form {
    max-width: 400px;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: var(--transition);
}

.input-group input:focus {
    outline: none;
    border-color: var(--secondary);
}

@media (max-width: 768px) {
    .newsletter-container {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .filters-wrapper {
        justify-content: center;
    }
}
</style>
{% endblock %}

{% block extra_js %}
{% include 'ecolux_scripts.html' %}
{% endblock %}
