/*
 * FornitureitcTheme — archivio.css (redesign 2026, Fase 3)
 * Negozio, categorie, reparti e ricerca prodotti (woocommerce/archive-product.php).
 * Riferimento: REDESIGN/mockup/Categoria.dc.html
 * Card, pulsanti, griglia e selettore quantità sono in layout.css.
 */

/* =============================================
   TESTATA
   ============================================= */
.arch-head { display: flex; flex-direction: column; gap: 18px; margin-top: 14px; }
.arch-head__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.arch-head__txt { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.arch-head h1 { margin: 0; font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -.01em; }
.arch-head__txt p { margin: 0; max-width: 760px; font-size: 15px; line-height: 1.55; color: var(--muted); }
.arch-head__pdf {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}
.arch-head__pdf:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.arch-head__pdf .fit-ico { stroke-width: 2; }

.arch-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.arch-chip {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}
.arch-chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.arch-chip.is-on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }

/* =============================================
   LAYOUT: filtri 264px + risultati
   ============================================= */
.arch-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-top: 24px;
}
.arch-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.arch-overlay { display: none; }

/* =============================================
   FILTRI
   ============================================= */
.arch-filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.arch-filters__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.arch-filters__title { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.arch-filters__reset { margin-left: auto; font-size: 13px; padding: 8px 0; }
.arch-filters__close {
  display: none;
  width: 44px; height: 44px;
  align-items: center; justify-content: center;
  border: 0; border-radius: var(--r);
  background: none; color: var(--ink); cursor: pointer;
}
.arch-fs {
  border: 0;
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}
.arch-fs legend {
  float: left; /* il legend nel flusso: niente sovrapposizione al bordo del fieldset */
  width: 100%;
  padding: 0;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.arch-fs legend + * { clear: left; }
.arch-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 14px;
  cursor: pointer;
}
.arch-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); flex-shrink: 0; }
.arch-n { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.arch-fs__more summary {
  display: flex;
  align-items: center;
  min-height: 36px;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
  cursor: pointer;
  list-style: none;
}
.arch-fs__more summary::-webkit-details-marker { display: none; }
.arch-fs__more summary::after { content: '+'; margin-left: 6px; }
.arch-fs__more[open] summary::after { content: '−'; }

.arch-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.arch-pill { position: relative; cursor: pointer; }
.arch-pills--fill .arch-pill { flex: 1 1 0; }
.arch-pill input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.arch-pill span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink);
}
.arch-pill--mono span { font-family: var(--font-mono); }
.arch-pill:hover span { border-color: var(--brand); }
.arch-pill input:checked + span { border: 1.5px solid var(--brand); background: var(--brand-tint); color: var(--brand); font-weight: 500; }
.arch-pill input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.arch-price { display: flex; align-items: center; gap: 8px; }
.arch-price input {
  width: 90px;
  min-width: 0;
  flex: 1 1 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-input);
  border-radius: var(--r-sm);
  font-size: 14px;
  background: #fff;
}
.arch-price input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.arch-price span { color: var(--muted); }

.arch-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; }
.arch-toggle label { font-size: 14px; font-weight: 500; cursor: pointer; }
.arch-switch { position: relative; display: block; width: 44px; height: 26px; flex-shrink: 0; }
.arch-switch input { position: absolute; inset: 0; z-index: 1; opacity: 0; margin: 0; cursor: pointer; }
.arch-switch span { position: absolute; inset: 0; border-radius: 13px; background: var(--line-input); transition: background var(--transition); }
.arch-switch span::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20,23,31,.2);
  transition: transform var(--transition);
}
.arch-switch input:checked + span { background: var(--brand); }
.arch-switch input:checked + span::after { transform: translateX(18px); }
.arch-switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.arch-filters__apply { padding: 0 20px 18px; }
/* con JS attivo, su desktop i filtri si applicano da soli */
.has-js .arch-filters__apply { display: none; }

/* =============================================
   TOOLBAR
   ============================================= */
