/**
 * Module 12 : Page boutique (archive produit)
 * Thème Storefront Child - TAMISIER MACHINES AGRICOLES
 *
 * Le thème n'utilise pas de sidebar : le filtrage par catégorie est fourni
 * par un bandeau de pastilles (inc/woocommerce-custom.php). Cette feuille
 * gère la mise en page du catalogue : en-tête, filtres, grille, pagination.
 */

/* ==========================================================================
   1. CONTENEUR
   ========================================================================== */

.post-type-archive-product .content-area,
.post-type-archive-product #primary,
.tax-product_cat .content-area,
.tax-product_cat #primary {
  width: 100% !important;
  float: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: none !important;
}

.post-type-archive-product .site-main,
.tax-product_cat .site-main {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  box-sizing: border-box;
}

/* ==========================================================================
   2. EN-TÊTE DE LA BOUTIQUE
   ========================================================================== */

/* Storefront applique text-align:center et 5.99em de padding bas ; il faut
   reprendre la main avec !important, la spécificité étant identique. */
.post-type-archive-product .woocommerce-products-header,
.tax-product_cat .woocommerce-products-header {
  text-align: left !important;
  padding: 0.5rem 0 1.25rem !important;
  margin-bottom: 1.35rem !important;
  border-bottom: 1px solid var(--agri-border-subtle, #e2e8f0);
}

/* Fil d'Ariane : Storefront l'enferme dans .col-full (1064px), ce qui le
   désaligne du contenu (1280px). On le recale et on réduit ses marges. */
.post-type-archive-product .storefront-breadcrumb,
.tax-product_cat .storefront-breadcrumb {
  margin: 0 !important;
  padding: 1.1rem 0 0 !important;
}

.post-type-archive-product .storefront-breadcrumb .col-full,
.tax-product_cat .storefront-breadcrumb .col-full {
  max-width: 1280px !important;
  margin: 0 auto !important;
  padding: 0 1.5rem !important;
  box-sizing: border-box !important;
}

.post-type-archive-product .woocommerce-products-header h1,
.tax-product_cat .woocommerce-products-header h1 {
  font-family: "Playfair Display", Georgia, serif !important;
  font-size: clamp(1.9rem, 3.2vw, 2.7rem) !important;
  font-weight: 700 !important;
  line-height: 1.15 !important;
  letter-spacing: -0.02em !important;
  color: var(--agri-anthracite-base, #1e2322) !important;
  margin: 0 0 0.5rem !important;
}

.tma-shop-subtitle {
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
  color: var(--agri-anthracite-muted, #525c59) !important;
  margin: 0 !important;
  max-width: 62ch;
}

/* ==========================================================================
   3. FILTRES PAR CATÉGORIE
   ========================================================================== */

.tma-shop-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
}

.tma-shop-cat {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none !important;
  color: var(--agri-anthracite-surface, #2b3230) !important;
  background-color: var(--agri-white, #ffffff);
  border: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: 999px;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.tma-shop-cat:hover {
  color: var(--agri-green-primary, #215833) !important;
  border-color: var(--agri-green-primary, #215833);
}

.tma-shop-cat.is-active {
  background-color: var(--agri-green-primary, #215833);
  border-color: var(--agri-green-primary, #215833);
  color: #ffffff !important;
}

.tma-shop-cat-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  background-color: rgba(0, 0, 0, 0.06);
  color: inherit;
}

.tma-shop-cat.is-active .tma-shop-cat-count {
  background-color: rgba(255, 255, 255, 0.24);
}

/* ==========================================================================
   4. BARRE D'OUTILS (compteur + tri)
   ========================================================================== */

.post-type-archive-product .storefront-sorting,
.tax-product_cat .storefront-sorting {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 0 !important;
  margin-bottom: 1.75rem !important;
  border-bottom: 1px solid var(--agri-border-subtle, #e2e8f0);
}

.post-type-archive-product .storefront-sorting::before,
.post-type-archive-product .storefront-sorting::after,
.tax-product_cat .storefront-sorting::before,
.tax-product_cat .storefront-sorting::after {
  display: none !important;
}

.post-type-archive-product .woocommerce-result-count,
.tax-product_cat .woocommerce-result-count {
  float: none !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.84rem;
  color: var(--agri-anthracite-muted, #525c59);
}

.post-type-archive-product .woocommerce-ordering,
.tax-product_cat .woocommerce-ordering {
  float: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.post-type-archive-product .woocommerce-ordering select,
.tax-product_cat .woocommerce-ordering select {
  padding: 0.45rem 0.75rem !important;
  font-size: 0.84rem;
  color: var(--agri-anthracite-base, #1e2322);
  background-color: var(--agri-white, #ffffff);
  border: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: var(--agri-radius, 4px);
  box-shadow: none;
}

/* ==========================================================================
   5. GRILLE DE PRODUITS
   ========================================================================== */

.post-type-archive-product ul.products,
.tax-product_cat ul.products {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  margin: 0 0 2.5rem !important;
  padding: 0 !important;
}

.post-type-archive-product ul.products::before,
.post-type-archive-product ul.products::after,
.tax-product_cat ul.products::before,
.tax-product_cat ul.products::after {
  display: none !important;
}

.post-type-archive-product ul.products li.product,
.tax-product_cat ul.products li.product {
  width: auto !important;
  float: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--agri-white, #ffffff);
  border: 1px solid var(--agri-border-subtle, #e2e8f0);
  border-radius: var(--agri-radius, 4px);
  text-align: left;
}

.post-type-archive-product ul.products li.product:hover,
.tax-product_cat ul.products li.product:hover {
  border-color: var(--agri-green-light, #2e7a47);
  box-shadow: 0 12px 20px -8px rgba(15, 23, 42, 0.18);
  transform: translateY(-2px);
}

/* Visuel : format constant pour aligner toutes les cartes */
.post-type-archive-product ul.products li.product > a,
.tax-product_cat ul.products li.product > a {
  display: block;
}

.post-type-archive-product ul.products li.product img,
.tax-product_cat ul.products li.product img {
  width: 100% !important;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  margin: 0 !important;
  border-radius: 0 !important;
  background-color: var(--agri-bg-neutral, #f8fafc);
}

.post-type-archive-product ul.products li.product .woocommerce-loop-product__title,
.tax-product_cat ul.products li.product .woocommerce-loop-product__title {
  padding: 0.85rem 1rem 0.3rem !important;
  margin: 0 !important;
  font-size: 0.95rem !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  letter-spacing: 0 !important;
  color: var(--agri-anthracite-base, #1e2322) !important;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

.post-type-archive-product ul.products li.product .price,
.tax-product_cat ul.products li.product .price {
  padding: 0 1rem !important;
  margin: auto 0 0.85rem !important;
  display: block;
  font-size: 1.1rem !important;
}

.post-type-archive-product ul.products li.product .button,
.tax-product_cat ul.products li.product .button {
  margin: 0 1rem 1rem !important;
  padding: 0.6rem 0.9rem !important;
  font-size: 0.78rem !important;
  text-align: center;
}

.post-type-archive-product ul.products li.product .onsale,
.tax-product_cat ul.products li.product .onsale {
  top: 0.6rem;
  right: 0.6rem;
  left: auto;
  border-radius: var(--agri-radius, 4px) !important;
  padding: 0.3rem 0.6rem !important;
  font-size: 0.72rem !important;
  line-height: 1.2 !important;
  min-height: 0 !important;
  min-width: 0 !important;
}

/* ==========================================================================
   6. PAGINATION
   ========================================================================== */

.post-type-archive-product .woocommerce-pagination,
.tax-product_cat .woocommerce-pagination {
  text-align: center;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}

.post-type-archive-product .woocommerce-pagination ul.page-numbers,
.tax-product_cat .woocommerce-pagination ul.page-numbers {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  border: 0 !important;
  margin: 0 !important;
}

.post-type-archive-product .woocommerce-pagination .page-numbers li,
.tax-product_cat .woocommerce-pagination .page-numbers li {
  border: 0 !important;
}

.post-type-archive-product .woocommerce-pagination .page-numbers li .page-numbers,
.tax-product_cat .woocommerce-pagination .page-numbers li .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--agri-anthracite-base, #1e2322);
  background-color: var(--agri-white, #ffffff);
  border: 1px solid var(--agri-border-subtle, #e2e8f0) !important;
  border-radius: var(--agri-radius, 4px);
  text-decoration: none;
}

.post-type-archive-product .woocommerce-pagination .page-numbers li .page-numbers.current,
.tax-product_cat .woocommerce-pagination .page-numbers li .page-numbers.current {
  color: #ffffff;
  background-color: var(--agri-green-primary, #215833);
  border-color: var(--agri-green-primary, #215833) !important;
}

.post-type-archive-product .woocommerce-pagination .page-numbers li a.page-numbers:hover,
.tax-product_cat .woocommerce-pagination .page-numbers li a.page-numbers:hover {
  border-color: var(--agri-green-primary, #215833) !important;
  color: var(--agri-green-primary, #1e2322);
}

/* ==========================================================================
   7. RESPONSIVE
   ========================================================================== */

@media (max-width: 1100px) {
  .post-type-archive-product ul.products,
  .tax-product_cat ul.products {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .post-type-archive-product .site-main,
  .tax-product_cat .site-main {
    padding: 0 1rem 3rem;
  }

  .post-type-archive-product ul.products,
  .tax-product_cat ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
  }

  .post-type-archive-product ul.products li.product .woocommerce-loop-product__title,
  .tax-product_cat ul.products li.product .woocommerce-loop-product__title {
    font-size: 0.88rem !important;
    padding: 0.7rem 0.8rem 0.25rem !important;
  }

  .post-type-archive-product ul.products li.product .price,
  .tax-product_cat ul.products li.product .price {
    padding: 0 0.8rem !important;
    font-size: 1rem !important;
  }

  .post-type-archive-product ul.products li.product .button,
  .tax-product_cat ul.products li.product .button {
    margin: 0 0.8rem 0.8rem !important;
    font-size: 0.72rem !important;
  }
}

@media (max-width: 460px) {
  .post-type-archive-product .woocommerce-products-header,
  .tax-product_cat .woocommerce-products-header {
    padding: 1.75rem 0 1rem;
  }

  .tma-shop-cat {
    font-size: 0.78rem;
    padding: 0.45rem 0.75rem;
  }
}
