{% extends "base.html" %}
{% from "components/tool_card.html" import tool_card %}

{% block title %}{{ publisher.display_name }} (@{{ publisher.slug }}) - SmartTools{% endblock %}

{% block meta_description %}{{ publisher.bio or 'SmartTools publisher profile for ' ~ publisher.display_name }}{% endblock %}

{% block content %}
<div class="bg-gray-50 min-h-screen">
    <!-- Profile Header -->
    <div class="bg-white border-b border-gray-200">
        <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
            <div class="flex items-start gap-6">
                <!-- Avatar -->
                <div class="w-24 h-24 bg-indigo-100 rounded-full flex items-center justify-center flex-shrink-0">
                    <span class="text-3xl font-bold text-indigo-600">{{ publisher.display_name[0]|upper }}</span>
                </div>

                <!-- Info -->
                <div class="flex-1 min-w-0">
                    <div class="flex items-center gap-3">
                        <h1 class="text-2xl font-bold text-gray-900 truncate">{{ publisher.display_name }}</h1>
                        {% if publisher.verified %}
                        <svg class="w-6 h-6 text-blue-500 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20" title="Verified publisher">
                            <path fill-rule="evenodd" d="M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44 5.252a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
                        </svg>
                        {% endif %}
                    </div>
                    <p class="mt-1 text-gray-500">@{{ publisher.slug }}</p>

                    {% if publisher.bio %}
                    <p class="mt-4 text-gray-600">{{ publisher.bio }}</p>
                    {% endif %}

                    <div class="mt-4 flex items-center gap-4 text-sm text-gray-500">
                        {% if publisher.website %}
                        <a href="{{ publisher.website }}"
                           target="_blank"
                           rel="noopener noreferrer"
                           class="flex items-center gap-1 hover:text-indigo-600">
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"/>
                            </svg>
                            Website
                        </a>
                        {% endif %}
                        <span class="flex items-center gap-1">
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"/>
                            </svg>
                            {{ tools|length }} tool{{ 's' if tools|length != 1 else '' }}
                        </span>
                        <span class="flex items-center gap-1">
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
                            </svg>
                            Joined {{ publisher.created_at|date_format }}
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Tools Section -->
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
        <h2 class="text-xl font-semibold text-gray-900 mb-6">Published Tools</h2>

        {% if tools %}
        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
            {% for tool in tools %}
            {{ tool_card(
                owner=tool.owner,
                name=tool.name,
                description=tool.description,
                category=tool.category,
                downloads=tool.downloads,
                version=tool.version
            ) }}
            {% endfor %}
        </div>
        {% else %}
        <div class="text-center py-12 bg-white rounded-lg border border-gray-200">
            <svg class="mx-auto w-12 h-12 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"/>
            </svg>
            <p class="mt-4 text-gray-600">No tools published yet.</p>
        </div>
        {% endif %}
    </div>
</div>
{% endblock %}