.arch-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 12px 10px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.arch-toolbar__filters { display: none; }
.arch-toolbar__count { font-size: 14px; color: var(--ink-2); }
.arch-toolbar__count strong { color: var(--ink); }
.arch-toolbar__spacer { flex: 1 1 auto; }
.arch-active { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.arch-active li {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 30px;
  padding: 0 4px 0 12px;
  border-radius: 15px;
  background: var(--brand-tint);
  color: var(--brand);
  font-size: 13px;
  font-weight: 500;
}
.arch-active a {
  position: relative;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  color: var(--brand);
}
.arch-active a::after { content: ''; position: absolute; inset: -10px -6px; } /* area cliccabile 44px */
.arch-active a:hover { background: rgba(27,43,107,.12); }
.arch-active .fit-ico { stroke-width: 2.2; }

.arch-sort { display: flex; align-items: center; gap: 8px; }
.arch-sort label { font-size: 14px; color: var(--muted); }
.arch-sort select {
  height: 40px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--line-input);
  border-radius: var(--r-sm);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233F4452' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 14px;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.arch-sort select:focus { outline: none; border-color: var(--brand); }
.arch-view { display: flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.arch-view__btn {
  width: 44px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  color: var(--muted);
}
.arch-view__btn + .arch-view__btn { border-left: 1px solid var(--line-strong); }
.arch-view__btn:hover { color: var(--brand); }
.arch-view__btn.is-on { background: var(--brand); color: #fff; }
.arch-view__btn .fit-ico { stroke-width: 2; }

/* =============================================
   GRIGLIA (3 colonne nella pagina archivio)
   ============================================= */
.arch-main .arch-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* =============================================
   VISTA LISTA
   ============================================= */
.arch-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.arch-list__head,
.arch-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 130px 150px 128px 52px;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
}
.arch-list__head {
  padding-top: 10px;
  padding-bottom: 10px;
  background: #FAFAF8;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.is-right { text-align: right; }
.is-center { text-align: center; }
.arch-list__rows { list-style: none; margin: 0; padding: 0; }
.arch-row { border-bottom: 1px solid var(--line-soft); }
.arch-row:last-child { border-bottom: 0; }
.arch-row:hover { background: #FCFCFA; }
.arch-row__media {
  width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r);
  background: var(--img-bg);
  overflow: hidden;
}
.arch-row__img { width: 84px !important; height: 84px !important; object-fit: contain; mix-blend-mode: multiply; }
.arch-row__info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.arch-row__name { color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.35; }
.arch-row__name:hover { color: var(--brand); }
.arch-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.arch-row__sku { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-right: 6px; }
.arch-row__chip { padding: 2px 8px; border-radius: 4px; background: #F1EFEA; font-size: 12px; color: var(--ink-2); }
.arch-row__stock { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.arch-row__stock > span { width: 8px; height: 8px; border-radius: 4px; flex-shrink: 0; background: currentColor; }
.arch-row__stock--ok   { color: var(--ok); }
.arch-row__stock--wait { color: #B45309; }
.arch-row__stock--no   { color: var(--sale); }
.arch-row__price { display: flex; flex-direction: column; align-items: flex-end; text-align: right; line-height: 1.2; }
.arch-row__price .amount { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--ink); }
.arch-row__price del .amount { font-size: 13px; font-weight: 500; color: var(--muted); }
.arch-row__price ins { text-decoration: none; }
.arch-row__price ins .amount { color: var(--sale); }
.arch-row__price .price-iva { font-size: 12px; color: var(--muted); margin-top: 2px; }
.arch-row__price .fit-pr-badge { margin-top: 4px; padding: 2px 6px; border-radius: 4px; background: var(--ok-bg); color: var(--ok-ink); font-size: 11px; font-weight: 600; }
.arch-row .fit-qty { justify-self: center; }
.arch-row__add { width: 48px; }
.arch-row__add .fit-ico--check { display: none; }
.arch-row__add.added .fit-ico--cart { display: none; }
.arch-row__add.added .fit-ico--check { display: block; }
.arch-row .added_to_cart { display: none; }
.arch-row__more { grid-column: 5 / -1; justify-self: center; font-size: 14px; font-weight: 600; padding: 12px 0; }
.arch-row__lock {
  grid-column: 4 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}
.arch-row__lock a { margin-left: 8px; font-size: 14px; font-weight: 600; padding: 12px 0; }
.arch-list__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: #FAFAF8;
  border-top: 1px solid var(--line);
}
.arch-list__hint { font-size: 14px; color: var(--muted); }
.arch-list__hint.is-ok { color: var(--ok); }
.arch-list__hint.is-error { color: var(--sale); }
.arch-list__hint a { font-weight: 600; }
.arch-list__foot .fit-btn { min-height: 44px; font-size: 15px; }

/* =============================================
   PAGINAZIONE (pulsanti 44px)
   ============================================= */
.arch-pages { margin-top: 12px; }
.arch-pages .woocommerce-pagination ul.page-numbers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
}
.arch-pages .woocommerce-pagination ul.page-numbers li { border: 0; margin: 0; float: none; overflow: visible; }
.arch-pages .woocommerce-pagination ul.page-numbers li .page-numbers {
  min-width: 44px;
  height: 44px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
}
.arch-pages .woocommerce-pagination ul.page-numbers li a.page-numbers:hover { border-color: var(--brand); color: var(--brand); background: var(--surface); }
.arch-pages .woocommerce-pagination ul.page-numbers li span.current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.arch-pages .woocommerce-pagination ul.page-numbers li span.dots { border: 0; background: none; min-width: 24px; padding: 0; }

/* =============================================
   NESSUN RISULTATO
   ============================================= */
.arch-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink-2);
}
.arch-empty .fit-ico { color: var(--muted); margin-bottom: 6px; }
.arch-empty p { margin: 0; }
.arch-empty .fit-btn { margin-top: 12px; }

/* =============================================
   DESKTOP STRETTO
   ============================================= */
@media (max-width: 1279px) and (min-width: 1025px) {
  .arch-list__head,
  .arch-row { grid-template-columns: 80px minmax(0, 1fr) 110px 130px 128px 52px; gap: 12px; }
  .arch-row__media { width: 80px; height: 80px; }
  .arch-row__img { width: 70px !important; height: 70px !important; }
}

/* =============================================
   MOBILE E TABLET (< 1025px)
   ============================================= */
@media (max-width: 1024px) {
  .arch-head { gap: 12px; margin-top: 8px; }
  .arch-head__row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .arch-head h1 { font-size: 28px; }
  .arch-head__txt p { font-size: 14px; }
  .arch-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .arch-chips::-webkit-scrollbar { display: none; }

  .arch-layout { grid-template-columns: 1fr; margin-top: 16px; }

  /* Filtri: pannello a scomparsa da sinistra */
  .arch-filters {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1200;
    width: min(360px, 88vw);
    border: 0;
    border-radius: 0;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 16px 0 40px rgba(15,26,69,.18);
    visibility: hidden;
  }
  .arch-filters.is-open { transform: translateX(0); visibility: visible; }
  .arch-filters__form { min-height: 100%; display: flex; flex-direction: column; }
  .arch-filters__head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 8px 8px 8px 20px; }
  .arch-filters__close { display: flex; }
  .has-js .arch-filters__apply,
  .arch-filters__apply {
    display: block;
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .arch-overlay:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1190;
    background: rgba(15,26,69,.45);
  }
  html.filters-open { overflow: hidden; }

  .arch-toolbar { padding: 10px 12px; gap: 10px; }
  .arch-toolbar__filters {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--brand);
    border-radius: var(--r);
    background: #fff;
    color: var(--brand);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
  }
  .arch-toolbar__spacer { display: none; }
  .arch-toolbar__count { margin-left: auto; }
  .arch-active { order: 5; width: 100%; }
  .arch-sort { flex: 1 1 auto; }
  .arch-sort label { display: none; }
  .arch-sort select { width: 100%; }

  .arch-main .arch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

  /* Lista: righe compatte */
  .arch-list__head { display: none; }
  .arch-row {
    grid-template-columns: 72px minmax(0, 1fr) auto;
    grid-template-areas:
      "media info  info"
      "media stock price"
      "qty   qty   add";
    gap: 8px 12px;
    padding: 14px;
  }
  .arch-row__media { grid-area: media; width: 72px; height: 72px; align-self: start; }
  .arch-row__img { width: 64px !important; height: 64px !important; }
  .arch-row__info { grid-area: info; }
  .arch-row__name { font-size: 14px; }
  .arch-row__stock { grid-area: stock; font-size: 13px; }
  .arch-row__price { grid-area: price; }
  .arch-row__price .amount { font-size: 18px; }
  .arch-row .fit-qty { grid-area: qty; justify-self: stretch; }
  .arch-row .fit-qty__input { flex: 1 1 auto; }
  .arch-row__add { grid-area: add; }
  .arch-row__more { grid-area: add; grid-column: auto; }
  .arch-list.is-guest .arch-row { grid-template-areas: "media info" "media stock" "lock lock"; grid-template-columns: 72px minmax(0, 1fr); }
  .arch-row__lock { grid-area: lock; grid-column: auto; justify-content: flex-start; }

  /* Barra "Aggiungi selezionati" sempre a portata, sopra la tab bar */
  .arch-list__foot {
    position: sticky;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    z-index: 5;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 14px;
    box-shadow: 0 -8px 20px rgba(20,23,31,.06);
  }
  .arch-list__hint { font-size: 13px; }
}

/* Tablet (700–1024px): 3 card per riga */
@media (min-width: 700px) and (max-width: 1024px) {
  .arch-main .arch-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .arch-filters { transition: none; }
}
