<div class="d-flex justify-content-between align-items-center mb-4">
    <h2>{{ category.name }}</h2>
    <button class="btn btn-primary" onclick="fetchContent('/parts')">Add New Item</button>
</div>

<div class="card">
    <div class="card-header">
        <h5 class="mb-0">Items in this Category</h5>
    </div>
    <div class="card-body">
        {% if items|length > 0 %}
            <div class="list-group">
                {% for item in items %}
                    <div class="list-group-item d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="mb-1">{{ item.name }}</h6>
                            {% if item.description %}
                                <p class="mb-1 text-muted">{{ item.description }}</p>
                            {% endif %}
                            {% if item.location %}
                                <small class="text-muted">📍 {{ item.location }}</small>
                            {% endif %}
                        </div>
                        <div>
                            <button class="btn btn-sm btn-outline-primary edit-btn" data-id="{{ item.id }}">Edit</button>
                            <button class="btn btn-sm btn-outline-danger delete-btn" data-id="{{ item.id }}">Delete</button>
                            {% if item.id_code %}
                                <a href="/print/{{ item.id }}" target="_blank" class="btn btn-sm btn-outline-secondary">QR</a>
                            {% endif %}
                        </div>
                    </div>
                {% endfor %}
            </div>
        {% else %}
            <p class="text-muted">No items in this category yet.</p>
            <button class="btn btn-primary" onclick="fetchContent('/parts')">Add First Item</button>
        {% endif %}
    </div>
</div>