{% load djadmin_tags %}
{# Search widget content - rendered inside sidebar-widget div #}
{# Match filter widget structure for consistent spacing #}
<div>
    <h3>Search</h3>

    <form method="get" action="">
        {# Preserve all parameters except q and page #}
        {% query_params_as_hidden_inputs 'q' 'page' %}

        <div>
            <input
                type="search"
                name="q"
                value="{{ request.GET.q|default:'' }}"
                placeholder="Search..."
                aria-label="Search"
            >
        </div>

        <div>
            <button type="submit" class="primary">
                {% include "djadmin/icons/magnifying-glass.html" %}
                <span>Search</span>
            </button>
            {% if request.GET.q %}
                <a href="{% querystring q=None page=None %}" class="secondary">
                    Clear
                </a>
            {% endif %}
        </div>
    </form>
</div>
