<div class="docs-search">
    <h1>Search documentation</h1>
    {% if quota_fallback %}
    <p class="docs-search-hint">You have reached your daily AI assistant limit. Showing keyword search results instead.</p>
    {% endif %}
    <form class="docs-search-bigform" method="get" action="/docs/search.html" role="search">
        <input type="search" name="q" value="{{ search_query|default('', true) }}" placeholder="Search the docs…" aria-label="Search documentation" class="docs-search-input" autofocus>
        <button type="submit" class="btn btn-primary">Search</button>
    </form>

    {% if search_query %}
        {% if search_results %}
        <p class="docs-search-count">{{ search_results|length }} result{{ '' if search_results|length == 1 else 's' }} for "{{ search_query }}"</p>
        <ul class="docs-search-results">
            {% for result in search_results %}
            <li class="docs-search-result">
                <a class="docs-search-result-title" href="{{ result.url }}">{{ result.title }}</a>
                <p class="docs-search-snippet">{{ result.snippet | safe }}</p>
            </li>
            {% endfor %}
        </ul>
        {% else %}
        <p class="docs-search-empty">No results for "{{ search_query }}".</p>
        {% endif %}
    {% else %}
        <p class="docs-search-hint">Type a query to search across every documentation page.</p>
    {% endif %}
</div>
