/* ═══════════════════════════════════════════════
 *  shop.css — Stili pagine shop (categoria, search, prodotto, catalogo)
 *  Deduplicato da: category.php + search.php + product.php + catalogo.php
 *  ═══════════════════════════════════════════════ */

/* ── Subcategory card (categoria) ── */
.subcategory-card {
  transition: box-shadow .2s, transform .15s;
  overflow: hidden;
}
.subcategory-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  transform: translateY(-2px);
}
.subcategory-card .card-body span { color: var(--primary) !important; }
.subcategory-img {
  width: 100%;
  height: 170px;
  object-fit: contain;
  display: block;
  background: #f8f9fa;
}

/* ── Griglia prodotti (categoria + search, deduplicato) ── */
.subcategory-grid,
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  max-width: 100%;
  overflow-x: hidden;
}

.product-img-wrapper {
  padding-top: 24px;
}

/* ── Nome prodotto troncato (categoria + search, deduplicato) ── */
.product-name-line {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

/* ── Box full-width per gruppi misura DM1 (categoria + search, deduplicato) ── */
.grid-full-width {
  grid-column: 1 / -1;
}

/* ── DM1 layout orizzontale: foto sx + contenuto dx ── */
.dm1-img-col {
  flex: 0 0 25%;
  width: 25%;
  padding: 0.5rem;
  display: flex;
  align-items: flex-start;
}
.dm1-img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  display: block;
  background: #f8f9fa;
  border-radius: 4px;
}
@media (max-width: 768px) {
  .dm1-img-col {
    flex: 0 0 40%;
    width: 40%;
  }
}

