/* =========================================================
   CPM CATALOGO PRODOTTI — RESTYLING
   Compatibile con:
   - archive-prodotto.php
   - taxonomy-categoria_prodotto.php
   - single-prodotto.php
   ========================================================= */

:root {
  --cpm-ink: #102b3a;
  --cpm-blue: #1262c4;
  --cpm-blue-dark: #0a4d9e;
  --cpm-soft: #f4fafc;
  --cpm-line: rgba(16, 43, 58, .14);
  --cpm-text: rgba(16, 43, 58, .74);
}

/* =========================================================
   BASE
   ========================================================= */

.post-type-archive-prodotto .container.main-content,
.tax-categoria_prodotto .container.main-content {
  width: 100%;
  max-width: 1540px;
  padding-top: 0;
  background: #fff;
}

.single-prodotto .container.main-content {
  max-width: 1280px;
}

.post-type-archive-prodotto #ajax-content-wrap,
.tax-categoria_prodotto #ajax-content-wrap {
  background: #fff;
}

/* =========================================================
   HERO ARCHIVIO / CATEGORIA
   Full width, blu CPM
   ========================================================= */

.post-type-archive-prodotto #ajax-content-wrap > .container.main-content > h1,
.tax-categoria_prodotto #ajax-content-wrap > .container.main-content > h1 {
  position: relative;
  left: 50%;

  width: 100vw;
  max-width: none;

  margin: 0 0 64px !important;
  margin-left: -50vw !important;
  padding: 92px max(56px, calc((100vw - 1420px) / 2)) 82px;

  overflow: hidden;

  text-align: left !important;

  font-size: clamp(48px, 5.8vw, 86px);
  line-height: .94;
  letter-spacing: -.055em;
  font-weight: 400;

  color: #fff;

  background:
    radial-gradient(circle at 87% 18%, rgba(255,255,255,.10), transparent 24%),
    linear-gradient(135deg, #0c4fa7 0%, #083f87 100%);

  border-radius: 0;
}

/* Pattern circolare chiaro sul fondo blu */

.post-type-archive-prodotto #ajax-content-wrap > .container.main-content > h1::before,
.tax-categoria_prodotto #ajax-content-wrap > .container.main-content > h1::before {
  content: "";
  position: absolute;
  right: 8%;
  top: -82px;

  width: 230px;
  height: 230px;

  border: 1.5px solid rgba(255,255,255,.18);
  border-radius: 50%;
}

.post-type-archive-prodotto #ajax-content-wrap > .container.main-content > h1::after,
.tax-categoria_prodotto #ajax-content-wrap > .container.main-content > h1::after {
  content: "";
  position: absolute;
  right: 22%;
  bottom: -43px;

  width: 98px;
  height: 98px;

  border: 1.5px solid rgba(255,255,255,.20);
  border-radius: 50%;
}

/* =========================================================
   LAYOUT ARCHIVIO
   ========================================================= */

.archive-layout {
  display: flex;
  align-items: flex-start;
  gap: 64px;

  padding: 0 20px 100px;
}

/* =========================================================
   SIDEBAR / FILTRI
   ========================================================= */

.filtro-categorie {
  position: sticky;
  top: 125px;

  flex: 0 0 270px;
  width: 270px;

  padding: 28px 24px 24px;

  background: linear-gradient(180deg, #f7fbfd 0%, #fff 100%);
  border: 1px solid rgba(18, 98, 196, .14);
  border-radius: 18px;

  box-shadow: 0 14px 34px rgba(16, 43, 58, .05);
}

.filtro-categorie h3 {
  margin: 0 0 20px;
  padding: 0 0 15px;

  font-size: 11px;
  line-height: 1.4;
  letter-spacing: .17em;
  text-transform: uppercase;
  font-weight: 600;

  color: var(--cpm-ink);

  border-bottom: 1px solid var(--cpm-line);
}

.filtro-categorie ul {
  margin: 0;
  padding: 0;
}

.filtro-categorie li {
  list-style: none !important;
  margin: 0;
  padding: 0;
}

.filtro-categorie a {
  position: relative;

  display: block;
  padding: 12px 34px 12px 0;

  border-bottom: 1px solid rgba(16, 43, 58, .09);

  color: rgba(16, 43, 58, .74);
  text-decoration: none;

  font-size: 15px;
  line-height: 1.4;

  transition:
    color .2s ease,
    padding-left .2s ease,
    border-color .2s ease;
}

.filtro-categorie li:last-child a {
  border-bottom: 0;
}

.filtro-categorie a::after {
  content: "→";
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);

  color: rgba(18, 98, 196, .48);

  transition:
    transform .2s ease,
    color .2s ease;
}

