{% extends "admin_base.html" %}

{% block title %}Edit Section{% endblock %}

{% block admin_content %}
<div class="max-w-xl mx-auto bg-white p-8 rounded-lg shadow-md">
    <h1 class="text-2xl font-bold mb-6">Edit Section</h1>
    <form method="POST" enctype="multipart/form-data" class="space-y-4">
        <div>
            <label for="name" class="block text-sm font-medium text-gray-700">Name</label>
            <input type="text" name="name" id="name" value="{{ section.name }}" required
                class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
        </div>
        <div>
            <label for="description" class="block text-sm font-medium text-gray-700">Description</label>
            <textarea name="description" id="description" rows="3"
                class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">{{ section.description }}</textarea>
        </div>
        <div>
            <label for="icon" class="block text-sm font-medium text-gray-700">Icon</label>
            {% if section.icon %}
            <div class="mb-2">
                <img src="{{ url_for('static', filename='icons/' + section.icon) }}" alt="{{ section.name }}" class="h-8 w-8 object-contain">
            </div>
            {% endif %}
            <input type="file" name="icon" id="icon" accept="image/*"
                class="mt-1 block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-[#6b8f71] file:text-white hover:file:bg-[#5a7b5f]">
            <p class="mt-1 text-sm text-gray-500">Leave empty to keep the current icon</p>
        </div>
        <button type="submit" class="btn-main w-full">Save Changes</button>
        <a href="{{ url_for('manage_sections') }}" class="block text-center mt-4 text-gray-500 hover:text-gray-700">Cancel</a>
    </form>
</div>
{% endblock %} 