{% extends 'layouts/base.twig' %}

{% block content %}
    <h1 class="my-5 position-relative fs-3 fw-bold sp-module-title">{{ __('Documentos', 'Sindikatua') }}</h1>

    <section class="page-documentos">
        <div class="container">
            {% if documentos %}

                {% for doc in documentos %}
                    <div class="card mb-3">
                        <div class="card-header">
                            
                                <a href="{{ doc.documento_url }}" class="text-decoration-none" target="_blank">
                                    <p class="card-title mb-1 fs-5 text-black fw-bolder hover-title-text">{{ doc.title }}</p>
                                </a>
                        </div>
                        <div class="row g-0">
                            <div class="col-1">
                                {% if doc.thumbnail %}
                                    <img src="{{ doc.thumbnail }}"
                                        class="img-fluid fit-object"
                                        alt="{{ doc.title }}"
                                        loading="lazy"
                                        >
                                {% else %}
                                    <div class="bg-light d-flex align-items-center justify-content-center h-100 rounded-start">
                                        <i class="bi bi-file-earmark-image-fill"></i>
                                    </div>
                                {% endif %}
                            </div>
                            <div class="col-11">
                                <div class="card-body d-flex flex-column justify-content-between h-100 py-2">
                                    <div>
                                        {% if doc.content %}
                                            <p class="card-text small mb-2">{{ doc.content }}</p>
                                        {% endif %}
                                    </div>

                                    <div>
                                        {% if doc.documento_url %}
                                            <a href="{{ doc.documento_url }}" 
                                                class="btn me-2 btn-primary-cnt btn-xs" 
                                                target="_blank">
                                                    <i class="bi bi-eye-fill"></i>
                                                    {{ __('Ver documento', 'Sindikatua') }}
                                            </a>

                                            <a href="{{ doc.documento_url() }}" download
                                                class="btn me-2 btn-primary-cnt btn-xs" >
                                                    <i class="bi bi-cloud-download-fill"></i>
                                                    {{ __('Descargar', 'Sindikatua') }}
                                            </a>
                                        {% else %}
                                            no hay doc.documento_url

                                        {% endif %}

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                {% endfor %}
            {% else %}
                <div class="alert alert-info" role="alert">
                    <p>{{ __('No hay documentos', 'Sindikatua') }}</p>
                </div>
            {% endif %}

            <!-- PAGINATION -->
            {% set pagination = posts.pagination %}
            {% if pagination %}
            <div class="pagination-custom mt-5">
                {% include 'partials/pagination-custom.twig' %}
            </div>
            {% else %}
                <div class="alert alert-info" role="alert">
                    No hay paginación.
                </div>
            {% endif %}

        </div>
    </section>
{% endblock %}
