/**
 * Carrito — TShop (woocommerce/cart/cart.php + cart-empty.php)
 * Pasos + filas con stepper + resumen sticky + envío gratis + kit.
 *
 * Especificidad: TODO control de formulario va con doble clase
 * (.tcart .tcart__x): el CSS dinámico de Astra estiliza button/input en
 * páginas Woo con 0,1,1 y una clase suelta pierde (medido en catálogo).
 */

/* ---------- Chrome de página (trampas Astra) ---------- */

/* El body de Astra es oscuro: la página pinta el suyo. */
body.woocommerce-cart {
  background-color: var(--surface);
}

/* Astra fija el ancho del container con selectores compuestos. */
body.woocommerce-cart .ast-container {
  max-width: none !important;
  padding: 0 !important;
}

/* .ast-container es flex: sin width el main hace shrink-to-fit. */
body.woocommerce-cart #primary,
body.woocommerce-cart .site-main,
body.woocommerce-cart .entry-content {
  width: 100%;
  margin: 0;
}

/* El side-cart completo (drawer + overlay + basket flotante) es redundante
   EN la página del carrito, y peor: al llegar con ?add-to-cart= el drawer
   se abre solo y su overlay (.xoo-wsc-opac) bloquea los clics de toda la
   página (medido con Playwright). Fuera entero. */
body.woocommerce-cart .xoo-wsc-markup {
  display: none !important;
}

/* Astra imprime el título de la página ("Carrito") encima del contenido:
   la plantilla ya tiene su propio H1. */
body.woocommerce-cart .entry-header {
  display: none;
}

.tcart {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding: 0 1.25rem 4rem;
  background-color: var(--surface);
  color: var(--on-surface);
  /* Sin esto, todo hereda la fuente del customizer de Astra (medido). */
  font-family: var(--font-text);
}

/* ---------- Avisos nativos de WC (cupones, deshacer, errores) ---------- */

body.woocommerce-cart .woocommerce-message,
body.woocommerce-cart .woocommerce-info,
body.woocommerce-cart .woocommerce-error {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--outline-variant);
  border-left: 4px solid var(--primary);
  border-radius: 0.75rem;
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  font-family: var(--font-text);
  font-size: 0.9rem;
  list-style: none;
}

body.woocommerce-cart .woocommerce-error {
  border-left-color: #a33a3a;
}

body.woocommerce-cart .woocommerce-message a,
body.woocommerce-cart .woocommerce-info a,
body.woocommerce-cart .woocommerce-error a {
  color: var(--primary);
  font-weight: 600;
}

/* ---------- Pasos ---------- */

.tcart__steps {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(1rem, 0.5rem + 3vw, 3rem);
  padding-top: 2.25rem;
}

.tcart__step {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.875rem;
  color: var(--on-surface-variant);
}

.tcart__step-n {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--surface-container);
  color: var(--on-surface-variant);
  font-weight: 700;
  font-size: 0.8rem;
}

.tcart__step--active {
  color: var(--on-surface);
  font-weight: 600;
}

.tcart__step--active .tcart__step-n {
  background: var(--primary);
  color: var(--surface-container-lowest);
}

.tcart__step--active .tcart__step-label {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.15rem;
}

/* ---------- Título ---------- */

.tcart__title {
  margin: 1.6rem 0 0.25rem;
  font-family: var(--font-headline);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-size: clamp(2.2rem, 1.4rem + 3.5vw, 3.6rem);
  color: var(--on-surface);
  text-decoration: underline;
  text-decoration-thickness: 0.055em;
  text-underline-offset: 0.14em;
}

.tcart__subtitle {
  margin: 0 0 2rem;
  color: var(--on-surface-variant);
  font-size: 0.95rem;
}

/* ---------- Layout ---------- */

.tcart__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .tcart__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Items ---------- */

.tcart__items {
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: 1.25rem;
  overflow: hidden;
}

