{if !empty($brands) && $brands[0]->isVisible}
<div class="container block-brand home slider-brand">
    <div class="row brand-title">
        <div class="col-sm-12">
            <h2 class="product-title">{$brands[0]->title}</h2>
        </div>
    </div>

    <div class="brand-slider-wrapper">
        {if $brands[0]->style == "brand2"}
            <div class="brand-track">
                <div class="brand-track-inner">
                    {foreach from=$brands[0]->selected_brands item=brand}
                        <div class="brand-item">
                            <a href="{$brand['url']}">
                                <img src="{$brand['img']}" alt="">
                            </a>
                        </div>
                    {/foreach}
                    {* 🔁 Duplication pour la boucle infinie *}
                    {* Calculer combien de fois répéter la boucle *}
                   {if count($brands[0]->selected_brands) < 6}
                        {assign var="repeat_count" value=4} {* Si moins de 6 logos, répéter 4 fois *}
                    {else}
                        {assign var="repeat_count" value=2} {* Sinon répéter 3 fois *}
                    {/if}

                    {* Répéter la boucle avec un calcul dynamique *}
                    {for $i=0 to $repeat_count-1}
                        {foreach from=$brands[0]->selected_brands item=brand}
                            <div class="brand-item">
                                <a href="{$brand['url']}">
                                    <img src="{$brand['img']}" alt="">
                                </a>
                            </div>
                        {/foreach}
                    {/for}
                </div>
            </div>
          
        {else}
            <div class="row brand-items">
                {foreach from=$brands[0]->selected_brands item=brand}
                    <div class="col-sm-2 col-xs-4 brand-item">
                        <a href="{$brand['url']}">
                            <img src="{$brand['img']}" alt="">
                        </a>
                    </div>
                {/foreach}
            </div>
        {/if}
    </div>
    {if {$brands[0]->btn}}
        <div class="row brand-btn">
            <div class="col-sm-12 col-xs-12">
                <a href="/marques" class="btn">Voir toutes nos marques</a>
            </div>
        </div>
    {/if}
</div>
{/if}