{% extends "base.html" %}

{% block title %}Run Artifacts{% endblock %}

{% block content %}
<div class="mb-6">
    <a href="/runs/{{ run_id }}/detail" class="inline-flex items-center text-blue-400 hover:text-blue-300">
        <svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
        </svg>
        Back to Run
    </a>
</div>

<h1 class="text-2xl font-bold text-white mb-6">Run Artifacts</h1>

{% if artifacts %}
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
    {% for artifact in artifacts %}
    <div class="bg-gray-800 rounded-lg p-4">
        <div class="flex items-center justify-between mb-3">
            <span class="px-2 py-1 text-xs rounded
                {% if artifact.role == 'input' %}bg-blue-600
                {% elif artifact.role == 'output' %}bg-green-600
                {% else %}bg-purple-600{% endif %}">
                {{ artifact.role }}
            </span>
            <span class="text-sm text-gray-400">{{ artifact.step_name }}</span>
        </div>

        <div class="mb-3">
            <p class="text-xs text-gray-500 mb-1">Content Hash</p>
            <p class="font-mono text-xs text-gray-300 truncate">{{ artifact.hash }}</p>
        </div>

        <div class="flex items-center justify-between text-sm">
            <span class="text-gray-400">
                {% if artifact.media_type == 'video' %}Video
                {% elif artifact.media_type == 'image' %}Image
                {% elif artifact.media_type == 'audio' %}Audio
                {% else %}File{% endif %}
            </span>
            <span class="text-gray-500">{{ (artifact.size_bytes / 1024)|round(1) }} KB</span>
        </div>

        <div class="mt-3 flex gap-2">
            <a href="/cache/{{ artifact.hash }}" class="flex-1 px-3 py-1 bg-gray-700 hover:bg-gray-600 text-center text-sm rounded transition-colors">
                View
            </a>
            <a href="/cache/{{ artifact.hash }}/raw" class="flex-1 px-3 py-1 bg-blue-600 hover:bg-blue-700 text-center text-sm rounded transition-colors">
                Download
            </a>
        </div>
    </div>
    {% endfor %}
</div>
{% else %}
<div class="bg-gray-800 rounded-lg p-6 text-center">
    <p class="text-gray-400">No artifacts found for this run.</p>
</div>
{% endif %}
{% endblock %}