.filtro-categorie a:hover {
  padding-left: 6px;
  background: transparent;
  color: var(--cpm-blue);
}

.filtro-categorie a:hover::after {
  transform: translate(4px, -50%);
  color: var(--cpm-blue);
}

.filtro-categorie a.current-cat {
  padding-left: 12px;

  color: #fff;
  font-weight: 500;

  background: linear-gradient(135deg, var(--cpm-blue), var(--cpm-blue-dark));
  border: 0;
  border-radius: 8px;
}

.filtro-categorie a.current-cat::after {
  right: 12px;
  color: #fff;
}

/* =========================================================
   GRIGLIA PRODOTTI
   ========================================================= */

.prodotti-grid {
  flex: 1;
  min-width: 0;

  display: flex;
  flex-wrap: wrap;
  gap: 38px 28px;
}

.prodotti-grid .prodotto-card {
  flex: 0 0 calc(33.333% - 18.7px);
  max-width: calc(33.333% - 18.7px);

  min-width: 0;
}

.prodotti-grid .prodotto-card a {
  display: block;
  height: 100%;

  color: var(--cpm-ink);
  text-decoration: none;
}

/* Immagine: più editoriale, meno "box ecommerce" */

.prodotti-grid .prodotto-card img,
.prodotti-grid .prodotto-card > a > div:first-child {
  display: block;

  width: 100%;
  height: 260px;

  object-fit: contain;

  padding: 24px;

  background: #f7fbfd;
  border: 1px solid rgba(18,98,196,.08);
  border-radius: 14px;

  transition:
    transform .35s ease,
    box-shadow .35s ease;
}

.prodotti-grid .prodotto-card:hover img {
  transform: translateY(-5px);
  box-shadow: 0 18px 34px rgba(16, 43, 58, .09);
}

.prodotti-grid .prodotto-card h3 {
  margin: 19px 0 7px;

  font-size: 21px;
  line-height: 1.18;
  letter-spacing: -.025em;
  font-weight: 400;

  color: var(--cpm-ink);
}

.prodotti-grid .prodotto-card .codice {
  margin: 0;

  font-size: 11px;
  line-height: 1.4;
  letter-spacing: .12em;
  text-transform: uppercase;

  color: rgba(16, 43, 58, .48);
}

/* =========================================================
   TOGGLE FILTRI MOBILE
   ========================================================= */

.toggle-filtri {
  display: none;

  width: 100%;
  margin: 0 0 24px;
  padding: 14px 18px;

  border: 0;
  border-radius: 10px;

  background: linear-gradient(135deg, var(--cpm-blue), var(--cpm-blue-dark));
  color: #fff;

  font-size: 13px;
  line-height: 1.2;
  letter-spacing: .10em;
  text-transform: uppercase;

  cursor: pointer;
}

/* =========================================================
   SINGLE — HEADER
   ========================================================= */

.product-header-bar {
  position: relative;
  overflow: hidden;

  width: 100%;
  margin: 0 0 70px;
  padding: 76px 0 58px;

  color: #fff;

  background:
    radial-gradient(circle at 85% 18%, rgba(255,255,255,.12), transparent 22%),
    linear-gradient(135deg, var(--cpm-blue) 0%, var(--cpm-blue-dark) 100%);
}

