<!-- Subdirectories Section -->
{% if subdirectories %}
<div class="sb-rounded sb-p-3 sb-mb-6 sb-bg-secondary-10">
    <h3 class="sb-text-lg sb-font-bold sb-text-text sb-mb-3">Directories</h3>
    <div class="sb-grid sb-grid-cols-1 sb-gap-2">
        {% for subdir in subdirectories %}
        <a href="/{{ subdir.url }}"
           class="sb-flex sb-items-center sb-justify-between sb-border-primary-50 sb-gap-2 sb-px-4 sb-py-4 sb-rounded sb-border sb-bg-background sb-no-underline sb-transition sb-hover:bg-secondary-10 sb-hover:border-primary">
            <span class="sb-text-base sb-font-semibold sb-primary">{{ subdir.title }}</span>
            <span class="sb-text-sm sb-text-text-secondary">{{ subdir.page_count }} page{{ subdir.page_count|pluralize }}</span>
        </a>
        {% endfor %}
    </div>
</div>
{% endif %}

<!-- Pages Section -->
{% if pages %}
<div class="sb-rounded sb-p-3 sb-bg-secondary-10">
    <h3 class="sb-text-lg sb-font-bold sb-text-text sb-mb-3">Pages</h3>
    <div class="sb-grid sb-grid-cols-1 sb-gap-3">
        {% for page in pages %}
        <a href="/{{ page.url }}" class="sb-block sb-px-4 sb-py-4 sb-rounded sb-border sb-bg-background sb-no-underline sb-transition sb-hover:bg-secondary-10 sb-border-primary-50 sb-hover:border-primary">
            <div class="sb-flex sb-items-center sb-justify-between sb-gap-2 sb-mb-1">
                <span class="sb-text-base sb-font-bold sb-primary">{{ page.title }}</span>
                {% if page.author %}
                <span class="sb-text-sm sb-text-text-secondary">by {{ page.author }}</span>
                {% endif %}
            </div>

            {% if page.description %}
            <p class="sb-text-sm sb-text-text-secondary sb-mt-1 sb-mb-2">{{ page.description }}</p>
            {% endif %}

            {% if page.published or page.modified or page.tags %}
            <div class="sb-flex sb-flex-wrap sb-items-center sb-gap-3 sb-mt-2 sb-text-sm">
                {% if page.published %}
                <div class="sb-flex sb-items-center sb-gap-1">
                    <span class="sb-font-semibold sb-text-text-secondary">Published:</span>
                    <span class="sb-text-text-secondary">{{ page.published|date:"d M Y" }}</span>
                </div>
                {% endif %}

                {% if page.modified %}
                <div class="sb-flex sb-items-center sb-gap-1">
                    <span class="sb-font-semibold sb-text-text-secondary">Modified:</span>
                    <span class="sb-text-text-secondary">{{ page.modified|date:"d M Y" }}</span>
                </div>
                {% endif %}

                {% if page.tags %}
                <div class="sb-flex sb-items-center sb-gap-1 sb-flex-wrap">
                    <span class="sb-font-semibold sb-text-text-secondary">Tags:</span>
                    {% for tag in page.tags %}
                    <span class="sb-tag sb-bg-secondary-10 sb-primary sb-text-xs sb-px-2 sb-py-1 sb-rounded-full">{{ tag }}</span>
                    {% endfor %}
                </div>
                {% endif %}
            </div>
            {% endif %}
        </a>
        {% endfor %}
    </div>
</div>
{% endif %}

<!-- Empty State -->
{% if not subdirectories and not pages %}
<div class="sb-text-center sb-py-8 sb-text-text-secondary">
    <p class="sb-text-sm">This directory is empty.</p>
</div>
{% endif %}
