{**
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License 3.0 (AFL-3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/AFL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 *}
{extends file=$layout}

{block name='head_microdata_special'}
  {include file='_partials/microdata/product-list-jsonld.tpl' listing=$listing}
{/block}

{block name='content'}
  <section id="main" class="mrd-catalog">

    {block name='product_list_header'}
      <header class="mrd-catalog-head">
        <h1 id="js-product-list-header" class="display">{$listing.label}</h1>
      </header>
    {/block}


    {hook h="displayHeaderCategory"}

    {assign var=_filterTop value=($catalogue[0]->filter == "filtreHaut")}

    {* Mode "filtre à gauche" : les facettes sont rendues dans #left-column (cf. layout-both-columns.tpl).
       Mode "filtre en haut" : elles sont dans la barre d'outils ci-dessous. *}
    <div class="cat-layout{if $_filterTop} is-filter-top{/if}">

      <div class="mrd-listing-body">
        <section id="products">

          {*
            Barre d'outils du listing.
            - Filtre HAUT : les facettes (hook displayFilter) ET le tri sur UNE seule
              ligne (cf. maquette MÉRIDIAN). #search_filters et #js-product-list-top
              sont deux frères persistants : le re-rendu AJAX les remplace sur place
              sans casser la rangée flex.
            - Filtre GAUCHE : seul le tri (products-top) reste ici, les facettes sont
              dans la sidebar.
            La barre est rendue HORS du test "produits > 0" pour que le filtre reste
            accessible même quand le filtrage ne renvoie aucun produit.
          *}
          {if $_filterTop}
            <div class="mrd-toolbar mrd-toolbar--top">
              <div class="mrd-toolbar-filters">
                <span class="mrd-toolbar-label">
                  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3 5h18l-7 8v6l-4-2v-4z"/></svg>
                  {l s='Filter' d='Shop.Theme.Actions'}
                </span>
                {hook h="displayFilter"}
              </div>
          {/if}
              {block name='product_list_top'}
                {include file='catalog/_partials/products-top.tpl' listing=$listing}
              {/block}
          {if $_filterTop}
            </div>
          {/if}

          {block name='product_list_active_filters'}
            <div class="mrd-active-filters hidden-sm-down">
              {$listing.rendered_active_filters nofilter}
            </div>
          {/block}

          {if $listing.products|count}

            {block name='product_list'}
              {include file='catalog/_partials/products.tpl' listing=$listing productClass="col-xs-12 col-sm-6 col-xl-4"}
            {/block}

            {block name='product_list_bottom'}
              {include file='catalog/_partials/products-bottom.tpl' listing=$listing}
            {/block}

          {else}
            <div id="js-product-list">
              {capture assign="errorContent"}
                <h4>{l s='No products available yet' d='Shop.Theme.Catalog'}</h4>
                <p>{l s='Stay tuned! More products will be shown here as they are added.' d='Shop.Theme.Catalog'}</p>
              {/capture}

              {include file='errors/not-found.tpl' errorContent=$errorContent}
            </div>

            <div id="js-product-list-bottom"></div>
          {/if}
        </section>
      </div>{* /mrd-listing-body *}
    </div>{* /cat-layout *}

    {block name='product_list_footer'}
      {if !empty($category.description)}
        <section class="mrd-catalog-desc mrd-section">
          <div class="catdesc-grid">
            <div class="muted">{$category.description nofilter}</div>
            {if !empty($category.image.large.url)}
              <div class="catdesc-img"><img src="{$category.image.large.url}" alt="{$category.name|default:''}" loading="lazy" width="600" height="450"></div>
            {/if}
          </div>
        </section>
      {/if}
    {/block}

    {hook h="displayFooterCategory"}

  </section>
{/block}
