/**
 * Tiered Pricing for WooCommerce nasconde il wrapper preloaded con display:none
 * aspettandosi il form WC nativo. Con la nostra Variation Table che lo sostituisce,
 * forziamo la visibilità del blocco prezzi a scaglioni.
 * I prezzi sono identici per tutte le varianti: mostriamo solo il primo blocco.
 */
.tpt__tiered-pricing-preloaded-variations {
  display: block !important;
}
.tpt__tiered-pricing-preloaded-variations .tiered-pricing-preloaded-variation:not(:first-child) {
  display: none !important;
}

/**
 * SIT Variation Table — CSS
 *
 * Architettura BEM con prefisso sit-vt__
 * Mobile-first, nessun framework esterno.
 *
 * Blocchi principali:
 *   .sit-vt__wrapper        — contenitore generale
 *   .sit-vt__table          — la tabella varianti
 *   .sit-vt__row            — riga variante
 *   .sit-vt__qty            — input quantità
 *   .sit-vt__btn-cart       — pulsante aggiungi al carrello
 *   .sit-vt__feedback       — area messaggi
 *   .sit-vt__stock          — label disponibilità
 */

.tiered-pricing-blocks .tiered-pricing--active {
  transform: scale(1) !important;
}

/* ==========================================================================
   Wrapper
   ========================================================================== */

.sit-vt__wrapper {
  margin: 1.5em 0;
  width: 100%;
}

/* ==========================================================================
   Tabella
   ========================================================================== */

.sit-vt__table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 0.9em;
}

/* Scroll orizzontale su schermi piccoli */
.sit-vt__wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Intestazione
   ========================================================================== */

.sit-vt__thead {
  border-bottom: 2px solid #e0e0e0;
}

.sit-vt__th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  background-color: #f8f8f8;
}

.sit-vt__th--quantity {
  text-align: center;
}

/* ==========================================================================
   Righe
   ========================================================================== */

.sit-vt__row {
  border-bottom: 1px solid #ececec;
  transition: background-color 0.15s ease;
}

.sit-vt__row:hover {
  background-color: #fafafa;
}

/* Variante esaurita */
.sit-vt__row--out-of-stock {
  opacity: 0.55;
  background-color: #f9f9f9;
  pointer-events: none; /* Disabilita interazione sulla riga intera */
}

.sit-vt__row--out-of-stock:hover {
  background-color: #f9f9f9;
}

/* ==========================================================================
   Celle
   ========================================================================== */

.sit-vt__td {
  padding: 10px 12px;
  vertical-align: middle;
}

.sit-vt__td--quantity {
  text-align: center;
}

.sit-vt__td--price,
.sit-vt__th--price {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
  color: #333;
}

.sit-vt__td--price ins {
  text-decoration: none;
}

/* ==========================================================================
   Attributi variante
   ========================================================================== */

.sit-vt__attr-value {
  display: inline-block;
  font-weight: 500;
}

.sit-vt__attr-sep {
  color: #aaa;
  margin: 0 4px;
}

/* ==========================================================================
   Stock
   ========================================================================== */

.sit-vt__stock {
  display: inline-block;
  font-size: 0.85em;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.sit-vt__stock--in {
  color: #2e7d32;
  background-color: #e8f5e9;
}

.sit-vt__stock--limited {
  color: #e65100;
  background-color: #fff3e0;
}

.sit-vt__stock--out {
  color: #c62828;
  background-color: #ffebee;
}

/* ==========================================================================
   Input quantità
   ========================================================================== */

.sit-vt__qty {
  width: 70px;
  padding: 6px 8px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1em;
  line-height: 1.4;
  -webkit-appearance: textfield;
  appearance: textfield;
  -moz-appearance: textfield; /* Nasconde le frecce su Firefox */
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.sit-vt__qty::-webkit-inner-spin-button,
.sit-vt__qty::-webkit-outer-spin-button {
  opacity: 1; /* Visibili su Webkit per UX migliore */
}

.sit-vt__qty:focus {
  border-color: #2271b1;
  box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
  outline: none;
}

.sit-vt__qty:disabled {
  background-color: #f5f5f5;
  border-color: #ddd;
  color: #aaa;
  cursor: not-allowed;
}

/* ==========================================================================
   Footer e pulsante
   ========================================================================== */

.sit-vt__footer {
  margin-top: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 0.75em;
  align-items: flex-start;
}

.sit-vt__btn-cart {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  transition:
    opacity 0.2s ease,
    background-color 0.2s ease;
  /* Il colore eredita dal tema WooCommerce tramite la classe .button.alt */
}

.sit-vt__btn-cart:disabled,
.sit-vt__btn-cart--loading {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Spinner semplice via pseudo-elemento durante il loading */
.sit-vt__btn-cart--loading::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  -webkit-animation: sit-vt-spin 0.6s linear infinite;
  animation: sit-vt-spin 0.6s linear infinite;
  vertical-align: middle;
}

@-webkit-keyframes sit-vt-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes sit-vt-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Area feedback
   ========================================================================== */

.sit-vt__feedback {
  display: none; /* Nascosta di default, mostrata via JS */
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.9em;
  line-height: 1.5;
  width: 100%;
}

.sit-vt__feedback p {
  margin: 0 0 4px;
}

.sit-vt__feedback--success {
  color: #1b5e20;
  background-color: #e8f5e9;
  border: 1px solid #a5d6a7;
}

.sit-vt__feedback--error {
  color: #b71c1c;
  background-color: #ffebee;
  border: 1px solid #ef9a9a;
}

.sit-vt__error-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.sit-vt__error-list li {
  margin-bottom: 2px;
}

/* ==========================================================================
   Responsive — tablet e mobile
   ========================================================================== */

@media (max-width: 600px) {
  .sit-vt__th,
  .sit-vt__td {
    padding: 8px 10px;
    font-size: 0.85em;
  }

  .sit-vt__qty {
    width: 58px;
    padding: 5px 6px;
  }

  .sit-vt__btn-cart {
    width: 100%;
    justify-content: center;
  }

  .sit-vt__footer {
    align-items: stretch;
  }
}

/* ==========================================================================
   Toggle Groups (accordion) — usato solo con 2+ assi attributo
   ========================================================================== */

.sit-vt__group {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-bottom: 8px;
  overflow: hidden;
}

.sit-vt__group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  background-color: #f8f8f8;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: 1em;
  font-weight: 600;
  color: #333;
  transition: background-color 0.15s ease;
}

.sit-vt__group-toggle:hover {
  background-color: #f0f0f0;
}

.sit-vt__group-toggle[aria-expanded="true"] {
  background-color: #e8f0fe;
  color: #1a56db;
  border-bottom: 1px solid #c7d9f9;
}

.sit-vt__group-toggle-icon {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 8px;
}

.sit-vt__group-toggle[aria-expanded="true"] .sit-vt__group-toggle-icon {
  transform: rotate(-135deg);
}

.sit-vt__group-panel[hidden] {
  display: none;
}

.sit-vt__table--sub {
  margin: 0;
}

.sit-vt__table--sub .sit-vt__th,
.sit-vt__table--sub .sit-vt__td {
  padding: 8px 16px;
}

.sit-vt__table--sub .sit-vt__td--attributes,
.sit-vt__table--sub .sit-vt__th--attributes {
  padding-left: 24px;
}

@media (max-width: 600px) {
  .sit-vt__group-toggle {
    padding: 10px 12px;
    font-size: 0.9em;
  }

  .sit-vt__table--sub .sit-vt__th,
  .sit-vt__table--sub .sit-vt__td {
    padding: 7px 10px;
  }
}