.product-header-bar::after {
  content: "";
  position: absolute;
  right: 8%;
  top: -85px;

  width: 240px;
  height: 240px;

  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
}

.product-header-inner {
  position: relative;
  z-index: 2;

  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.product-header-bar .product-title {
  max-width: 900px;
  margin: 0 0 18px;

  color: #fff;

  font-size: clamp(42px, 5vw, 72px);
  line-height: .97;
  letter-spacing: -.05em;
  font-weight: 400;
}

.product-header-bar .breadcrumb {
  margin: 0;
  padding: 0;

  color: rgba(255,255,255,.68);

  font-size: 13px;
  line-height: 1.5;
}

.product-header-bar .breadcrumb a {
  color: rgba(255,255,255,.84);
  text-decoration: none;
}

.product-header-bar .breadcrumb a:hover {
  color: #fff;
}

.product-header-bar .breadcrumb .cat-root {
  color: #fff;
  font-weight: 600;
}

/* =========================================================
   SINGLE — CORPO PRODOTTO
   ========================================================= */

.prodotto-container {
  display: flex !important;
  gap: 80px !important;
  flex-wrap: wrap !important;
  align-items: flex-start !important;
}

.prodotto-img-col {
  flex: 1 !important;
  min-width: 300px !important;
  align-items: stretch !important;
}

.prodotto-hero {
  width: 100%;
  padding: 36px;

  background: linear-gradient(145deg,#f7fbfd,#eef6fa);
  border-radius: 18px;
}

.prodotto-hero img {
  display: block;

  width: 100% !important;
  max-width: 100% !important;
  height: 520px !important;

  object-fit: contain;

  background: transparent !important;
}

.prodotto-info {
  flex: 1 !important;
  min-width: 300px !important;
  padding-top: 12px;
}

.prodotto-info h2 {
  margin: 0 0 26px;

  font-size: clamp(38px, 4vw, 58px);
  line-height: .98;
  letter-spacing: -.045em;
  font-weight: 400;

  color: var(--cpm-ink);
}

.prodotto-info > p {
  margin: 0 0 8px;
  color: var(--cpm-text);
}

.prodotto-info > p strong {
  color: var(--cpm-ink);
  font-weight: 600;
}

.prodotto-info .descrizione {
  margin-top: 30px;
  padding-top: 28px;

  border-top: 1px solid var(--cpm-line);

  color: var(--cpm-text);
}

.prodotto-info .descrizione p {
  line-height: 1.75;
}

/* Scheda tecnica */

.prodotto-info a[href$=".pdf"] {
  display: inline-flex;
  align-items: center;
  gap: 10px;

  margin-top: 18px;

  color: var(--cpm-blue);
  text-decoration: none;
  font-weight: 500;
}

.prodotto-info a[href$=".pdf"]::after {
  content: "↓";
}

/* CTA Richiedi info */

.btn-richiedi-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  margin-top: 22px;
  padding: 14px 24px;

  border-radius: 999px;

  background: linear-gradient(135deg, var(--cpm-blue), var(--cpm-blue-dark));
  color: #fff !important;

  text-decoration: none;
  font-size: 14px;
  font-weight: 500;

  transition:
    transform .2s ease,
    box-shadow .2s ease;
}

.btn-richiedi-info:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(18, 98, 196, .22);
}

/* =========================================================
   PRODOTTI SIMILI
   ========================================================= */

.prodotti-simili-wrapper {
  width: 100% !important;
  max-width: 1200px !important;
  margin: 105px auto 80px !important;
  padding-top: 62px;

  border-top: 1px solid var(--cpm-line);
}

.prodotti-simili-wrapper h2 {
  margin: 0 0 42px;

  text-align: left;

  font-size: clamp(38px, 4.6vw, 62px);
  line-height: 1;
  letter-spacing: -.045em;
  font-weight: 400;

  color: var(--cpm-ink);
}

.prodotti-simili-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
}

