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

{% block title %}SmartTools - Build Custom AI Commands in YAML{% endblock %}

{% block meta_description %}Create Unix-style pipeable AI tools with simple YAML configuration. Provider-agnostic, composable, and community-driven.{% endblock %}

{% block content %}
<!-- Hero Section -->
<section class="bg-white py-16 md:py-24">
    <div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
        <h1 class="text-4xl md:text-5xl font-bold text-gray-900 leading-tight">
            Build Custom AI Commands in YAML
        </h1>
        <p class="mt-6 text-xl text-gray-600 max-w-3xl mx-auto">
            Create Unix-style pipeable tools that work with any AI provider.
            Provider-agnostic and composable for ultimate flexibility.
        </p>

        <!-- Install Command -->
        <div class="mt-10 max-w-xl mx-auto">
            <div class="flex items-center bg-gray-100 rounded-lg p-4 group">
                <span class="text-gray-400 mr-2 select-none">$</span>
                <code id="install-command" class="flex-1 text-gray-800 font-mono text-sm md:text-base text-left">pip install smarttools && smarttools init</code>
                <button type="button"
                        onclick="copyInstallCommand()"
                        class="ml-4 p-2 text-gray-400 hover:text-gray-600 transition-colors"
                        aria-label="Copy install command">
                    <svg id="copy-icon" class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/>
                    </svg>
                    <svg id="check-icon" class="w-5 h-5 hidden text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
                    </svg>
                </button>
            </div>
        </div>

        <!-- CTAs -->
        <div class="mt-10 flex flex-col sm:flex-row items-center justify-center gap-4">
            <a href="{{ url_for('web.docs', path='getting-started') }}"
               class="w-full sm:w-auto inline-flex justify-center items-center px-8 py-4 text-lg font-medium text-white bg-indigo-600 rounded-md hover:bg-indigo-700 transition-colors shadow-md">
                Get Started
            </a>
            <a href="{{ url_for('web.tutorials') }}"
               class="w-full sm:w-auto inline-flex justify-center items-center px-8 py-4 text-lg font-medium text-cyan-600 border-2 border-cyan-500 rounded-md hover:bg-cyan-50 transition-colors">
                View Tutorials
            </a>
        </div>
    </div>
</section>

<!-- Three Pillars Section -->
<section class="py-16 bg-gray-50">
    <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
        <h2 class="text-3xl font-bold text-gray-900 text-center mb-12">
            Why SmartTools?
        </h2>

        <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
            <!-- Pillar 1: Easy -->
            <div class="bg-white rounded-lg border border-gray-200 p-8 text-center hover:shadow-lg transition-shadow">
                <div class="w-16 h-16 bg-indigo-100 rounded-full flex items-center justify-center mx-auto mb-6">
                    <svg class="w-8 h-8 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
                    </svg>
                </div>
                <h3 class="text-xl font-semibold text-gray-900 mb-3">Easy to Use</h3>
                <p class="text-gray-600">
                    Simple YAML configuration for quick setup. No complex programming required to get started.
                </p>
            </div>

            <!-- Pillar 2: Powerful -->
            <div class="bg-white rounded-lg border border-gray-200 p-8 text-center hover:shadow-lg transition-shadow">
                <div class="w-16 h-16 bg-cyan-100 rounded-full flex items-center justify-center mx-auto mb-6">
                    <svg class="w-8 h-8 text-cyan-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
                    </svg>
                </div>
                <h3 class="text-xl font-semibold text-gray-900 mb-3">Powerful</h3>
                <p class="text-gray-600">
                    Leverage any AI provider, compose complex multi-step workflows with Python code integration.
                </p>
            </div>

            <!-- Pillar 3: Community -->
            <div class="bg-white rounded-lg border border-gray-200 p-8 text-center hover:shadow-lg transition-shadow">
                <div class="w-16 h-16 bg-indigo-100 rounded-full flex items-center justify-center mx-auto mb-6">
                    <svg class="w-8 h-8 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
                    </svg>
                </div>
                <h3 class="text-xl font-semibold text-gray-900 mb-3">Community</h3>
                <p class="text-gray-600">
                    Share, discover, and contribute to a growing ecosystem of tools built by developers like you.
                </p>
            </div>
        </div>
    </div>
