{**
 * 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' append}
   <meta property="og:type" content="product">
   {if $product.cover}
     <meta property="og:image" content="{$product.cover.large.url}">
   {/if}
 
   {if $product.show_price}
     <meta property="product:pretax_price:amount" content="{$product.price_tax_exc}">
     <meta property="product:pretax_price:currency" content="{$currency.iso_code}">
     <meta property="product:price:amount" content="{$product.price_amount}">
     <meta property="product:price:currency" content="{$currency.iso_code}">
   {/if}
   {if isset($product.weight) && ($product.weight != 0)}
   <meta property="product:weight:value" content="{$product.weight}">
   <meta property="product:weight:units" content="{$product.weight_unit}">
   {/if}
 {/block}
 
 {block name='head_microdata_special'}
   {include file='_partials/microdata/product-jsonld.tpl'}
 {/block}
 
 {block name='content'}
 
   <section id="main">
     <meta content="{$product.url}">
 
     <div class="row product-container js-product-container">
       <div class="col-xxs-12 col-sm-12 col-md-7 product-media-col">
         {block name='page_content_container'}
           <section class="page-content" id="content">
             {block name='page_content'}
               {block name='product_cover_thumbnails'}
                 {include file='catalog/_partials/product-cover-thumbnails.tpl'}
               {/block} 
             {/block}
           </section>
         {/block}
         </div>
         <div class="col-xxs-12 col-sm-12 col-md-5 article-info">
           {block name='page_header_container'}
             {block name='page_header'}
               {* les pastilles nouveau/promo sont posées sur l'image (product-cover-thumbnails.tpl) *}
               <div class="brand-img">
                   {* image de marque AU-DESSUS du titre *}
                   {if isset($manufacturer_image_url)}
                     <a class="brand-logo-link" href="{$product_brand_url}">
                       <img src="{$manufacturer_image_url}" class="img img-fluid manufacturer-logo" alt="{$product_manufacturer->name}" loading="lazy">
                     </a>
                   {/if}
                   <h1 class="h1">{block name='page_title'}{$product.name}{/block}</h1>
               </div>
             {/block}
           {/block}
           {block name='product_prices'}
             {include file='catalog/_partials/product-prices.tpl'}
           {/block}


          {* La pastille de disponibilité est rendue dans product-add-to-cart.tpl
             (zone rafraîchie en AJAX → se met à jour au changement de taille). *}

          {if !empty($productParameter) && $productParameter[0]->reduction}
            {if $cart.discounts|count > 0}
              {assign var="max_discount" value=$cart.discounts[0]}  {* Initialisation avec la première réduction *}
            
             {foreach from=$cart.discounts item=discount}
                  {if $discount.reduction_percent > $max_discount.reduction_percent || $discount.reduction_amount > $max_discount.reduction_amount}
                    {assign var="max_discount" value=$discount}  {* Mettre à jour la réduction maximale si nécessaire *}
                  {/if}
              {/foreach}
        
              <div class="discounts_product">
                  <p>
                  <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q65 0 123 19t107 53l-58 59q-38-24-81-37.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-18-2-36t-6-35l65-65q11 32 17 66t6 70q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm-56-216L254-466l56-56 114 114 400-401 56 56-456 457Z"/></svg>
                      <span>{$max_discount.description} avec le code : <strong>{$max_discount.code}</strong></span>
                  </p>
              </div>
            {/if}
          {/if}
 
           <div class="product-information">
             {block name='product_description_short'}
               <div id="product-description-short-{$product.id}" class="product-description">{$product.description_short nofilter}</div>
             {/block}
 
             {if $product.is_customizable && count($product.customizations.fields)}
               {block name='product_customization'}
                 {include file="catalog/_partials/product-customization.tpl" customizations=$product.customizations}
               {/block}
             {/if}
 
             <div class="product-actions js-product-actions">
               {block name='product_buy'}
                 <form action="{$urls.pages.cart}" method="post" id="add-to-cart-or-refresh">
                   <input type="hidden" name="token" value="{$static_token}">
                   <input type="hidden" name="id_product" value="{$product.id}" id="product_page_product_id">
                   <input type="hidden" name="id_customization" value="{$product.id_customization}" id="product_customization_id" class="js-product-customization-id">
 
                   {block name='product_variants'}
                     {include file='catalog/_partials/product-variants.tpl'}
                   {/block}
 
                   {block name='product_pack'}
                     {if $packItems}
                       <section class="product-pack">
                         <p class="h4">{l s='This pack contains' d='Shop.Theme.Catalog'}</p>
                         {foreach from=$packItems item="product_pack"}
                           {block name='product_miniature'}
                             {include file='catalog/_partials/miniatures/pack-product.tpl' product=$product_pack showPackProductsPrice=$product.show_price}
                           {/block}
                         {/foreach}
                     </section>
                     {/if}
                   {/block}
 
                   {block name='product_discounts'}
                     {include file='catalog/_partials/product-discounts.tpl'}
                   {/block}

                   {hook h="displayDeliveryEstimation"}
 
                   {block name='product_add_to_cart'}
                     {include file='catalog/_partials/product-add-to-cart.tpl'}
                   {/block}

 
                   {block name='product_additional_info'}
                     {include file='catalog/_partials/product-additional-info.tpl'}
                   {/block}
 
                   {* Input to refresh product HTML removed, block kept for compatibility with themes *}
                   {block name='product_refresh'}{/block}
                 </form>
               {/block}
 
             </div>            
 
             {block name='hook_display_reassurance'}
               {hook h='displayReassurance'}
             {/block}
 
             
  
             {block name='product_tabs'}
               {* Onglets MÉRIDIAN en accordéon (fidèle maquette) *}
               <div class="mrd-acc" data-accordion>

                 {if $product.description}
                   <div class="mrd-acc-item is-open">
                     <button type="button" class="mrd-acc-head"><span>{l s='Description' d='Shop.Theme.Catalog'}</span><svg class="mrd-acc-ico" width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg></button>
                     <div class="mrd-acc-body"><div class="mrd-acc-cell"><div class="mrd-acc-inner"><div class="product-description">{$product.description nofilter}</div></div></div></div>
                   </div>
                 {/if}

                 <div class="mrd-acc-item{if !$product.description} is-open{/if}">
                   <button type="button" class="mrd-acc-head"><span>{l s='Détails du produit' d='Shop.Theme.Catalog'}</span><svg class="mrd-acc-ico" width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg></button>
                   <div class="mrd-acc-body"><div class="mrd-acc-cell"><div class="mrd-acc-inner">{include file='catalog/_partials/product-details.tpl'}</div></div></div>
                 </div>

                 {if $product.attachments}
                   <div class="mrd-acc-item">
                     <button type="button" class="mrd-acc-head"><span>{l s='Pièces jointes' d='Shop.Theme.Catalog'}</span><svg class="mrd-acc-ico" width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg></button>
                     <div class="mrd-acc-body"><div class="mrd-acc-cell"><div class="mrd-acc-inner">
                       <section class="product-attachments">
                         {foreach from=$product.attachments item=attachment}
                           <div class="attachment">
                             <h4><a href="{url entity='attachment' params=['id_attachment' => $attachment.id_attachment]}">{$attachment.name}</a></h4>
                             <p>{$attachment.description}</p>
                             <a class="ulink" href="{url entity='attachment' params=['id_attachment' => $attachment.id_attachment]}">{l s='Télécharger' d='Shop.Theme.Actions'} ({$attachment.file_size_formatted})</a>
                           </div>
                         {/foreach}
                       </section>
                     </div></div></div>
                   </div>
                 {/if}

                 {foreach from=$product.extraContent item=extra key=extraKey}
                   <div class="mrd-acc-item">
                     <button type="button" class="mrd-acc-head"><span>{$extra.title}</span><svg class="mrd-acc-ico" width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg></button>
                     <div class="mrd-acc-body"><div class="mrd-acc-cell"><div class="mrd-acc-inner {$extra.attr.class}">{$extra.content nofilter}</div></div></div>
                   </div>
                 {/foreach}

               </div>
             {/block}
         </div>
       </div>
     </div>
 
     {block name='product_accessories'}
       {if $accessories}
        <section class="product-accessories clearfix">
          <h2>{l s='You might also like' d='Shop.Theme.Catalog'}</h2>
          <div class="slider-container">
            <div class="slider-accessories">
              <div class="products row">
                {foreach from=$accessories item="product_accessory" key="position"}
                  {block name='product_miniature'}
                    {include file='catalog/_partials/miniatures/product.tpl' product=$product_accessory position=$position productClasses="col-xs-12 col-sm-6 col-lg-4 col-xl-3"}
                  {/block}
                {/foreach}
              </div>
            </div>
            <button id="prevBtn-accessories" class="accessories-btn prev">
              <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M400-80 0-480l400-400 71 71-329 329 329 329-71 71Z"/></svg>
            </button>
            <button id="nextBtn-accessories" class="accessories-btn next">
              <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="m321-80-71-71 329-329-329-329 71-71 400 400L321-80Z"/></svg>
            </button>
          </div>
          <div class="pagination-indicators-accessories">
            <div class="indicator-accessories {if $smarty.foreach.indicator.first}active-accessories{/if}"></div>
          </div>
      </section>
       {/if}
     {/block}
 
     {block name='product_footer'}
       {hook h='displayFooterProduct' product=$product category=$category}
     {/block}
 
     {block name='product_images_modal'}
       {include file='catalog/_partials/product-images-modal.tpl'}
     {/block}
 
     {block name='page_footer_container'}
       <footer class="page-footer">
         {block name='page_footer'}
           <!-- Footer content -->
         {/block}
       </footer>
     {/block}
   </section>
 
 {/block}
 