{% extends 'gallery/base.html' %}

{% block content %}
<div class="container mx-auto px-4 py-8">
    <!-- 面包屑导航 -->
    <nav class="mb-8">
        <ol class="flex items-center space-x-2 text-sm text-gray-400">
            <li>
                <a href="{% url 'index' %}" class="hover:text-blue-400 transition-colors">Gallery</a>
            </li>
            <li>
                <span class="mx-2">/</span>
            </li>
            <li class="text-gray-300">{{ category.name }}</li>
        </ol>
    </nav>

    <!-- 分类标题 -->
    <div class="mb-12 text-center">
        <h1 class="text-4xl md:text-5xl font-serif font-bold mb-4">{{ category.name }}</h1>
        <p class="text-gray-400 max-w-2xl mx-auto">
            {{ artworks.count }} 个作品
        </p>
    </div>

    <!-- 作品网格 -->
    {% if artworks %}
    <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
        {% for artwork in artworks %}
        <a href="{% url 'artwork_detail' artwork.slug %}" class="group">
            <div class="relative overflow-hidden rounded-xl bg-dark-card transition-all duration-300 hover:scale-[1.02] hover:shadow-2xl">
                <!-- 图片 -->
                <div class="aspect-square overflow-hidden">
                    <img
                        data-src="{{ artwork.thumbnail.url|default:artwork.image.url }}"
                        alt="{{ artwork.title }}"
                        class="lazy-image w-full h-full object-cover transition-transform duration-500 group-hover:scale-110"
                        loading="lazy"
                    >
                </div>

                <!-- 遮罩层 -->
                <div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div>

                <!-- 作品信息 -->
                <div class="absolute bottom-0 left-0 right-0 p-4 transform translate-y-full group-hover:translate-y-0 transition-transform duration-300">
                    <div class="bg-black/80 backdrop-blur-sm rounded-lg p-4">
                        <h3 class="text-lg font-semibold text-white mb-2 truncate">{{ artwork.title }}</h3>

                        {% if artwork.description %}
                        <p class="text-gray-300 text-sm line-clamp-2 mb-3">
                            {{ artwork.description|truncatechars:80 }}
                        </p>
                        {% endif %}

                        <div class="flex items-center justify-between text-xs text-gray-400">
                            <span>{{ artwork.created_at|date:"Y年m月d日" }}</span>
                            {% if artwork.view_count %}
                            <span>{{ artwork.view_count }} 次浏览</span>
                            {% endif %}
                        </div>
                    </div>
                </div>

            </div>
        </a>
        {% endfor %}
    </div>
    {% else %}
    <!-- 空状态 -->
    <div class="text-center py-20">
        <div class="inline-flex items-center justify-center w-24 h-24 rounded-full bg-gray-800/50 mb-6">
            <svg class="w-12 h-12 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
            </svg>
        </div>
        <h3 class="text-xl font-semibold text-gray-300 mb-2">暂无作品</h3>
        <p class="text-gray-500 max-w-md mx-auto mb-8">
            该分类下暂时没有作品，请稍后再来查看。
        </p>
        <a href="{% url 'index' %}" class="inline-flex items-center px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors">
            <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
            </svg>
            返回 Gallery
        </a>
    </div>
    {% endif %}
</div>
{% endblock %}