<section class="list-panel search-result-section">
  <div class="panel-heading">
    <div>
      <h2>{{ title }}</h2>
      <p>{{ items|length }} result{{ items|length == 1 ? '' : 's' }}</p>
    </div>
  </div>

  {% if items is empty %}
    <div class="compact-empty-state">
      <p>No matches in this section.</p>
    </div>
  {% else %}
    <div class="search-result-list">
      {% for item in items %}
        <a class="search-result-item" href="{{ base_url }}/{{ base_path }}/{{ item.id }}{{ type == 'product' ? '/edit' : '' }}">
          <span class="search-result-icon" aria-hidden="true">
            {% if type == 'customer' %}
              <svg viewBox="0 0 24 24"><path d="M20 21a8 8 0 0 0-16 0"></path><circle cx="12" cy="7" r="4"></circle></svg>
            {% elseif type == 'product' %}
              <svg viewBox="0 0 24 24"><path d="m21 16-9 5-9-5V8l9-5 9 5v8Z"></path><path d="m3 8 9 5 9-5"></path><path d="M12 13v8"></path></svg>
            {% else %}
              <svg viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"></path><path d="M14 2v6h6"></path><path d="M8 13h8M8 17h6"></path></svg>
            {% endif %}
          </span>
          <span class="search-result-copy">
            {% if type == 'document' %}
              <strong>{{ item.document_number }}</strong>
              <small>{{ item.company_name ?: item.customer_name ?: 'No customer' }} · {{ item.status|replace({'_': ' '})|title }} · {{ item.currency }} {{ item.grand_total|number_format(2) }}</small>
            {% elseif type == 'customer' %}
              <strong>{{ item.company_name ?: item.name }}</strong>
              <small>{{ item.name }}{% if item.email %} · {{ item.email }}{% endif %}{% if item.phone %} · {{ item.phone }}{% endif %}</small>
            {% else %}
              <strong>{{ item.name }}</strong>
              <small>{{ item.description ?: 'No description' }} · KES {{ item.unit_price|number_format(2) }}</small>
            {% endif %}
          </span>
          <span class="search-result-action">View</span>
        </a>
      {% endfor %}
    </div>
  {% endif %}
</section>