</section>

<!-- Featured Tools Section -->
<section class="py-16 bg-white">
    <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex items-center justify-between mb-12">
            <h2 class="text-3xl font-bold text-gray-900">
                Featured Tools & Projects
            </h2>
            <a href="{{ url_for('web.tools') }}" class="text-indigo-600 hover:text-indigo-800 font-medium flex items-center">
                View All
                <svg class="w-4 h-4 ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
                </svg>
            </a>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
            {% for tool in featured_tools %}
            {{ tool_card(
                owner=tool.owner,
                name=tool.name,
                description=tool.description,
                category=tool.category,
                downloads=tool.downloads,
                version=tool.version
            ) }}
            {% else %}
            <!-- Placeholder when no tools -->
            <div class="col-span-full text-center py-12 text-gray-500">
                <p class="mb-4">No featured tools yet. Be the first to publish!</p>
                <a href="{{ url_for('web.docs', path='publishing') }}" class="text-indigo-600 hover:text-indigo-800 font-medium">
                    Learn how to publish a tool
                </a>
            </div>
            {% endfor %}
        </div>
    </div>
</section>

<!-- Getting Started Section -->
<section class="py-16 bg-gray-50">
    <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
        <h2 class="text-3xl font-bold text-gray-900 text-center mb-12">
            Getting Started
        </h2>

        <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
            {{ tutorial_card(
                title="Basic Setup",
                description="Learn how to install SmartTools and configure your first AI provider.",
                href=url_for('web.docs', path='getting-started'),
                step_number=1
            ) }}

            {{ tutorial_card(
                title="Your First Tool",
                description="Create a simple AI-powered command that you can use from your terminal.",
                href=url_for('web.tutorials_path', path='first-tool'),
                step_number=2
            ) }}

            {{ tutorial_card(
                title="Advanced Workflows",
                description="Combine multiple steps and providers to build powerful automation.",
                href=url_for('web.tutorials_path', path='advanced-workflows'),
                step_number=3
            ) }}
        </div>
    </div>
</section>

<!-- Featured Contributor Section -->
{% if featured_contributor %}
<section class="py-16 bg-white">
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
        <h2 class="text-3xl font-bold text-gray-900 text-center mb-12">
            Featured Contributor
        </h2>

        {{ contributor_card(
            display_name=featured_contributor.display_name,
            slug=featured_contributor.slug,
            bio=featured_contributor.bio_override or featured_contributor.bio,
            verified=featured_contributor.verified
        ) }}
    </div>
</section>
{% endif %}

<!-- Ad Zone (Optional) -->
{% if show_ads %}
<section class="py-8 bg-blue-50">
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
        <p class="text-xs text-gray-500 mb-2">Advertisement</p>
        <div id="footer-ad-zone" class="min-h-[90px] flex items-center justify-center">
            <!-- Ad content loaded dynamically -->
            <p class="text-gray-400 text-sm">Support SmartTools Development</p>
        </div>
    </div>
</section>
{% endif %}

<script>
function copyInstallCommand() {
    const command = 'pip install smarttools && smarttools init';
    navigator.clipboard.writeText(command).then(() => {
        const copyIcon = document.getElementById('copy-icon');
        const checkIcon = document.getElementById('check-icon');
        copyIcon.classList.add('hidden');
        checkIcon.classList.remove('hidden');
        setTimeout(() => {
            copyIcon.classList.remove('hidden');
            checkIcon.classList.add('hidden');
        }, 2000);
    });
}
</script>
{% endblock %}
