/**
 * sm_combinationstable - Estilos de la tabla de combinaciones.
 */

/* ------------------------------------------------------------------
 * Ocultar los bloques nativos
 * - El selector de atributos se oculta en cuanto la tabla existe en el DOM
 *   (no contiene la tabla, así que es seguro hacerlo solo con CSS).
 *   Se excluyen las ventanas modales (vista rápida de otros productos).
 * - Cantidad + "Añadir al carrito" los oculta el JS (clase sm-ct-native-hidden)
 *   después de recolocar la tabla. Si el JS fallara, el comprador seguiría
 *   teniendo el botón nativo.
 * ------------------------------------------------------------------ */
body:has(.js-sm-ct) .product-variants:not(.modal .product-variants),
.sm-ct-native-hidden {
  display: none !important;
}

/* ------------------------------------------------------------------
 * Tabla
 * ------------------------------------------------------------------ */
.sm-ct {
  margin: 1rem 0 1.5rem;
  clear: both;
  /* Permite adaptar la tabla al ancho de la columna del tema (container queries) */
  container-type: inline-size;
  /* Último recurso: si algo no cabe, desplazamiento dentro de la tabla, no de la página */
  overflow-x: auto;
}

/* Las medidas (nombres cortos) en una sola línea; los nombres largos pueden partirse */
.sm-ct__nowrap {
  white-space: nowrap;
}

/* Oferta en una combinación: precio anterior tachado + descuento */
.sm-ct__old {
  display: block;
  font-size: 0.75rem;
  line-height: 1.3;
}

.sm-ct__old del {
  display: block;
  color: #999;
  white-space: nowrap;
}

.sm-ct__price-value {
  white-space: nowrap;
}

.sm-ct__discount {
  display: inline-block;
  margin-right: 0.2rem;
  padding: 0 0.3rem;
  border-radius: 2px;
  background: #d32f2f;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.sm-ct__row--discount .sm-ct__price-value {
  color: #d32f2f;
  font-weight: 600;
}

.sm-ct__table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.sm-ct__table th,
.sm-ct__table td {
  padding: 0.6rem 0.5rem;
  vertical-align: middle;
  border-top: 1px solid #e5e5e5;
}

.sm-ct__table thead th {
  border-top: 0;
  border-bottom: 2px solid #e5e5e5;
  font-weight: 600;
  white-space: nowrap;
}

.sm-ct__row:hover {
  background: #f7f9fb;
}

.sm-ct__row--disabled {
  opacity: 0.55;
}

.sm-ct__num {
  text-align: right;
  white-space: nowrap;
}

.sm-ct__center {
  text-align: center;
}

.sm-ct__ref {
  color: #6b6b6b;
  font-size: 0.875rem;
}

.sm-ct__suffix {
  font-size: 0.8em;
  color: #6b6b6b;
  white-space: nowrap;
}

/* Nombre con miniatura de la combinación */
.sm-ct__name-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sm-ct__thumb {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 3px;
}

.sm-ct__pick {
  cursor: pointer;
}

.sm-ct__pick:hover strong,
.sm-ct__pick:focus strong,
.sm-ct__ref .sm-ct__pick:hover,
.sm-ct__ref .sm-ct__pick:focus {
  text-decoration: underline;
}

.sm-ct__row.is-current .sm-ct__thumb {
  border-color: #333;
}

/* Cantidad: botones - / + como el selector nativo del tema */
.sm-ct__stepper {
  display: inline-flex;
  align-items: stretch;
  height: 38px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
  overflow: hidden;
}

.sm-ct__step {
  flex: 0 0 30px;
  width: 30px;
  padding: 0;
  border: 0;
  background: #f6f6f6;
  color: #777;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.sm-ct__step:hover:not([disabled]) {
  background: #ececec;
  color: #222;
}

.sm-ct__step[disabled] {
  cursor: not-allowed;
}

.sm-ct__input {
  width: 3rem;
  margin: 0;
  padding: 0 0.15rem;
  border: 0;
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  border-radius: 0;
  text-align: center;
  font-size: 0.95rem;
  -moz-appearance: textfield;
  appearance: textfield;
}

.sm-ct__input::-webkit-outer-spin-button,
.sm-ct__input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.sm-ct__input:focus {
  outline: 2px solid #2e86de;
  outline-offset: -2px;
}

/* Aviso de stock parcial (debajo de la fila) */
.sm-ct__notice-row[hidden] {
  display: none !important;
}

.sm-ct__table .sm-ct__notice-row td {
  padding-top: 0;
  border-top: 0;
}

.sm-ct__notice {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
  background: #fff4e0;
  color: #8a5a00;
  font-size: 0.8rem;
}