.prodotti-simili-grid .prodotto-card {
  flex: 0 0 calc(25% - 22.5px);
  max-width: calc(25% - 22.5px);
}

.prodotti-simili-grid .prodotto-card a {
  color: var(--cpm-ink);
  text-decoration: none;
}

.prodotti-simili-grid .prodotto-card img,
.prodotti-simili-grid .prodotto-card > a > div {
  display: block;

  width: 100%;
  height: 210px;

  padding: 22px;

  object-fit: contain;

  background: linear-gradient(145deg,#f7fbfd,#eef6fa);
  border-radius: 12px;

  transition: transform .3s ease;
}

.prodotti-simili-grid .prodotto-card:hover img {
  transform: translateY(-4px);
}

.prodotti-simili-grid .prodotto-card p {
  margin: 16px 0 0;

  font-size: 17px;
  line-height: 1.3;

  color: var(--cpm-ink);
}

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 1024px) {

  .archive-layout {
    gap: 34px;
  }

  .filtro-categorie {
    flex-basis: 230px;
    width: 230px;
  }

  .prodotti-grid .prodotto-card {
    flex: 0 0 calc(50% - 14px);
    max-width: calc(50% - 14px);
  }

  .prodotti-simili-grid .prodotto-card {
    flex: 0 0 calc(50% - 15px);
    max-width: calc(50% - 15px);
  }

  .prodotto-container {
    gap: 50px !important;
  }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 768px) {

  .post-type-archive-prodotto #ajax-content-wrap > .container.main-content > h1,
  .tax-categoria_prodotto #ajax-content-wrap > .container.main-content > h1 {
    left: 50%;
    width: 100vw;
    margin-left: -50vw !important;
    margin-bottom: 34px !important;
    padding: 58px 24px 54px;

    font-size: 44px;

    border-radius: 0;
  }

  .archive-layout {
    flex-direction: column;
    gap: 26px;
    padding-bottom: 70px;
  }

  .toggle-filtri {
    display: block;
  }

  .filtro-categorie {
    position: static;

    display: none;

    width: 100%;
    flex-basis: auto;

    margin: 0;
  }

  .filtro-categorie.active {
    display: block;
  }

  .prodotti-grid {
    width: 100%;
    gap: 34px;
  }

  .prodotti-grid .prodotto-card {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .prodotti-grid .prodotto-card img,
  .prodotti-grid .prodotto-card > a > div:first-child {
    height: 290px;
  }

  .product-header-bar {
    margin-bottom: 46px;
    padding: 54px 0 42px;
  }

  .product-header-bar .product-title {
    font-size: 42px;
  }

  .prodotto-container {
    display: block !important;
  }

  .prodotto-img-col,
  .prodotto-info {
    width: 100%;
    min-width: 100% !important;
  }

  .prodotto-info {
    margin-top: 42px;
  }

  .prodotto-hero {
    padding: 24px;
  }

  .prodotto-hero img {
    height: 390px !important;
  }

  .prodotti-simili-wrapper {
    margin-top: 78px !important;
    padding-top: 50px;
  }

  .prodotti-simili-grid .prodotto-card {
    flex: 0 0 100%;
    max-width: 100%;
  }
}


/* =========================================================
   V3 - CORREZIONI LARGHEZZA / ALLINEAMENTO
   ========================================================= */

/* Il container Salient dell'archivio deve sfruttare davvero la pagina */
.post-type-archive-prodotto #ajax-content-wrap > .container.main-content,
.tax-categoria_prodotto #ajax-content-wrap > .container.main-content {
  width: 100% !important;
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Hero full width, ma contenuto del titolo allineato alla larghezza catalogo */
.post-type-archive-prodotto #ajax-content-wrap > .container.main-content > h1,
.tax-categoria_prodotto #ajax-content-wrap > .container.main-content > h1 {
  left: auto !important;
  width: 100% !important;
  margin-left: 0 !important;

  padding-left: max(56px, calc((100vw - 1540px) / 2)) !important;
  padding-right: max(56px, calc((100vw - 1540px) / 2)) !important;
}

