/*
 * Nomos Partecipate - stile classico dello Speciale Partecipate
 * Le regole sono volutamente circoscritte al modulo per non interferire
 * con il template Joomla 6.
 */
.nomos-partecipate {
  --nomos-primary: #003d6a;
  --nomos-renewed: #4a9bc5;
  width: 100%;
  font-family: inherit;
}


/* T4 / JA Purity IV: il titolo Joomla del modulo non fa parte dello Speciale originale.
   Viene nascosto solo per il wrapper che contiene questo modulo. */
.t4-mod-wrap:has(.nomos-partecipate) > .section-inner > .container:first-child {
  display: none !important;
}

.t4-mod-wrap:has(.nomos-partecipate) {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

html.nomos-partecipate-popup-open,
body.nomos-partecipate-popup-open {
  overflow: hidden !important;
}

.nomos-partecipate,
.nomos-partecipate * {
  box-sizing: border-box;
}

.nomos-partecipate .nomos-partecipate-module {
  width: 100%;
  margin: 0 0 28px;
  padding: 0;
}

.nomos-partecipate .module-inner,
.nomos-partecipate .module-ct,
.nomos-partecipate .custom {
  width: 100%;
  margin: 0;
  padding: 0;
}

/* Titoli: riproducono il linguaggio del vecchio T3 module-title */
.nomos-partecipate .module-title.titolo_monitoraggio.nomos-partecipate-title {
  display: block;
  position: relative;
  margin: 0;
  padding: 0 0 10px;
  border: 0;
  border-bottom: 2px solid var(--nomos-primary);
  background: transparent;
  color: var(--nomos-primary);
  font-family: inherit;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
}

.nomos-partecipate .module-title.titolo_monitoraggio.nomos-partecipate-title > span {
  display: inline-block;
}

/* Nel sorgente originale c'era un paragrafo vuoto tra titolo e tabella */
.nomos-partecipate .nomos-partecipate-spacer {
  height: 18px;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 18px;
}

.nomos-partecipate a.jcepopup {
  color: var(--nomos-primary) !important;
  text-decoration: none !important;
  cursor: zoom-in;
}

.nomos-partecipate a.jcepopup:hover,
.nomos-partecipate a.jcepopup:focus {
  color: var(--nomos-primary) !important;
  text-decoration: none !important;
}


/* Reset mirato contro gli stili tabella di Bootstrap 5 / T4 */
.nomos-partecipate table.partecipate-grid1 > :not(caption) > * > *,
.nomos-partecipate table.partecipate-grid > :not(caption) > * > * {
  box-shadow: none !important;
  color: inherit;
}

.nomos-partecipate table.partecipate-grid1 td:not(.rinnovata),
.nomos-partecipate table.partecipate-grid td:not(.rinnovata) {
  background-color: #ffffff !important;
}

/* =========================================================
   I E II LIVELLO - stessa tabella dell'originale
   ========================================================= */
.nomos-partecipate table.partecipate-grid1 {
  width: 100% !important;
  margin: 0 !important;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  table-layout: fixed;
  border: 1px solid #ccc !important;
  background: #fff;
}

.nomos-partecipate table.partecipate-grid1 > tbody > tr > td {
  position: relative;
  border: 1px solid #ccc !important;
  padding: 8px;
  text-align: center !important;
  vertical-align: middle !important;
  background: #fff;
  box-shadow: none;
}

/* I livello - celle con loghi */
.nomos-partecipate table.partecipate-grid1-loghi > tbody > tr > td {
  width: 20%;
  height: 112px;
}

.nomos-partecipate table.partecipate-grid1-loghi a.jcepopup {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 94px;
}

.nomos-partecipate table.partecipate-grid1 img {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 90px !important;
  margin: 0 auto !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  object-fit: contain;
}

/* II livello - testo, come nel modulo originale */
.nomos-partecipate table.partecipate-grid1-testo > tbody > tr > td {
  width: 25%;
  height: 80px;
  padding: 12px;
  vertical-align: top !important;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.35;
}

.nomos-partecipate table.partecipate-grid1-testo td > strong {
  display: block;
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.nomos-partecipate .capogruppo {
  margin-top: 4px;
  color: #666;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
}

.nomos-partecipate .capogruppo strong {
  font-weight: 700;
}

/* =========================================================
   III LIVELLO - classe originale partecipate-grid
   ========================================================= */
.nomos-partecipate table.partecipate-grid {
  width: 100% !important;
  margin: 0 !important;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  table-layout: fixed;
  font-family: Arial, Helvetica, sans-serif;
  border: 1px solid #ddd !important;
  background: #fff;
}

.nomos-partecipate table.partecipate-grid > tbody > tr > td {
  position: relative;
  width: 33.333333%;
  height: 80px;
  padding: 12px;
  border: 1px solid #e6e6e6 !important;
  text-align: center !important;
  vertical-align: top !important;
  background: #fff;
  box-shadow: none;
}

.nomos-partecipate table.partecipate-grid td > strong {
  display: block;
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

/* =========================================================
   STATO RINNOVATA - stesso trattamento del CSS originale
   ========================================================= */
.nomos-partecipate table.partecipate-grid1 td.rinnovata,
.nomos-partecipate table.partecipate-grid td.rinnovata {
  position: relative;
  overflow: hidden;
  padding: 28px 15px 15px !important;
  background: #eef7fc !important;
  border: 2px solid var(--nomos-renewed) !important;
  box-shadow: 0 3px 12px rgba(74, 155, 197, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.nomos-partecipate table.partecipate-grid1 td.rinnovata:hover,
.nomos-partecipate table.partecipate-grid td.rinnovata:hover {
  z-index: 2;
  background: #e1f1f9 !important;
  box-shadow: 0 6px 18px rgba(74, 155, 197, 0.28);
  transform: translateY(-3px);
}

/* Badge generato dal modulo. È equivalente al ::before originale,
   ma permette di cambiare il testo dal backend. */
.nomos-partecipate .nomos-partecipate-badge {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 3;
  padding: 5px 10px;
  background: var(--nomos-renewed);
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .4px;
  text-transform: uppercase;
  border-radius: 0 0 0 8px;
  pointer-events: none;
}

/* Nota sotto il I livello: stesso peso visivo dell'originale */
.nomos-partecipate .nomos-partecipate-note {
  margin: 13px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.45;
  text-align: left;
}

/* =========================================================
   POPUP - comportamento equivalente a quello del sorgente originale
   ========================================================= */
#partecipate-image-dialog {
  position: fixed !important;
  inset: 0 !important;
  margin: auto !important;
  width: fit-content !important;
  max-width: 94vw !important;
  max-height: 92vh !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 6px !important;
  background: transparent !important;
  overflow: visible !important;
  box-shadow: none !important;
}

#partecipate-image-dialog[open] {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#partecipate-image-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82) !important;
}

.partecipate-dialog-content {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  max-width: 94vw !important;
  max-height: 92vh !important;
}

.partecipate-dialog-image {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: 94vw !important;
  max-height: 88vh !important;
  object-fit: contain !important;
  background: #fff !important;
  border-radius: 5px !important;
  box-shadow: 0 8px 35px rgba(0, 0, 0, 0.55) !important;
}

.partecipate-dialog-close {
  position: absolute !important;
  top: -20px !important;
  right: -20px !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 46px !important;
  height: 46px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: #fff !important;
  color: #111 !important;
  font-family: Arial, sans-serif !important;
  font-size: 34px !important;
  font-weight: 400 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.45) !important;
}

.partecipate-dialog-close:hover,
.partecipate-dialog-close:focus {
  background: #eee !important;
  outline: 2px solid #fff !important;
  outline-offset: 3px !important;
}

/* =========================================================
   RESPONSIVE - mantiene la resa originale su desktop
   ========================================================= */
@media (max-width: 1024px) {
  .nomos-partecipate table.partecipate-grid1,
  .nomos-partecipate table.partecipate-grid {
    display: block !important;
    border: 0 !important;
  }

  .nomos-partecipate table.partecipate-grid1 > tbody,
  .nomos-partecipate table.partecipate-grid > tbody {
    display: grid !important;
    gap: 8px;
  }

  .nomos-partecipate table.partecipate-grid1-loghi > tbody {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .nomos-partecipate table.partecipate-grid1-testo > tbody,
  .nomos-partecipate table.partecipate-grid > tbody {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nomos-partecipate table.partecipate-grid1 > tbody > tr,
  .nomos-partecipate table.partecipate-grid > tbody > tr {
    display: contents !important;
  }

  .nomos-partecipate table.partecipate-grid1 > tbody > tr > td,
  .nomos-partecipate table.partecipate-grid > tbody > tr > td {
    display: block !important;
    width: 100% !important;
    height: auto;
    min-height: 80px;
  }

  .nomos-partecipate table.partecipate-grid1-loghi > tbody > tr > td {
    min-height: 112px;
  }
}

@media (max-width: 600px) {
  .nomos-partecipate .module-title.titolo_monitoraggio.nomos-partecipate-title {
    font-size: 21px;
  }

  .nomos-partecipate .nomos-partecipate-note {
    font-size: 16px;
  }

  .nomos-partecipate table.partecipate-grid1-loghi > tbody,
  .nomos-partecipate table.partecipate-grid1-testo > tbody,
  .nomos-partecipate table.partecipate-grid > tbody {
    grid-template-columns: 1fr;
  }

  #partecipate-image-dialog,
  .partecipate-dialog-content {
    max-width: 96vw !important;
    max-height: 90vh !important;
  }

  .partecipate-dialog-image {
    max-width: 96vw !important;
    max-height: 84vh !important;
  }

  .partecipate-dialog-close {
    top: -17px !important;
    right: -6px !important;
    width: 42px !important;
    height: 42px !important;
    font-size: 30px !important;
  }
}