.tcart__item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto auto auto;
  gap: 1.1rem;
  align-items: center;
  padding: 1.25rem 1.4rem;
}

.tcart__item + .tcart__item {
  border-top: 1px solid var(--outline-variant);
}

.tcart .tcart__item-pic {
  width: 96px;
  height: 96px;
  border-radius: 0.9rem;
  background: var(--surface-container-low);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.tcart .tcart__item-pic img {
  max-width: 88%;
  max-height: 88%;
  width: auto;
  height: auto;
  /* Fotos con fondo blanco pegado: multiply lo funde con la placa. */
  mix-blend-mode: multiply;
}

.tcart__item-sku {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--on-surface-variant);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

.tcart .tcart__item-name {
  display: inline-block;
  margin: 0.1rem 0;
  font-weight: 700;
  font-size: 1rem;
  color: var(--on-surface);
  text-decoration: none;
}

.tcart .tcart__item-name:hover,
.tcart .tcart__item-name:focus-visible {
  color: var(--primary);
  text-decoration: underline;
  outline: none;
}

.tcart__item-brand {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--on-surface-variant);
}

.tcart__item-brand svg {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--primary);
}

.tcart__item-intl {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: #7c4a03;
}

.tcart__item-intl svg {
  width: 12px;
  height: 12px;
  flex: none;
  color: #b45309;
}

.tcart__item-unit {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--on-surface-variant);
}

/* Stepper (doble clase + tamaños explícitos: Astra aplasta paddings). */
.tcart__qty {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--outline-variant);
  border-radius: 999px;
  overflow: hidden;
}

.tcart .tcart__qty-btn {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--on-surface);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.tcart .tcart__qty-btn:hover,
.tcart .tcart__qty-btn:focus,
.tcart .tcart__qty-btn:active {
  background: var(--surface-container);
  color: var(--on-surface);
  outline: none;
}

.tcart .tcart__qty-input {
  width: 2.6rem;
  padding: 0.35rem 0;
  border: 0;
  background: transparent;
  color: var(--on-surface);
  text-align: center;
  font-family: var(--font-text);
  font-weight: 600;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}

.tcart .tcart__qty-input::-webkit-outer-spin-button,
.tcart .tcart__qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tcart .tcart__qty-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: 0.4rem;
}

.tcart__item-total {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tcart .tcart__remove {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--on-surface-variant);
  background: transparent;
}

.tcart .tcart__remove:hover,
.tcart .tcart__remove:focus-visible {
  background: rgb(122 47 47 / 0.1);
  color: #a33a3a;
  outline: none;
}

.tcart .tcart__remove svg {
  width: 16px;
  height: 16px;
}

/* Botón de respaldo sin JS (cart.js lo oculta con hidden). */
.tcart .tcart__update {
  margin-top: 0.9rem;
  padding: 0.55rem 1.2rem;
  border: 1.5px solid var(--outline-variant);
  border-radius: 999px;
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  font-family: var(--font-text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.tcart .tcart__update:hover,
.tcart .tcart__update:focus,
.tcart .tcart__update:active {
  background: var(--surface-container);
  color: var(--on-surface);
  outline: none;
}

/* Trampa: hidden pierde contra display de una clase. */
.tcart .tcart__update[hidden] {
  display: none;
}

.tcart__intl-note {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 1.1rem 0 0;
  padding: 0.8rem 1rem;
  border: 1px solid rgb(180 83 9 / 0.25);
  border-radius: 0.9rem;
  background: rgb(180 83 9 / 0.08);
  color: #7c4a03;
  font-size: 0.83rem;
  line-height: 1.5;
}

.tcart__intl-note svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 0.15rem;
  color: #b45309;
}

.tcart .tcart__keep {
  display: inline-block;
  margin-top: 1rem;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}

.tcart .tcart__keep:hover,
.tcart .tcart__keep:focus-visible {
  text-decoration: underline;
  outline: none;
}

/* ---------- Resumen ---------- */

.tcart__summary {
  position: sticky;
  /* Debajo del header sticky glass (~4.5rem + margen). */
  top: 6rem;
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: 1.25rem;
  padding: 1.5rem;
}

@media (max-width: 900px) {
  .tcart__summary {
    position: static;
  }
}

.tcart__summary-title {
  margin: 0 0 1.1rem;
  font-family: var(--font-headline);
  font-size: 1.15rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--on-surface);
}

