{% if topics and topics.items %}
<div class="space-y-4">
    {% for topic in topics.items %}
    <div class="card hover:shadow-lg transition-shadow {% if topic.is_pinned %}border-l-4 border-primary-500{% endif %}">
        <div class="flex items-start">
            <div class="w-10 h-10 bg-primary-100 rounded-full flex items-center justify-center text-primary-600 font-semibold flex-shrink-0">
                {{ topic.author.username[0].upper() }}
            </div>
            <div class="ml-4 flex-grow">
                <div class="flex items-center mb-1">
                    {% if topic.is_pinned %}
                    <span class="bg-primary-100 text-primary-600 text-xs px-2 py-0.5 rounded mr-2">Pinned</span>
                    {% endif %}
                    {% if topic.is_locked %}
                    <span class="bg-red-100 text-red-600 text-xs px-2 py-0.5 rounded mr-2">Locked</span>
                    {% endif %}
                    <a href="{{ url_for('forum_topic', category_slug=category.slug, topic_id=topic.id) }}" class="text-lg font-semibold text-gray-900 hover:text-primary-600 transition-colors">
                        {{ topic.title }}
                    </a>
                </div>
                <div class="text-sm text-gray-500">
                    by {{ topic.author.username }} &middot; {{ topic.created_at.strftime('%B %d, %Y') }}
                </div>
            </div>
            <div class="text-right text-sm text-gray-500 flex-shrink-0">
                <div class="font-medium">{{ topic.reply_count }} replies</div>
                <div>Last activity: {{ topic.last_activity.strftime('%b %d') }}</div>
            </div>
        </div>
    </div>
    {% endfor %}
</div>
{% else %}
<div class="text-center py-16">
    <div class="w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4">
        <svg class="w-8 h-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" />
        </svg>
    </div>
    <h3 class="text-xl font-semibold text-gray-900 mb-2">No topics yet</h3>
    <p class="text-gray-600">Be the first to start a discussion!</p>
</div>
{% endif %}
