{% extends "themis/base.html" %}

{% block title %}API Keys — {{ themis_app_name }}{% endblock %}

{% block content %}
<div class="max-w-3xl mx-auto">
    <div class="flex items-center justify-between mb-6">
        <h1 class="text-2xl font-bold">API Keys</h1>
        <a href="{% url 'themis:key-create' %}" class="btn btn-primary btn-sm">Add Key</a>
    </div>

    {% if keys %}
    <div class="space-y-3">
        {% for key in keys %}
        <div class="card bg-base-200">
            <div class="card-body p-4">
                <div class="flex items-center justify-between">
                    <div>
                        <a href="{% url 'themis:key-detail' pk=key.pk %}"
                           class="font-semibold link link-hover">
                            {{ key.display_name }}
                        </a>
                        <div class="flex items-center gap-2 mt-1">
                            <span class="badge badge-sm badge-outline">{{ key.get_key_type_display }}</span>
                            <span class="text-sm opacity-60 font-mono">{{ key.masked_value }}</span>
                            {% if not key.is_active %}
                            <span class="badge badge-sm badge-error">Inactive</span>
                            {% endif %}
                        </div>
                    </div>
                    <div class="flex gap-1">
                        <a href="{% url 'themis:key-edit' pk=key.pk %}"
                           class="btn btn-ghost btn-xs">Edit</a>
                    </div>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
    {% else %}
    <div class="card bg-base-200">
        <div class="card-body items-center text-center py-12">
            <p class="opacity-60 mb-4">No API keys configured yet.</p>
            <a href="{% url 'themis:key-create' %}" class="btn btn-primary btn-sm">Add Your First Key</a>
        </div>
    </div>
    {% endif %}
</div>
{% endblock %}
