/* =========================================================================
   Pagina "Rifiuti conferibili nei Centri di Raccolta" — VERSIONE 2
   Tutto client-side: la view stampa le schede, i filtri lavorano sul DOM.
   Wrapper richiesto sul blocco view: classe .cercdr
   - Accordion schede rifiuto
   - CDR esclusi come pill
   - Toolbar con 2 filtri live (titolo + CDR), nessun reload, nessun bottone
   - Contatore risultati + messaggio "nessun rifiuto"
   ========================================================================= */

/* il form esposto Views non si usa a video: lo leggiamo via JS e lo nascondiamo */
.cercdr .views-exposed-form { display: none; }

/* --- Toolbar filtri --- */
.cercdr .cer-toolbar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
}
.cercdr .cer-field { flex: 1 1 280px; min-width: 0; }
.cercdr .cer-field > label {
  display: block;
  font-size: 0.9rem;
  color: #2b2e3a;
  margin: 0 0 0.35rem;
}
.cercdr .cer-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.85rem 0.6rem 2.4rem;
  border: 1px solid #c9c9cf;
  border-radius: 8px;
  font-size: 1rem;
  background-repeat: no-repeat;
  background-position: 0.8rem center;
  background-size: 18px 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
}

/* --- Combobox CDR --- */
.cercdr .cdr-combo { position: relative; }
.cercdr .cdr-combo-list {
  position: absolute; z-index: 20; left: 0; right: 0;
  margin: 4px 0 0; padding: 4px; list-style: none;
  max-height: 280px; overflow-y: auto;
  background: #fff; border: 1px solid #d9d9dc; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.cercdr .cdr-combo-list[hidden] { display: none; }
.cercdr .cdr-combo-list a {
  display: block; padding: 0.5rem 0.65rem; border-radius: 6px;
  color: #2b2e3a; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.cercdr .cdr-combo-list a:hover { background: #eef0f2; }
.cercdr .cdr-combo-list a[hidden] { display: none; }
.cercdr .cdr-combo-list li a.is-active {
  background: #d8e6ff; color: #1a1c22; font-weight: 600;
}

/* --- Contatore + messaggio vuoto --- */
.cercdr .cer-count { margin: 0 0 0.75rem; color: #6a6d78; font-size: 0.9rem; }
.cercdr .cer-empty {
  margin: 1rem 0; padding: 1rem; border-radius: 8px;
  background: #f6f6f7; color: #3a3d47;
}
.cercdr .cer-empty[hidden] { display: none; }

/* --- Accordion: lista --- */
.cercdr .item-list ul { list-style: none; margin: 0; padding: 0; }
.cercdr .item-list > ul > li { border-bottom: 1px solid #e6e6e8; }

.cercdr .item-list > ul > li > .views-field-title {
  position: relative;
  padding: 1.15rem 3rem 1.15rem 0.25rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.15rem;
  color: #2b2e3a;
  user-select: none;
}
.cercdr .item-list > ul > li > .views-field-title a {
  color: inherit; text-decoration: none; pointer-events: none;
}

/* Icona + che ruota in × */
.cercdr .item-list > ul > li > .views-field-title::after {
  content: "";
  position: absolute; right: 24px; top: 50%; margin-top: -10px;
  width: 20px; height: 20px;
  background-repeat: no-repeat; background-position: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8 2C8.13261 2 8.25979 2.05268 8.35355 2.14645C8.44732 2.24021 8.5 2.36739 8.5 2.5V7.5L13.5 7.5C13.6326 7.5 13.7598 7.55268 13.8536 7.64645C13.9473 7.74021 14 7.86739 14 8C14 8.13261 13.9473 8.25979 13.8536 8.35355C13.7598 8.44732 13.6326 8.5 13.5 8.5H8.5V13.5C8.5 13.6326 8.44732 13.7598 8.35355 13.8536C8.25979 13.9473 8.13261 14 8 14C7.86739 14 7.74021 13.9473 7.64645 13.8536C7.55268 13.7598 7.5 13.6326 7.5 13.5L7.5 8.5H2.5C2.36739 8.5 2.24021 8.44732 2.14645 8.35355C2.05268 8.25979 2 8.13261 2 8C2 7.86739 2.05268 7.74021 2.14645 7.64645C2.24021 7.55268 2.36739 7.5 2.5 7.5H7.5V2.5C7.5 2.36739 7.55268 2.24021 7.64645 2.14645C7.74021 2.05268 7.86739 2 8 2Z' fill='%23888'/%3E%3C/svg%3E");
  transition: transform .2s ease;
}
.cercdr .item-list > ul > li.is-open > .views-field-title::after { transform: rotate(45deg); }

/* Corpo animato */
.cercdr .item-list > ul > li .cer-body {
  overflow: hidden; max-height: 0; opacity: 0;
  transition: max-height .25s ease, opacity .25s ease;
}
.cercdr .item-list > ul > li.is-open .cer-body {
  max-height: 2000px; opacity: 1; padding: 0 0.25rem 0.4rem;
}

/* Corpo come tabella */
.cercdr .cer-body .views-field,
.cercdr .cer-body > div:not([class]) {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0.2rem 1.25rem;
  align-items: start;
  padding: 0.6rem 0; margin: 0;
  border-bottom: 1px solid #f0f0f1;
}
.cercdr .cer-body > *:last-child { border-bottom: 0; }
.cercdr .cer-body .views-label,
.cercdr .cer-body > div:not([class]) > span:first-child {
  display: block; font-weight: 600; color: #6a6d78; margin: 0;
}
.cercdr .cer-body .field-content,
.cercdr .cer-body > div:not([class]) > div {
  display: block; margin: 0; color: #2b2e3a;
}
.cercdr .cer-body .field-content p { display: inline; margin: 0; }

@media (max-width: 640px) {
  .cercdr .cer-body .views-field,
  .cercdr .cer-body > div:not([class]) {
    grid-template-columns: 1fr; gap: 0.15rem; padding: 0.5rem 0;
  }
}

/* CDR esclusi come pill */
.cercdr .views-field-field-cdr-esclusi .views-label { display: block; margin-bottom: 0.4rem; }
.cercdr .views-field-field-cdr-esclusi .field-content { display: inline; }
.cercdr .views-field-field-cdr-esclusi .cdr-tag {
  display: inline-block;
  margin: 0 0.3rem 0.3rem 0;
  padding: 0.15rem 0.65rem;
  background: #ececee; border: 1px solid #d9d9dc; border-radius: 999px;
  font-size: 0.85rem; line-height: 1.5; color: #3a3d47; white-space: nowrap;
}