/* ── Pulsanti misura (categoria + search, deduplicato) ── */
.size-variants {
  display: grid;
  grid-template-columns: repeat(auto-fill, 160px);
  gap: 0.35rem;
}
.size-btn {
  font-size: 0.85rem;
  line-height: 1.2;
  padding: 0.25rem 0.4rem;
  width: 100%;
  text-align: center;
  min-width: 2.5rem;
  max-width: 100%;
  text-align: center;
  border-radius: 4px;
  transition: background-color .15s, color .15s, border-color .15s;
  white-space: normal;
  word-break: break-word;
}
.size-btn:hover {
  background: var(--primary, #0d6efd);
  color: #fff;
  border-color: var(--primary, #0d6efd);
}
.size-variants-2col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pkg-col-wide { flex: 1 1 100%; max-width: 100%; }

.size-btn-desc {
  font-size: 0.72rem;
  opacity: 0.8;
  font-weight: normal;
  white-space: normal;
}
.size-btn small {
  font-size: 0.72rem;
  opacity: 0.85;
  display: block;
}

/* ── Colori (prodotto, categoria, search) ── */
.color-item {
  display: flex;
  gap: var(--color-item-gap);
  align-items: stretch;
  min-height: var(--color-item-min-height);
  transition: box-shadow .15s;
}
.color-item.color-item-sm {
  gap: var(--color-item-gap-sm);
  min-height: var(--color-item-min-height-sm);
  font-size: .875rem;
}
.color-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.color-item-img {
  flex: 0 0 var(--color-img-size);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
  background: #f8f9fa;
}
.color-item-img.color-item-img-sm {
  flex: 0 0 var(--color-img-size-sm);
  aspect-ratio: 1;
  border-radius: 4px;
}
.color-item-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.color-item-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}
.color-item-info {
  line-height: 1.2;
  font-size: .875rem;
}
.color-item-noimg {
  font-size: var(--font-xxs);
  color: var(--text-muted);
}

/* ── Stock bars ── */
.stock-bars {
  display: flex;
  gap: 1px;
  height: var(--stock-bar-h);
  width: 70px;
  min-width: 70px;
  flex-shrink: 0;
}
.stock-bars.stock-bars-wide {
  width: 120px;
  min-width: 120px;
}
.stock-bars-sm {
  height: var(--stock-bar-h-sm);
  width: 70px;
  min-width: 70px;
  flex-shrink: 0;
}
.stock-bar {
  flex: 1 1 0%;
  min-width: 0;
  height: 100%;
  border-radius: 2px;
}

/* ── Disponibilità: solo binaria, nessuna giacenza esposta al cliente ── */
.stock-flag {
  font-size: var(--font-xxs);
  font-weight: 600;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.stock-flag-in  { color: var(--stock-good); background: color-mix(in srgb, var(--stock-good) 25%, transparent); }
.stock-flag-out { color: var(--stock-out);  background: color-mix(in srgb, var(--stock-out) 25%, transparent); }

/* ── Bottoni quantità ── */
.btn-qty {
  height: var(--qty-btn-size);
  width: var(--qty-btn-size);
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}
.btn-qty-sm {
  height: var(--qty-btn-size-sm);
  width: var(--qty-btn-size-sm);
  padding: 0;
  font-size: .8rem;
  line-height: 1;
}
.qty-input {
  height: var(--qty-btn-size);
  flex: 1;
  min-width: var(--qty-input-min-width);
  font-size: var(--font-sm);
  padding: 2px;
}
.qty-input-sm {
  height: var(--qty-btn-size-sm);
  flex: 1;
  min-width: var(--qty-input-min-width-sm);
  font-size: var(--font-xs);
  padding: 1px;
}
.btn-cart {
  height: var(--qty-btn-size);
  font-size: var(--font-sm);
  padding: 0 6px;
}
.btn-cart-sm {
  height: var(--qty-btn-size-sm);
  font-size: var(--font-xxs);
  padding: 0 4px;
}

/* ── Gruppo controlli (qty + cart inline) ── */
.qty-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.qty-row-sm {
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Confezioni in colonne (DM1 + DM4) ── */
.pkg-cols { align-items: flex-start; }
.pkg-col  { flex: 1 1 180px; min-width: 160px; max-width: 280px; }

/* ── Card thumb DM4 (vista griglia) ── */
.card-thumb { display: none; flex-direction: column; overflow: hidden; text-decoration: none; color: inherit; }
.card-thumb picture { display: block; width: 80%; margin: 0 auto; aspect-ratio: 1; overflow: hidden; }
.card-thumb-img, .card-thumb picture img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-thumb-body { padding: .45rem .55rem; }
.ct-name { font-size: .78rem; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ct-code { font-size: .72rem; margin-top: .15rem; }

/* ── Vista card: 4 DM4 per riga ── */
.view-card #productGrid { grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.view-card #productGrid .dm4-card { grid-column: span 1 !important; }
.view-card .dm4-card .card-thumb { display: flex; flex-direction: column; align-items: stretch; }
.view-card .dm4-card .card-dm { flex-direction: column; }
.view-card .dm4-card .card-dm .dm1-img-col { display: none; }
.view-card .dm4-card .card-thumb picture { width: 70%; margin: .5rem auto 0; }
@media (max-width: 992px) { .view-card #productGrid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 576px) { .view-card #productGrid { grid-template-columns: repeat(2, 1fr); } }

/* ── DM4 layout righe: col1=foto col2=info+colori ── */
body:not(.view-card) .dm4-card .dm4-info-col { flex: 1; min-width: 12rem; }
body:not(.view-card) .dm4-card .pkg-row { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: .5rem; padding-bottom: .5rem; border-bottom: 1px solid #e9ecef; }
body:not(.view-card) .dm4-card .pkg-row .pkg-info { flex: 0 0 11.5rem; width: 11.5rem; }
body:not(.view-card) .dm4-card .pkg-row .pkg-colors-block { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; align-content: start; }
/* card view: pkg-row verticale */
.view-card .dm4-card .pkg-row { display: block; margin-bottom: .5rem; padding-bottom: .5rem; border-bottom: 1px solid #e9ecef; }
body:not(.view-card) .dm4-card .pkg-colors-block .btn-colors-toggle { grid-column: 1 / -1; margin-bottom: .25rem; }
body:not(.view-card) .dm4-card .pkg-colors-block .pkg-colors-grid { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; }
body:not(.view-card) .dm4-card .pkg-colors-block .qty-row-main { grid-column: 1 / -1; }

/* ── Qty + cart nel gruppo DM4 / no-colore ── */
.qty-row-main {
  display: flex;
  align-items: center;
  gap: 4px;
}
.qty-row-main .btn-outline-secondary {
  height: var(--qty-btn-size);
  width: var(--qty-btn-size);
  padding: 0;
  font-size: .95rem;
}
.qty-row-main .qty-input-main {
  height: var(--qty-btn-size);
  flex: 1;
  min-width: var(--qty-input-min-width);
  font-size: var(--font-sm);
}
.qty-row-main .btn-accent {
  height: var(--qty-btn-size);
  font-size: .85rem;
  padding: 0 8px;
}

.color-qty {
  min-width: 50px;
}

/* ── Packaging card (prodotto) ── */
.packaging-card {
  transition: box-shadow .15s;
}
.packaging-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

/* ── Size select btn (prodotto) ── */
.size-select-btn {
  min-width: 3rem;
  transition: all .15s;
}

/* ── Sidebar suggerimenti (prodotto) ── */
.suggestions-sidebar {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.suggestion-card {
  transition: transform .15s, box-shadow .15s;
}
.suggestion-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.12) !important;
}
.suggestion-card:not(.suggestion-card-compact):hover {
  transform: translateY(-2px);
}
.suggestion-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f8f9fa;
  display: block;
}
/* Immagine suggerimento centrata (DM1 linked products) */
.suggestion-img-centered {
  width: 60%;
  margin: 0 auto;
}
/* Compact 80% per DM 01/04 */
.suggestion-card-compact {
  transform: scale(0.8);
  transform-origin: top left;
  margin-bottom: -12% !important;
}

/* ── Immagine principale prodotto ── */
.product-main-img {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
}
/* Immagine card prodotto (categoria/search) */
.product-card-img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  display: block;
}
/* Immagine card prodotto collegato (DM1 linked products) */
.card-img-top-linked {
  height: 160px;
  object-fit: cover;
}
/* Thumbnail gallery */
.product-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
}
.product-thumb {
  padding: 0;
  background: #fff;
}
.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-thumb:hover,
.product-thumb.active {
  border-color: var(--primary);
}

/* ── Link nome misura / variante prodotto ── */
.variant-code-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

/* ── Packaging card layout ── */
.packaging-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  min-height: 80px;
}

/* ── Card catalogo ── */
.catalog-card {
  transition: box-shadow .2s, transform .15s;
  cursor: pointer;
  background: #fff;
}
.catalog-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  transform: translateY(-2px);
}
.catalog-embed {
  width: 100%;
  height: 320px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Iframe full (cartella colori PDF) ── */
.iframe-full {
  width: 100%;
  height: 100%;
  border: 0;
}
.modal-body-80vh {
  height: 80vh;
}

/* ── Nasconde freccette spinner nei campi number ── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ── Carrello: riduzione caratteri lista articoli ── */
.cart-table { font-size: 0.9rem; }

/* ── Input quantità nel carrello ── */
.cart-table .input-group {
  flex-wrap: nowrap;
  width: 130px;
}
.cart-table .input-group .form-control {
  min-width: 0;
}

/* ── Spazio tra confezioni nelle card prodotto ── */
.product-card .card-body > .mb-2 {
  margin-bottom: 0.85rem !important;
}

/* ── Color info text (stock label, color name) ── */
.color-name-xs {
  font-size: .78rem;
}
.color-stock-label {
  font-size: .75rem;
  line-height: 1;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .subcategory-grid,
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .subcategory-grid,
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
}

@media (max-width: 767.98px) {
  .suggestions-sidebar {
    position: static;
    margin-top: 1.5rem;
    max-height: none;
    overflow-y: visible;
  }
  #mainPicture {
    display: block;
    max-width: 420px;
    margin-inline: auto;
  }
  .product-main-img { width: 100% !important; }
}

/* ── Pulsanti quadrati color-item (mobile e tablet) ── */
@media (max-width: 991.98px) {
  .color-item .btn-cart {
    width: var(--qty-btn-size);
    padding: 0;
    font-size: .95rem;
  }
  .color-item .btn-qty {
    width: var(--qty-btn-size);
    padding: 0;
  }
}
