{% extends 'blo/base.html.twig' %}
{% block title %}BLO — Achat en ligne{% endblock %}
{% block stylesheets %}
{{ parent() }}
<style>
.blo-hero-slider-wrap { padding: 1rem 1rem 0; }
.blo-hero-slider {
width: 100%;
aspect-ratio: 1920 / 520;
border-radius: 20px;
overflow: hidden;
box-shadow: 0 12px 32px rgba(93,184,91,0.15);
}
.blo-hero-slider .carousel-inner, .blo-hero-slider .carousel { height: 100%; }
.blo-hero-slide {
position: relative;
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-color: #1a1a2e;
}
.blo-hero-slide::before {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(90deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.1) 60%, transparent 100%);
border-radius: 0;
z-index: 1;
}
.blo-hero-slide .slide-content {
position: absolute;
inset: 0;
z-index: 2;
display: flex;
flex-direction: column;
justify-content: center;
padding: 2rem 2.5rem;
max-width: 540px;
color: #fff;
}
.blo-hero-slide .slide-content h2 { color: #fff; font-size: 1.8rem; font-weight: 800; margin-bottom: 0.5rem; text-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.blo-hero-slide .slide-content .price { font-size: 1.6rem; font-weight: 700; text-shadow: 0 2px 6px rgba(0,0,0,0.3); white-space: nowrap; }
.blo-hero-slide .slide-content .price-old { font-size: 1rem; opacity: 0.7; text-decoration: line-through; margin-left: 0.5rem; }
.blo-hero-slider .carousel-control-prev, .blo-hero-slider .carousel-control-next { width: 4rem; opacity: 0.9; z-index: 10; }
.blo-hero-slider .carousel-indicators button { background-color: rgba(255,255,255,0.5); width: 10px; height: 10px; border-radius: 50%; border: none; margin: 0 6px; }
.blo-hero-slider .carousel-indicators button.active { background-color: #fff; transform: scale(1.2); }
.blo-scroll-row { display: flex; overflow-x: auto; gap: 1rem; padding-bottom: 1rem; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.blo-scroll-row .blo-product-box { flex: 0 0 200px; scroll-snap-align: start; }
@media (min-width: 768px) { .blo-scroll-row .blo-product-box { flex: 0 0 220px; } }
@media (max-width: 576px) { .blo-hero-slide .slide-content { padding: 1.2rem 1.2rem; } .blo-hero-slide .slide-content h2 { font-size: 1.2rem; } }
</style>
{% endblock %}
{% block body %}
<div class="container-fluid px-0 blo-hero-slider-wrap">
{# Slider hero (produits configurés en admin) #}
{% if sliderItems|default([])|length > 0 %}
<section class="blo-hero-slider container">
<div id="heroSlider" class="carousel slide h-100" data-bs-ride="carousel">
<div class="carousel-indicators">
{% for item in sliderItems %}
<button type="button" data-bs-target="#heroSlider" data-bs-slide-to="{{ loop.index0 }}" {{ loop.first ? 'class="active"' : '' }}></button>
{% endfor %}
</div>
<div class="carousel-inner h-100">
{% for item in sliderItems %}
{% set firstImg = item.product is not null ? item.product.images|first : null %}
{% set bgImg = item.backgroundImage ? asset('uploads/slider/' ~ item.backgroundImage) : asset('assets/images/background/weatherbg.jpg') %}
<div class="carousel-item {{ loop.first ? 'active' : '' }} h-100">
<div class="blo-hero-slide" style="background-image: url('{{ bgImg }}');">
<div class="container h-100">
<div class="row align-items-center h-100">
<div class="col-md-6 text-center text-md-start">
<h2>{{ item.getDisplayTitle() }}</h2>
{% if item.getDisplaySubtitle() %}<p class="mb-2" style="opacity:0.9;">{{ item.getDisplaySubtitle() }}</p>{% endif %}
{% if item.product is not null %}
<p class="mb-3">
<span class="price">
{% if item.product.promoPrice %}{{ item.product.promoPrice|blo_price(item.product.currency) }}{% else %}{{ item.product.price|blo_price(item.product.currency) }}{% endif %}
</span>
{% if item.product.promoPrice %}<span class="price-old">{{ item.product.price|blo_price(item.product.currency) }}</span>{% endif %}
</p>
<a href="{{ path('blo_product_show', {slug: item.product.slug}) }}" class="btn btn-light rounded-pill px-4 fw-bold shadow-sm" style="color:#2e7d32;">Je découvre</a>
{% endif %}
</div>
<div class="col-md-6 text-center d-none d-md-flex align-items-center justify-content-center h-100 py-3">
{% if firstImg %}
<img src="{{ asset('uploads/' ~ firstImg.path) }}" alt="{{ item.getDisplayTitle() }}" style="max-height: 100%; max-width: 90%; object-fit: contain; filter: drop-shadow(0 8px 16px rgba(0,0,0,0.15));">
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#heroSlider" data-bs-slide="prev"><span class="carousel-control-prev-icon"></span></button>
<button class="carousel-control-next" type="button" data-bs-target="#heroSlider" data-bs-slide="next"><span class="carousel-control-next-icon"></span></button>
</div>
</section>
{% endif %}
</div>
<div class="container py-3">
{# Offres du moment #}
{% if promoProducts|length > 0 %}
<section class="blo-section-box">
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
<h2 class="mb-0">Offres du moment</h2>
<a href="{{ path('blo_catalog') }}?promo=1" class="small">Voir tout</a>
</div>
<div class="row g-3">
{% for product in promoProducts %}
<div class="col-6 col-sm-4 col-md-3 col-lg-2">
<div class="blo-product-box">
<a href="{{ path('blo_product_show', {slug: product.slug}) }}" class="text-decoration-none text-dark d-block">
<div class="img-wrap position-relative">
<span class="badge bg-danger position-absolute top-0 start-0 rounded-pill">Promo</span>
{% set firstImage = product.images|first %}
{% if firstImage %}
<img src="{{ asset('uploads/' ~ firstImage.path) }}" alt="{{ product.title }}">
{% else %}
<i class="bi bi-image text-secondary" style="font-size: 3rem;"></i>
{% endif %}
</div>
<div class="title">{{ product.title }}</div>
<p class="price mb-0"><del>{{ product.price|blo_price(product.currency) }}</del> {{ product.promoPrice|blo_price(product.currency) }}</p>
</a>
<form action="{{ path('blo_cart_add', {productId: product.id}) }}" method="post" class="d-inline">
<button type="submit" class="blo-product-add-btn" title="Ajouter au panier"><i class="bi bi-plus-lg fs-5"></i></button>
</form>
</div>
</div>
{% endfor %}
</div>
</section>
{% endif %}
{# Nouveautés (défilement horizontal sur mobile) #}
{% if newestProducts|length > 0 %}
<section class="blo-section-box">
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
<h2 class="mb-0">Nouveautés</h2>
<a href="{{ path('blo_catalog') }}?newest=1" class="small">Voir tout</a>
</div>
<div class="blo-scroll-row d-md-none">
{% for product in newestProducts %}
<div class="blo-product-box">
<a href="{{ path('blo_product_show', {slug: product.slug}) }}" class="text-decoration-none text-dark d-block">
<div class="img-wrap">
{% set firstImage = product.images|first %}
{% if firstImage %}<img src="{{ asset('uploads/' ~ firstImage.path) }}" alt="{{ product.title }}">{% else %}<i class="bi bi-image text-secondary"></i>{% endif %}
</div>
<div class="title">{{ product.title }}</div>
<p class="price mb-0">{% if product.promoPrice %}<del>{{ product.price|blo_price(product.currency) }}</del> {{ product.promoPrice|blo_price(product.currency) }}{% else %}{{ product.price|blo_price(product.currency) }}{% endif %}</p>
</a>
<form action="{{ path('blo_cart_add', {productId: product.id}) }}" method="post" class="d-inline">
<button type="submit" class="blo-product-add-btn" title="Ajouter au panier"><i class="bi bi-plus-lg fs-5"></i></button>
</form>
</div>
{% endfor %}
</div>
<div class="row g-3 d-none d-md-flex">
{% for product in newestProducts %}
<div class="col-6 col-lg-3">
<div class="blo-product-box h-100">
<a href="{{ path('blo_product_show', {slug: product.slug}) }}" class="text-decoration-none text-dark d-block">
<div class="img-wrap">
{% set firstImage = product.images|first %}
{% if firstImage %}<img src="{{ asset('uploads/' ~ firstImage.path) }}" alt="{{ product.title }}">{% else %}<i class="bi bi-image text-secondary"></i>{% endif %}
</div>
<div class="title">{{ product.title }}</div>
<p class="price mb-0">{% if product.promoPrice %}<del>{{ product.price|blo_price(product.currency) }}</del> {{ product.promoPrice|blo_price(product.currency) }}{% else %}{{ product.price|blo_price(product.currency) }}{% endif %}</p>
</a>
<form action="{{ path('blo_cart_add', {productId: product.id}) }}" method="post" class="d-inline">
<button type="submit" class="blo-product-add-btn" title="Ajouter au panier"><i class="bi bi-plus-lg fs-5"></i></button>
</form>
</div>
</div>
{% endfor %}
</div>
</section>
{% endif %}
{# À la une #}
<section class="blo-section-box">
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
<h2 class="mb-0">À la une</h2>
<a href="{{ path('blo_catalog') }}" class="small">Voir tout</a>
</div>
<div class="row g-3">
{% for product in featuredProducts %}
<div class="col-6 col-sm-4 col-md-3 col-lg-2">
<div class="blo-product-box">
<a href="{{ path('blo_product_show', {slug: product.slug}) }}" class="text-decoration-none text-dark d-block">
<div class="img-wrap">
{% set firstImage = product.images|first %}
{% if firstImage %}<img src="{{ asset('uploads/' ~ firstImage.path) }}" alt="{{ product.title }}">{% else %}<i class="bi bi-image text-secondary"></i>{% endif %}
</div>
<div class="title">{{ product.title }}</div>
<p class="price mb-0">{% if product.promoPrice %}<del>{{ product.price|blo_price(product.currency) }}</del> {{ product.promoPrice|blo_price(product.currency) }}{% else %}{{ product.price|blo_price(product.currency) }}{% endif %}</p>
</a>
<form action="{{ path('blo_cart_add', {productId: product.id}) }}" method="post" class="d-inline">
<button type="submit" class="blo-product-add-btn" title="Ajouter au panier"><i class="bi bi-plus-lg fs-5"></i></button>
</form>
</div>
</div>
{% else %}
<div class="col-12 text-center py-4 text-muted">Aucun produit. <a href="{{ path('blo_catalog') }}">Parcourir le catalogue</a>.</div>
{% endfor %}
</div>
</section>
</div>
{% endblock %}