/* Barra de envío gratis */
.tcart__freeship {
  margin-bottom: 1.2rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--outline-variant);
  border-radius: 0.9rem;
  background: var(--surface-container-low);
}

.tcart__freeship-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

.tcart__freeship-row svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--primary);
}

.tcart__freeship-row b {
  font-variant-numeric: tabular-nums;
}

.tcart__freeship-track {
  height: 0.45rem;
  margin-top: 0.6rem;
  border-radius: 999px;
  background: var(--surface-container);
  overflow: hidden;
}

.tcart__freeship-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-fixed-dim));
}

/* Cupón */
.tcart__coupon {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1.2rem;
}

.tcart .tcart__coupon-input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 1rem;
  border: 1.5px solid var(--outline-variant);
  border-radius: 999px;
  background: var(--surface-container-low);
  color: var(--on-surface);
  font-family: var(--font-text);
  font-size: 0.875rem;
}

.tcart .tcart__coupon-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.tcart .tcart__coupon-btn {
  padding: 0.55rem 1.1rem;
  border: 0;
  border-radius: 999px;
  background: var(--surface-container);
  color: var(--on-surface);
  font-family: var(--font-text);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.tcart .tcart__coupon-btn:hover,
.tcart .tcart__coupon-btn:focus,
.tcart .tcart__coupon-btn:active {
  background: var(--primary);
  color: var(--surface-container-lowest);
  outline: none;
}

/* Líneas */
.tcart__lines {
  display: flex;
  flex-direction: column;
}

.tcart__line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: 0.3rem 0;
  font-size: 0.92rem;
  color: var(--on-surface-variant);
}

.tcart__line b {
  color: var(--on-surface);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tcart__line--muted {
  padding-top: 0;
  font-size: 0.75rem;
}

.tcart__line--coupon b {
  color: var(--primary);
}

.tcart .tcart__coupon-remove {
  margin-left: 0.3rem;
  color: var(--on-surface-variant);
  font-size: 0.78rem;
  text-decoration: none;
}

.tcart .tcart__coupon-remove:hover,
.tcart .tcart__coupon-remove:focus-visible {
  color: #a33a3a;
  text-decoration: underline;
  outline: none;
}

.tcart__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0.8rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--outline-variant);
}

.tcart__total-label {
  font-weight: 700;
}

.tcart__total-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.tcart__total-iva {
  margin: 0.1rem 0 0;
  text-align: right;
  font-size: 0.72rem;
  color: var(--on-surface-variant);
}

/* CTA (Astra pinta button/a:hover globales: estados explícitos). */
.tcart .tcart__checkout {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1.1rem;
  padding: 0.95rem 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--surface-container-lowest);
  font-family: var(--font-text);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.tcart .tcart__checkout:hover,
.tcart .tcart__checkout:focus,
.tcart .tcart__checkout:active {
  background: var(--secondary);
  color: #fff;
  outline: none;
}

.tcart .tcart__checkout svg {
  width: 18px;
  height: 18px;
}

.tcart__trust {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin-top: 0.9rem;
  font-size: 0.75rem;
  color: var(--on-surface-variant);
}

.tcart__trust span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tcart__trust svg {
  width: 13px;
  height: 13px;
  color: var(--primary);
}

/* ---------- Completa tu kit ---------- */

.tcart__kit {
  margin-top: 1.3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--outline-variant);
}

