{% load category_tags %}

<nav class="category-breadcrumbs" aria-label="Category breadcrumb">
    {% if breadcrumbs %}
        <ol class="breadcrumb-list">
            <li class="breadcrumb-item">
                <a href="/" class="breadcrumb-link">
                    <i class="heroicons-home-outline breadcrumb-icon"></i>
                    <span class="sr-only">Home</span>
                </a>
            </li>
            
            {% for category in breadcrumbs %}
                <li class="breadcrumb-item">
                    <span class="breadcrumb-separator">
                        <i class="heroicons-chevron-right-outline"></i>
                    </span>
                    
                    {% if not forloop.last %}
                        <a href="/categories/{{ category.get_url_path }}/" class="breadcrumb-link">
                            {% if category.icon %}
                                <i class="{{ category.icon }} breadcrumb-icon"></i>
                            {% endif %}
                            <span class="breadcrumb-text">{{ category.name }}</span>
                        </a>
                    {% else %}
                        <span class="breadcrumb-current">
                            {% if category.icon %}
                                <i class="{{ category.icon }} breadcrumb-icon"></i>
                            {% endif %}
                            <span class="breadcrumb-text">{{ category.name }}</span>
                        </span>
                    {% endif %}
                </li>
            {% endfor %}
        </ol>
    {% endif %}
</nav>

<style>
.category-breadcrumbs {
    font-family: inherit;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9em;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.breadcrumb-link {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    text-decoration: none;
    color: #6b7280;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.breadcrumb-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #374151;
    text-decoration: none;
}

.breadcrumb-current {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    color: #374151;
    font-weight: 600;
}

.breadcrumb-separator {
    display: flex;
    align-items: center;
    color: #9ca3af;
    margin: 0 0.25rem;
}

.breadcrumb-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.breadcrumb-text {
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Responsive */
@media (max-width: 640px) {
    .breadcrumb-list {
        font-size: 0.8em;
    }
    
    .breadcrumb-text {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .breadcrumb-link,
    .breadcrumb-current {
        padding: 0.125rem 0.375rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .category-breadcrumbs {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .breadcrumb-link {
        color: #9ca3af;
    }
    
    .breadcrumb-link:hover {
        background-color: rgba(255, 255, 255, 0.05);
        color: #d1d5db;
    }
    
    .breadcrumb-current {
        color: #f3f4f6;
    }
    
    .breadcrumb-separator {
        color: #6b7280;
    }
}
</style>