/* ============================
   STILI SOLO PER CATEGORIE PRODOTTO
   Wrapper principale: .product-categories-archive
   ============================ */

/* Mapping degli stili esistenti verso i selettori reali dello shop */
body.woocommerce-shop ul.products,
body.post-type-archive-product ul.products {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    margin: 0 auto;
    padding: 0 !important;
    width: 100%;
    box-sizing: border-box;
    font-family: "Nunito", sans-serif;
}

body.woocommerce-shop ul.products li.product-category,
body.post-type-archive-product ul.products li.product-category {
  background: #f9f9f9 !important;
  border: none !important;
  border-radius: 8px !important;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1) !important;
  overflow: hidden !important;
  position: relative;
  padding: 0 !important; /* to match product cards (inner padding per elementi) */
  transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

/* Hover card */
.product-categories-archive .product-category:hover {
    transform: translateY(-5px) !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2) !important;
}

/* Immagine categoria */
.product-categories-archive .product-category img {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  transition: transform 0.3s ease, opacity 0.3s ease !important;
}

.product-categories-archive .product-category:hover img {
  transform: scale(1.05) !important;
  opacity: 0.9 !important;
}

/* Titolo categoria */
.product-categories-archive .woocommerce-loop-category__title {
    font-family: 'Nunito', sans-serif;
    font-size: 1.5rem !important; /* match prodotti */
    font-weight: 700 !important;
    color: #333 !important;
    margin: 0.75rem 0 0.35rem !important;
    padding: 0 7px !important;
    text-align: center;
    line-height: 1.3;
}

.product-categories-archive .woocommerce-loop-category__title a {
    color: #0073aa;
    text-decoration: none;
    display: inline-block;
    transition: color 0.3s ease;
}

.product-categories-archive .woocommerce-loop-category__title a:hover {
    color: #005177;
}

/* Nasconde il count accanto al titolo categoria */
body.woocommerce-shop ul.products li.product-category mark.count,
body.post-type-archive-product ul.products li.product-category mark.count,
.woocommerce-loop-category__title mark.count { display: none !important; }


/* Forza margini descrizione */
.product-categories-archive .product-category .entry-excerpt {
  padding: 0 7px !important;
  margin: 0 0 0.75rem !important;
  font-size: 0.9rem !important;
  color: #555 !important;
  line-height: 1.5 !important;
  text-align: justify !important;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ======================================
   Override entry-excerpt per sicurezza
   Copre regole globali con !important
   ====================================== */
.product-categories-archive .products.elementor-grid li.product .entry-excerpt {
    text-align: center !important;
    margin-bottom: 24px !important;
    --margin-block-end: 24px !important;
}

/* ============================
   RESPONSIVE
   ============================ */

/* Override layout colonne con gap coerente */
:root { --cat-gap:20px; }
body.woocommerce-shop ul.products,
body.post-type-archive-product ul.products {
  gap: var(--cat-gap) !important;
}
/* Desktop 4 colonne */
body.woocommerce-shop ul.products li.product-category,
body.post-type-archive-product ul.products li.product-category {
  flex: 0 1 calc((100% - 3 * var(--cat-gap)) / 4) !important;
}
/* Tablet <=1024px: 2 colonne */
@media (max-width:1024px){
  body.woocommerce-shop ul.products li.product-category,
  body.post-type-archive-product ul.products li.product-category {
    flex: 0 1 calc((100% - var(--cat-gap)) / 2) !important;
  }
}
/* Mobile <=600px: 1 colonna con padding laterale */
@media (max-width:600px){
  body.woocommerce-shop ul.products,
  body.post-type-archive-product ul.products { padding:0 18px !important; }
  body.woocommerce-shop ul.products li.product-category,
  body.post-type-archive-product ul.products li.product-category { flex:0 0 100% !important; }
}
/* Fix eventuali override tema che impongono width:100% sul tablet */
@media (min-width:601px) and (max-width:1024px){
  body.woocommerce-shop ul.products li.product-category[class],
  body.post-type-archive-product ul.products li.product-category[class] { width:auto !important; }
}

/* Disattivo vecchie regole di layout specifiche non più necessarie (override) */
.product-categories-archive .product-category { /* layout gestito sopra */ }

/* Rimuovi stili precedenti confliggenti (vecchia padding/margini) */
.product-categories-archive .product-category { padding: 0 !important; border: none !important; box-shadow: none !important; }
.product-categories-archive .product-category .woocommerce-loop-category__title { margin: 0.75rem 0 0.35rem !important; }

/* Responsive: manteniamo le regole esistenti, ma uniformiamo gap usando margin-bottom */
body.woocommerce-shop ul.products li.product-category,
body.post-type-archive-product ul.products li.product-category { margin-bottom: 24px !important; }
@media (max-width:1024px){
  body.woocommerce-shop ul.products li.product-category,
  body.post-type-archive-product ul.products li.product-category { margin-bottom: 35px !important; }
}
@media (max-width:600px){
  body.woocommerce-shop ul.products li.product-category,
  body.post-type-archive-product ul.products li.product-category { margin-bottom: 30px !important; }
}