.tcart__kit-title {
  margin: 0 0 0.9rem;
  font-family: var(--font-headline);
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--on-surface);
}

.tcart__kit-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--outline-variant);
  border-radius: 0.9rem;
  background: var(--surface-container-low);
}

.tcart__kit-card + .tcart__kit-card {
  margin-top: 0.6rem;
}

.tcart .tcart__kit-pic {
  width: 56px;
  height: 56px;
  border-radius: 0.6rem;
  background: var(--surface-container-lowest);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.tcart .tcart__kit-pic img {
  max-width: 86%;
  max-height: 86%;
  width: auto;
  height: auto;
  mix-blend-mode: multiply;
}

.tcart .tcart__kit-name {
  display: inline-block;
  font-size: 0.83rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--on-surface);
  text-decoration: none;
}

.tcart .tcart__kit-name:hover,
.tcart .tcart__kit-name:focus-visible {
  color: var(--primary);
  text-decoration: underline;
  outline: none;
}

.tcart__kit-price {
  margin-top: 0.1rem;
  font-size: 0.8rem;
  color: var(--on-surface-variant);
  font-variant-numeric: tabular-nums;
}

.tcart .tcart__kit-add {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--surface-container-lowest);
}

.tcart .tcart__kit-add:hover,
.tcart .tcart__kit-add:focus,
.tcart .tcart__kit-add:active {
  background: var(--secondary);
  color: #fff;
  outline: none;
}

.tcart .tcart__kit-add svg {
  width: 16px;
  height: 16px;
}

/* ---------- Carrito vacío ---------- */

.tcart--empty {
  padding-top: 3rem;
}

.tcart__empty {
  max-width: 32rem;
  margin-inline: auto;
  padding: 3rem 1rem 2rem;
  text-align: center;
}

.tcart__empty .tcart__title {
  font-size: clamp(1.8rem, 1.2rem + 2.5vw, 2.6rem);
}

.tcart__empty .tcart__subtitle {
  margin-bottom: 1.6rem;
}

.tcart__empty-icon {
  display: inline-grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: 999px;
  background: var(--surface-container);
  color: var(--on-surface-variant);
}

.tcart__empty-icon svg {
  width: 26px;
  height: 26px;
}

.tcart .tcart__checkout--empty {
  display: inline-flex;
  width: auto;
  padding: 0.95rem 2rem;
}

/* ---------- Móvil ---------- */

@media (max-width: 640px) {
  .tcart__item {
    grid-template-columns: 72px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    row-gap: 0.8rem;
  }

  .tcart .tcart__item-pic {
    width: 72px;
    height: 72px;
    grid-row: span 2;
  }

  .tcart__remove {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    align-self: start;
  }

  .tcart__qty {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }

  .tcart__item-total {
    grid-column: 3;
    grid-row: 2;
    align-self: center;
  }
}

/* ---------- Dark: la placa de la foto se vuelve card blanca ---------- */

@media (prefers-color-scheme: dark) {
  .tcart .tcart__item-pic,
  .tcart .tcart__kit-pic {
    background: #ffffff;
  }

  .tcart__item-intl,
  .tcart__intl-note {
    color: #fcd34d;
  }

  .tcart__intl-note {
    background: rgb(251 191 36 / 0.1);
    border-color: rgb(251 191 36 / 0.3);
  }

  .tcart__item-intl svg,
  .tcart__intl-note svg {
    color: #fbbf24;
  }

  .tcart .tcart__remove:hover,
  .tcart .tcart__remove:focus-visible {
    background: rgb(248 187 113 / 0.12);
    color: #f2b8b5;
  }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .tcart .tcart__checkout,
  .tcart .tcart__kit-add,
  .tcart .tcart__coupon-btn,
  .tcart .tcart__qty-btn,
  .tcart .tcart__remove,
  .tcart .tcart__update {
    transition: background-color 0.15s ease, color 0.15s ease;
  }
}
