{% extends "base.html" %}

{% block title %}Marketplace - RAGLint{% endblock %}

{% block content %}
<div class="space-y-6">
    <div class="flex justify-between items-center">
        <div>
            <h1 class="text-2xl font-bold text-gray-900">Plugin Marketplace</h1>
            <p class="mt-1 text-sm text-gray-500">Discover and install community plugins to extend RAGLint.</p>
        </div>
    </div>

    <!-- Plugins Grid -->
    <div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
        {% for plugin in plugins %}
        <div class="bg-white overflow-hidden shadow rounded-lg divide-y divide-gray-200">
            <div class="px-4 py-5 sm:px-6">
                <div class="flex justify-between items-start">
                    <div>
                        <h3 class="text-lg leading-6 font-medium text-gray-900">{{ plugin.name }}</h3>
                        <p class="mt-1 text-xs text-gray-500">v{{ plugin.version }} by {{ plugin.author }}</p>
                    </div>
                    <span
                        class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
                        {{ plugin.type }}
                    </span>
                </div>
                <p class="mt-2 text-sm text-gray-500 h-12 overflow-hidden">
                    {{ plugin.description }}
                </p>
            </div>
            <div class="px-4 py-4 sm:px-6 bg-gray-50">
                <div class="flex justify-between items-center">
                    <div class="text-xs text-gray-500">
                        {{ plugin.downloads }} downloads
                    </div>
                    {% if plugin.installed %}
                    <button disabled
                        class="inline-flex items-center px-3 py-1.5 border border-transparent text-xs font-medium rounded-md text-green-700 bg-green-100 cursor-default">
                        <svg class="-ml-0.5 mr-2 h-4 w-4" fill="currentColor" viewBox="0 0 20 20">
                            <path fill-rule="evenodd"
                                d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
                                clip-rule="evenodd" />
                        </svg>
                        Installed
                    </button>
                    {% else %}
                    <form action="/marketplace/install" method="POST">
                        <input type="hidden" name="plugin_name" value="{{ plugin.name }}">
                        <button type="submit"
                            class="inline-flex items-center px-3 py-1.5 border border-transparent text-xs font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                            Install
                        </button>
                    </form>
                    {% endif %}
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
</div>
{% endblock %}