{{ header }}
<div id="product-category" class="container">
  <ul class="breadcrumb">
    {% for breadcrumb in breadcrumbs %}
      <li class="breadcrumb-item"><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
    {% endfor %}
  </ul>
  <div class="row">{{ column_left }}
    <div id="content" class="col">{{ content_top }}
      <h1>{{ heading_title }}</h1>
      {% if image or description %}
        <div class="row">
          {% if image %}
            <div class="col-3"><img src="{{ image }}" alt="{{ heading_title }}" title="{{ heading_title }}" class="img-thumbnail"/></div>
          {% endif %}
          {% if description %}
            <div class="col-9">{{ description }}</div>
          {% endif %}
        </div>
        <hr/>
      {% endif %}

      {% if categories %}
        <h3>{{ text_refine }}</h3>
        {% if categories|length <= 5 %}
          <div class="row">
            <div class="col-sm-3">
              <ul>
                {% for category in categories %}
                  <li><a href="{{ category.href }}">{{ category.name }}</a></li>
                {% endfor %}
              </ul>
            </div>
          </div>
        {% else %}
          <div class="row row-cols-sm-2 row-cols-lg-4">
            {% set total = category.children|length %}
            {% if total > 20 %}
              {% set batch = (total / 4)|round(0, 'ceil') %}
            {% else %}
              {% set batch = 5 %}
            {% endif %}
            {% for category in categories|batch(batch) %}
              <div class="col">
                <ul>
                  {% for child in category %}
                    <li><a href="{{ child.href }}">{{ child.name }}</a></li>
                  {% endfor %}
                </ul>
              </div>
            {% endfor %}
          </div>
          <br/>
        {% endif %}
      {% endif %}

      {% if products %}
        <div class="row">
          <div class="col-lg-3">
            <div class="mb-3">
              <a href="{{ compare }}" id="compare-total" class="btn btn-primary d-block"><i class="fa-solid fa-arrow-right-arrow-left"></i> <span class="d-none d-xl-inline">{{ text_compare }}</span></a>
            </div>
          </div>
          <div class="col-lg-1 d-none d-lg-block">
            <div class="btn-group">
              <button type="button" id="button-list" class="btn btn-light" data-bs-toggle="tooltip" title="{{ button_list }}"><i class="fa-solid fa-table-list"></i></button>
              <button type="button" id="button-grid" class="btn btn-light" data-bs-toggle="tooltip" title="{{ button_grid }}"><i class="fa-solid fa-table-cells"></i></button>
            </div>
          </div>
          <div class="col-lg-4 offset-lg-1 col-6">
            <div class="input-group mb-3">
              <label for="input-sort" class="input-group-text">{{ text_sort }}</label>
              <select id="input-sort" class="form-select" onchange="location = this.value;">
                {% for sorts in sorts %}
                  <option value="{{ sorts.href }}"{% if sorts.value == '%s-%s'|format(sort, order) %} selected{% endif %}>{{ sorts.text }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-lg-3 col-6">
            <div class="input-group mb-3">
              <label for="input-limit" class="input-group-text">{{ text_limit }}</label>
              <select id="input-limit" class="form-select" onchange="location = this.value;">
                {% for limits in limits %}
                  <option value="{{ limits.href }}"{% if limits.value == limit %} selected{% endif %}>{{ limits.text }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
        </div>

        <div id="product-list" class="row row-cols-1 row-cols-sm-2 row-cols-md-2 row-cols-lg-4">
          {% for product in products %}
            <div class="col mb-3">{{ product }}</div>
          {% endfor %}
        </div>

        <div class="row">
          <div class="col-sm-6 text-start">{{ pagination }}</div>
          <div class="col-sm-6 text-end">{{ results }}</div>
        </div>
      {% endif %}
      {% if not categories and not products %}
        <p>{{ text_no_results }}</p>
        <div class="text-end"><a href="{{ continue }}" class="btn btn-primary">{{ button_continue }}</a></div>
      {% endif %}
      {{ content_bottom }}</div>
    {{ column_right }}</div>
</div>
{{ footer }}
