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

{% block title %}{% if is_edit %}Edit {{ model.name }}{% else %}Add LLM Model{% endif %}{% endblock %}

{% block content %}
<div class="text-sm breadcrumbs mb-4">
    <ul>
        <li><a href="{% url 'llm_manager:dashboard' %}">LLM Manager</a></li>
        <li><a href="{% url 'llm_manager:model_list' %}">Models</a></li>
        <li>{% if is_edit %}Edit {{ model.name }}{% else %}Add Model{% endif %}</li>
    </ul>
</div>

<div class="max-w-2xl">
    <h1 class="text-2xl font-bold mb-4">{% if is_edit %}Edit {{ model.name }}{% else %}Add LLM Model{% endif %}</h1>

    <form method="post" class="space-y-4">
        {% csrf_token %}

        {% for field in form %}
        <div class="form-control w-full">
            <label class="label"><span class="label-text font-semibold">{{ field.label }}</span></label>
            {{ field }}
            {% if field.errors %}
            <label class="label"><span class="label-text-alt text-error">{{ field.errors.0 }}</span></label>
            {% endif %}
            {% if field.help_text %}
            <label class="label"><span class="label-text-alt">{{ field.help_text }}</span></label>
            {% endif %}
        </div>
        {% endfor %}

        <div class="flex gap-2 pt-4">
            <button type="submit" class="btn btn-primary">{% if is_edit %}Save Changes{% else %}Create Model{% endif %}</button>
            <a href="{% if is_edit %}{% url 'llm_manager:model_detail' model.pk %}{% else %}{% url 'llm_manager:model_list' %}{% endif %}" class="btn btn-ghost">Cancel</a>
        </div>
    </form>
</div>
{% endblock %}