.sm-ct__min {
  display: block;
  margin-top: 0.2rem;
  color: #6b6b6b;
  font-size: 0.75rem;
}

.sm-ct__line {
  font-weight: 600;
}

/* Disponibilidad */
.sm-ct__badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: nowrap;
}

.sm-ct__badge--in {
  background: #e3f5e9;
  color: #1d7a3e;
}

.sm-ct__badge--order {
  background: #fff4e0;
  color: #8a5a00;
}

.sm-ct__badge--off {
  background: #f1f1f1;
  color: #6b6b6b;
}

/* ------------------------------------------------------------------
 * Pie: total + botón
 * ------------------------------------------------------------------ */
.sm-ct__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding-top: 0.75rem;
  border-top: 2px solid #e5e5e5;
}

.sm-ct__total {
  font-size: 1.05rem;
}

.sm-ct__total-label {
  margin-right: 0.35rem;
}

.sm-ct__total-value {
  font-size: 1.2rem;
}

.sm-ct__add {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.sm-ct__add[disabled] {
  cursor: not-allowed;
}

.sm-ct.is-loading .sm-ct__add {
  opacity: 0.7;
  pointer-events: none;
}

/* Mensajes */
.sm-ct__messages:empty {
  display: none;
}

.sm-ct__messages {
  margin-top: 0.75rem;
}

.sm-ct__msg {
  margin: 0 0 0.5rem;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.sm-ct__msg ul {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}

.sm-ct__msg--success {
  background: #e3f5e9;
  color: #1d7a3e;
}

.sm-ct__msg--error {
  background: #fdecea;
  color: #a12622;
}

.sm-ct__msg--info {
  background: #eef4fb;
  color: #1f4f82;
}

/* ------------------------------------------------------------------
 * Modo compacto: cuando la columna del tema es estrecha (ej. ficha a dos
 * columnas) se reducen márgenes y el sufijo pasa bajo el precio.
 * ------------------------------------------------------------------ */
@container (max-width: 680px) {
  .sm-ct__table {
    font-size: 0.875rem;
  }

  .sm-ct__table th,
  .sm-ct__table td {
    padding: 0.5rem 0.25rem;
  }

  .sm-ct__table thead th {
    font-size: 0.8rem;
    white-space: normal;
  }

  .sm-ct__ref {
    font-size: 0.8rem;
    /* Referencias largas (011-680911080) pueden partirse si no caben */
    overflow-wrap: anywhere;
  }

  .sm-ct__thumb {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
  }

  .sm-ct__name-wrap {
    gap: 0.4rem;
  }

  .sm-ct__price .sm-ct__suffix {
    display: block;
  }

  .sm-ct__input {
    width: 2.2rem;
  }

  .sm-ct__line {
    font-size: 0.8rem;
  }

  .sm-ct__step {
    flex-basis: 22px;
    width: 22px;
  }

  .sm-ct__badge {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    white-space: normal;
  }
}

/* ------------------------------------------------------------------
 * Móvil: cada fila pasa a ser una tarjeta
 * ------------------------------------------------------------------ */
@media (max-width: 767px) {
  .sm-ct__table,
  .sm-ct__table tbody,
  .sm-ct__table tr,
  .sm-ct__table td {
    display: block;
    width: 100%;
  }

  .sm-ct__table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .sm-ct__row {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    background: #fff;
  }

  .sm-ct__table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-top: 0;
    text-align: right;
  }

  .sm-ct__table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: #6b6b6b;
    font-size: 0.85rem;
    text-align: left;
  }

  /* El nombre hace de cabecera de la tarjeta */
  .sm-ct__table td.sm-ct__name {
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
  }

  .sm-ct__table td.sm-ct__name::before {
    display: none;
  }

  .sm-ct__qty {
    flex-wrap: wrap;
  }

  .sm-ct__stepper {
    margin-left: auto;
  }

  .sm-ct__row.has-notice {
    margin-bottom: 0;
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
  }

  .sm-ct__table .sm-ct__notice-row {
    margin: 0 0 0.75rem;
    padding: 0 0.75rem 0.6rem;
    border: 1px solid #e5e5e5;
    border-top: 0;
    border-radius: 0 0 6px 6px;
    background: #fff;
  }

  .sm-ct__table .sm-ct__notice-row td {
    display: block;
    padding: 0;
    text-align: left;
  }

  .sm-ct__table .sm-ct__notice-row td::before {
    display: none;
  }

  .sm-ct__min {
    width: 100%;
    text-align: right;
  }

  .sm-ct__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .sm-ct__total {
    text-align: right;
  }

  .sm-ct__add {
    justify-content: center;
    width: 100%;
  }
}
