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

{% block title %}Delete {{ library.name }} — {{ themis_app_name }}{% endblock %}

{% block content %}
<div class="mb-4">
    <a href="{% url 'library:library-detail' uid=library.uid %}" class="btn btn-ghost btn-sm">← {{ library.name }}</a>
</div>

<div class="max-w-lg">
    <h1 class="text-3xl font-bold mb-4 text-error">Delete Library</h1>
    <div class="alert alert-warning mb-6">
        <span>Are you sure you want to delete <strong>{{ library.name }}</strong>? This action cannot be undone.</span>
    </div>
    {% if library.managed_by_display %}
    <div class="alert alert-error mb-6">
        <span>
            <strong>This Library is managed by {{ library.managed_by_display }}</strong>{% if library.workspace_id %}
            (workspace <code>{{ library.workspace_id }}</code>){% endif %}.
            {% if library.workspace_id %}
            Deleting it here removes its embedded content from Mnemosyne, but the
            source files still live in {{ library.managed_by_display }} — it will
            be <strong>recreated and re-embedded on the next sync</strong>. Use
            this to clear an orphaned Library that is blocking workspace
            re-registration.
            {% else %}
            Deleting it here removes its embedded content from Mnemosyne;
            {{ library.managed_by_display }} may recreate and re-embed it on its
            next sync.
            {% endif %}
        </span>
    </div>
    {% endif %}
    <form method="post">
        {% csrf_token %}
        <div class="flex gap-2">
            <button type="submit" class="btn btn-error">Delete</button>
            <a href="{% url 'library:library-detail' uid=library.uid %}" class="btn btn-ghost">Cancel</a>
        </div>
    </form>
</div>
{% endblock %}