/* Catalogo largo e centrato */
.post-type-archive-prodotto .toggle-filtri,
.tax-categoria_prodotto .toggle-filtri,
.post-type-archive-prodotto .archive-layout,
.tax-categoria_prodotto .archive-layout {
  width: calc(100% - 80px);
  max-width: 1540px;
  margin-left: auto;
  margin-right: auto;
}

.post-type-archive-prodotto .archive-layout,
.tax-categoria_prodotto .archive-layout {
  padding-left: 0;
  padding-right: 0;
}

/* Sidebar leggermente più compatta per lasciare spazio ai prodotti */
.post-type-archive-prodotto .filtro-categorie,
.tax-categoria_prodotto .filtro-categorie {
  flex: 0 0 245px;
  width: 245px;
}

/* Griglia: tre colonne che sfruttano tutto lo spazio disponibile */
.post-type-archive-prodotto .prodotti-grid,
.tax-categoria_prodotto .prodotti-grid {
  flex: 1 1 0;
  width: auto;
}

/* Card senza fondino celeste */
.prodotti-grid .prodotto-card img,
.prodotti-grid .prodotto-card > a > div:first-child {
  background: #fff !important;
  border: 1px solid rgba(16,43,58,.08);
}

/* Anche la card non deve ereditare eventuali fondi del tema */
.prodotti-grid .prodotto-card,
.prodotti-grid .prodotto-card a {
  background: transparent !important;
}

/* Immagini un po' più grandi ora che il catalogo è più largo */
.prodotti-grid .prodotto-card img,
.prodotti-grid .prodotto-card > a > div:first-child {
  height: 285px;
}

@media (max-width: 1024px) {
  .post-type-archive-prodotto .toggle-filtri,
  .tax-categoria_prodotto .toggle-filtri,
  .post-type-archive-prodotto .archive-layout,
  .tax-categoria_prodotto .archive-layout {
    width: calc(100% - 48px);
  }

  .post-type-archive-prodotto #ajax-content-wrap > .container.main-content > h1,
  .tax-categoria_prodotto #ajax-content-wrap > .container.main-content > h1 {
    padding-left: 24px !important;
    padding-right: 24px !important;
  }
}

@media (max-width: 768px) {
  .post-type-archive-prodotto .toggle-filtri,
  .tax-categoria_prodotto .toggle-filtri,
  .post-type-archive-prodotto .archive-layout,
  .tax-categoria_prodotto .archive-layout {
    width: calc(100% - 40px);
  }

  .post-type-archive-prodotto #ajax-content-wrap > .container.main-content > h1,
  .tax-categoria_prodotto #ajax-content-wrap > .container.main-content > h1 {
    width: 100% !important;
    left: auto !important;
    margin-left: 0 !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}
/* Titolo archivio centrato */
.post-type-archive-prodotto #ajax-content-wrap > .container.main-content > h1,
.tax-categoria_prodotto #ajax-content-wrap > .container.main-content > h1 {
    text-align: center !important;
}

/* =========================================================
   ARCHIVIO - 3 PRODOTTI PER RIGA
   ========================================================= */

.prodotti-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 40px 30px;
}

.prodotti-grid .prodotto-card {
    flex: 0 0 calc((100% - 60px) / 3) !important;
    width: calc((100% - 60px) / 3) !important;
    max-width: calc((100% - 60px) / 3) !important;
}


/* TABLET - 2 prodotti */
@media (max-width: 1024px) {

    .prodotti-grid .prodotto-card {
        flex: 0 0 calc((100% - 30px) / 2) !important;
        width: calc((100% - 30px) / 2) !important;
        max-width: calc((100% - 30px) / 2) !important;
    }

}


/* MOBILE - 1 prodotto */
@media (max-width: 768px) {

    .prodotti-grid .prodotto-card {
        flex: 0 0 100% !important;
        width: 100% !important;
        max-width: 100% !important;
    }

}