/* ═══════════════════════════════════════════════════════════
   CARRITO & CHECKOUT — Origen Tu Marca
   Versión: 1.0.2
   ═══════════════════════════════════════════════════════════ */

/* ── Variables (heredadas del tema, redeclaradas por seguridad) ── */
:root {
  --bg:    #F5F3F0;
  --black: #111110;
  --mid:   #7A7872;
  --light: #DEDAD4;
  --white: #ffffff;
  --font:  'DM Sans', sans-serif;
}

/* ── Reset base ─────────────────────────────────────────── */
.sp-cart-page,
.sp-checkout-page {
  background: var(--bg);
  min-height: 60vh;
  padding: 60px 0 100px;
}

/* ══════════════════════════════════════════════════════════
   CARRITO
   ══════════════════════════════════════════════════════════ */

.sp-cart-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 40px;
}

/* ── Carrito vacío ───────────────────────────────────────── */
.sp-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  gap: 16px;
}

.sp-cart-empty__icon {
  opacity: .4;
  margin-bottom: 8px;
}

.sp-cart-empty__title {
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--black);
  letter-spacing: -.02em;
}

.sp-cart-empty__text {
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 300;
  color: var(--mid);
}

.sp-cart-empty__btn {
  display: inline-block;
  margin-top: 8px;
  padding: 12px 32px;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 400;
  letter-spacing: .04em;
  text-decoration: none;
  transition: opacity .2s;
}

.sp-cart-empty__btn:hover { opacity: .78; }

/* ── Grid principal ──────────────────────────────────────── */
.sp-cart-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 60px;
  align-items: start;
}

/* ── Título ─────────────────────────────────────────────── */
.sp-cart-title {
  font-family: var(--font);
  font-size: 2rem;
  font-weight: 200;
  color: var(--black);
  letter-spacing: -.03em;
  margin-bottom: 32px;
}

/* ── Cabecera columnas ──────────────────────────────────── */
.sp-cart-header-row {
  display: grid;
  grid-template-columns: 2fr 1fr 120px 1fr;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--light);
  font-family: var(--font);
  font-size: .75rem;
  font-weight: 400;
  color: var(--mid);
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ── Fila de producto ───────────────────────────────────── */
.sp-cart-row {
  display: grid;
  grid-template-columns: 2fr 1fr 120px 1fr;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--light);
  gap: 12px;
}

.sp-cart-row__product {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sp-cart-row__img-wrap {
  flex-shrink: 0;
  width: 72px;
  height: 90px;
  overflow: hidden;
  background: var(--light);
}

.sp-cart-row__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sp-cart-row__name {
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 300;
  color: var(--black);
  text-decoration: none;
  line-height: 1.35;
}

.sp-cart-row__name:hover { text-decoration: underline; }

.sp-cart-row__attrs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sp-cart-row__attrs span {
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 300;
  color: var(--mid);
}

/* ── Controles cantidad ─────────────────────────────────── */
.sp-cart-row__qty {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sp-qty-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--light);
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 300;
  color: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, background .2s;
}

.sp-qty-btn:hover {
  border-color: var(--black);
  background: var(--black);
  color: var(--white);
}

.sp-qty-num {
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 300;
  color: var(--black);
  min-width: 20px;
  text-align: center;
}

/* ── Precio + eliminar ──────────────────────────────────── */
.sp-cart-row__price {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sp-cart-row__price span {
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 400;
  color: var(--black);
}

.sp-cart-row__remove {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: .5;
  transition: opacity .2s;
  display: flex;
  align-items: center;
}

.sp-cart-row__remove:hover { opacity: 1; }

/* ── Seguir comprando ───────────────────────────────────── */
.sp-cart-continue {
  margin-top: 24px;
}

.sp-cart-continue a {
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 300;
  color: var(--mid);
  text-decoration: none;
  transition: color .2s;
}

.sp-cart-continue a:hover { color: var(--black); }

/* ── Resumen del pedido ─────────────────────────────────── */
.sp-cart-summary {
  background: var(--white);
  padding: 32px;
  position: sticky;
  top: 100px;
}

.sp-cart-summary__title {
  font-family: var(--font);
  font-size: 1.125rem;
  font-weight: 300;
  color: var(--black);
  letter-spacing: -.01em;
  margin-bottom: 24px;
}

.sp-cart-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 300;
  color: var(--black);
}

.sp-cart-summary__shipping span:last-child {
  font-size: .8125rem;
  color: var(--mid);
}

.sp-cart-summary__divider {
  height: 1px;
  background: var(--light);
  margin: 8px 0;
}

.sp-cart-summary__total {
  font-weight: 400;
  font-size: 1.0625rem;
}

/* ── Cupón ──────────────────────────────────────────────── */
.sp-cart-coupon {
  display: flex;
  gap: 8px;
  margin: 20px 0 6px;
}

.sp-cart-coupon__input,
.sp-co-coupon__input {
  flex: 1;
  height: 42px;
  border: 1px solid var(--light);
  background: transparent;
  padding: 0 14px;
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 300;
  color: var(--black);
  outline: none;
  transition: border-color .2s;
}

.sp-cart-coupon__input:focus,
.sp-co-coupon__input:focus {
  border-color: var(--black);
}

.sp-cart-coupon__btn,
.sp-co-coupon__btn {
  height: 42px;
  padding: 0 16px;
  background: transparent;
  border: 1px solid var(--black);
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 400;
  color: var(--black);
  cursor: pointer;
  letter-spacing: .04em;
  transition: background .2s, color .2s;
  white-space: nowrap;
}

.sp-cart-coupon__btn:hover,
.sp-co-coupon__btn:hover {
  background: var(--black);
  color: var(--white);
}

.sp-cart-coupon__msg,
.sp-co-coupon__msg {
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 300;
  min-height: 18px;
  margin-bottom: 4px;
}

.sp-cart-coupon__msg.ok,
.sp-co-coupon__msg.ok { color: #2a7a2a; }

.sp-cart-coupon__msg.err,
.sp-co-coupon__msg.err { color: #c0392b; }

/* ── Botón ir a pagar ───────────────────────────────────── */
.sp-cart-summary__checkout-btn {
  display: block;
  width: 100%;
  padding: 15px;
  margin-top: 20px;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 400;
  letter-spacing: .04em;
  text-align: center;
  text-decoration: none;
  transition: opacity .2s;
}

.sp-cart-summary__checkout-btn:hover { opacity: .78; }

.sp-cart-summary__note {
  text-align: center;
  font-family: var(--font);
  font-size: .75rem;
  font-weight: 300;
  color: var(--mid);
  margin-top: 12px;
}


/* ══════════════════════════════════════════════════════════
   CHECKOUT
   ══════════════════════════════════════════════════════════ */

.sp-checkout-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 40px;
}

.sp-checkout-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 64px;
  align-items: start;
}

.sp-checkout-title {
  font-family: var(--font);
  font-size: 2rem;
  font-weight: 200;
  color: var(--black);
  letter-spacing: -.03em;
  margin-bottom: 36px;
}

/* ── Secciones del formulario ───────────────────────────── */
.sp-checkout-section {
  border: none;
  padding: 0;
  margin: 0 0 36px;
}

.sp-checkout-section__legend {
  font-family: var(--font);
  font-size: .6875rem;
  font-weight: 400;
  color: var(--mid);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--light);
  width: 100%;
}

/* ── Campos ─────────────────────────────────────────────── */
.sp-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sp-field--full {
  width: 100%;
}

.sp-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: end;
}

/* Labels en field-row: ALTURA FIJA para que los inputs de ambas columnas
   arranquen exactamente a la misma altura, aunque un label tenga más texto
   o envuelva a dos líneas. Antes usaba min-height y no alcanzaba. */
.sp-field-row .sp-field label {
  height: 18px;
  line-height: 18px;
  overflow: hidden;
  white-space: nowrap;
}

/* Que cada columna de la fila estire su campo por igual */
.sp-field-row .sp-field {
  justify-content: flex-end;
}

.sp-field + .sp-field,
.sp-field--full + .sp-field--full,
.sp-field--full + .sp-field-row,
.sp-field-row + .sp-field--full {
  margin-top: 16px;
}

.sp-field label {
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 300;
  color: var(--mid);
  letter-spacing: .01em;
}

.sp-required { color: var(--black); }

.sp-field input[type="text"],
.sp-field input[type="email"],
.sp-field input[type="tel"],
.sp-field select,
.sp-field textarea {
  border: none;
  border-bottom: 1px solid var(--light);
  background: transparent;
  padding: 10px 0;
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 300;
  color: var(--black);
  outline: none;
  transition: border-color .2s;
  width: 100%;
  -webkit-appearance: none;
  border-radius: 0;
}

.sp-field input:focus,
.sp-field select:focus,
.sp-field textarea:focus {
  border-bottom-color: var(--black);
}

.sp-field input::placeholder,
.sp-field textarea::placeholder {
  color: var(--light);
  font-weight: 300;
}

.sp-field select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%237A7872' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 20px;
  /* Igualar alto de línea con los inputs para que Ciudad (input) y
     Región (select) queden perfectamente alineados */
  line-height: 1.4;
  height: auto;
}

/* ── Quitar el fondo celeste/amarillo que Chrome pinta al autocompletar ──
   Chrome usa un color interno propio para -webkit-autofill. No se puede
   sobrescribir con background normal, hay que usar el truco del box-shadow
   interior gigante del color de fondo + fijar el color de texto. */
.sp-field input:-webkit-autofill,
.sp-field input:-webkit-autofill:hover,
.sp-field input:-webkit-autofill:focus,
.sp-field input:-webkit-autofill:active,
.sp-field textarea:-webkit-autofill,
.sp-field select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
  box-shadow: 0 0 0 1000px var(--bg) inset !important;
  -webkit-text-fill-color: var(--black) !important;
  caret-color: var(--black);
  transition: background-color 9999s ease-in-out 0s;
}

.sp-field textarea {
  resize: vertical;
  min-height: 80px;
  padding: 10px 0;
}

/* ── Métodos de envío ───────────────────────────────────── */
.sp-checkout-shipping-methods {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sp-shipping-option {
  border-bottom: 1px solid var(--light);
}

.sp-shipping-option:first-child {
  border-top: 1px solid var(--light);
}

.sp-shipping-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  cursor: pointer;
}

.sp-shipping-label input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--black);
  cursor: pointer;
  flex-shrink: 0;
}

.sp-shipping-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
}

.sp-shipping-name {
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 300;
  color: var(--black);
}

.sp-shipping-price {
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 400;
  color: var(--black);
}

.sp-shipping-free {
  color: #2a7a2a;
}

.sp-shipping-none {
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 300;
  color: var(--mid);
  padding: 14px 0;
}

/* ── Botón submit (mobile) ──────────────────────────────── */
.sp-checkout-submit-mobile {
  display: none;
  margin-top: 8px;
}

/* ── Resumen checkout (sidebar) ─────────────────────────── */
.sp-checkout-summary {
  background: var(--white);
  padding: 32px;
  position: sticky;
  top: 100px;
}

.sp-checkout-summary__title {
  font-family: var(--font);
  font-size: 1.125rem;
  font-weight: 300;
  color: var(--black);
  letter-spacing: -.01em;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--light);
}

/* ── Items del resumen ──────────────────────────────────── */
.sp-checkout-items {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.sp-co-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sp-co-item__img-wrap {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 70px;
  background: var(--light);
  overflow: hidden;
}

.sp-co-item__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sp-co-item__qty {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-size: .6875rem;
  font-weight: 400;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sp-co-item__info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sp-co-item__name {
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 300;
  color: var(--black);
  line-height: 1.3;
}

.sp-co-item__attrs {
  font-family: var(--font);
  font-size: .75rem;
  font-weight: 300;
  color: var(--mid);
}

.sp-co-item__price {
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 400;
  color: var(--black);
  flex-shrink: 0;
}

/* ── Cupón checkout ─────────────────────────────────────── */
.sp-co-coupon {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

/* ── Totales checkout ───────────────────────────────────── */
.sp-co-totals {
  margin-top: 16px;
}

.sp-co-totals__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 300;
  color: var(--black);
}

.sp-co-totals__discount span:last-child {
  color: #2a7a2a;
}

.sp-co-totals__divider {
  height: 1px;
  background: var(--light);
  margin: 6px 0;
}

.sp-co-totals__total {
  font-weight: 400;
  font-size: 1.0625rem;
}

/* ── Botón pagar ────────────────────────────────────────── */
.sp-checkout-submit-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin-top: 24px;
  background: var(--black);
  color: var(--white);
  border: none;
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 400;
  letter-spacing: .04em;
  text-align: center;
  cursor: pointer;
  transition: opacity .2s;
}

.sp-checkout-submit-btn:hover:not(:disabled) { opacity: .78; }
.sp-checkout-submit-btn:disabled { opacity: .5; cursor: not-allowed; }

.sp-co-secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-size: .75rem;
  font-weight: 300;
  color: var(--mid);
  margin-top: 12px;
}


/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤900px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sp-cart-grid,
  .sp-checkout-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .sp-cart-summary,
  .sp-checkout-summary {
    position: static;
  }

  .sp-checkout-summary {
    order: -1; /* Resumen arriba en tablet/mobile */
  }

  .sp-checkout-submit-mobile {
    display: block;
  }

  #sp-checkout-submit-desktop {
    display: none;
  }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤600px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .sp-cart-wrap,
  .sp-checkout-wrap {
    padding: 0 20px;
  }

  .sp-cart-page,
  .sp-checkout-page {
    padding: 40px 0 80px;
  }

  /* En mobile: ocultar cabecera de columnas y reorganizar filas */
  .sp-cart-header-row { display: none; }

  .sp-cart-row {
    grid-template-columns: 72px 1fr;
    grid-template-rows: auto auto;
    gap: 8px 16px;
  }

  .sp-cart-row__product {
    grid-column: 1 / 3;
  }

  .sp-cart-row__attrs {
    flex-direction: row;
    gap: 8px;
  }

  .sp-cart-row__qty {
    justify-content: flex-start;
  }

  .sp-cart-row__price {
    justify-content: space-between;
  }

  .sp-field-row {
    grid-template-columns: 1fr;
  }

  .sp-checkout-title { font-size: 1.5rem; }
  .sp-cart-title     { font-size: 1.5rem; }
}

/* ══════════════════════════════════════════════════════════════════
   MODELO B — Cuenta en el checkout (iniciar sesión + crear cuenta)
   ══════════════════════════════════════════════════════════════════ */

.sp-account-box {
  background: var(--white);
  border: 1px solid var(--light);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 26px;
}

.sp-account-box__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.sp-account-box__intro {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sp-account-box__q {
  font-size: 1rem;
  font-weight: 400;
  color: var(--black);
}

.sp-account-box__sub {
  font-size: .8125rem;
  font-weight: 300;
  color: var(--mid);
  line-height: 1.45;
  max-width: 340px;
}

.sp-account-box__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Botones de la tarjeta de cuenta */
.sp-account-btn {
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 300;
  letter-spacing: .02em;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  line-height: 1;
}

/* "Iniciar sesión" — negro sólido */
.sp-account-btn--ghost {
  background: var(--black);
  color: var(--bg);
  border: 1px solid var(--black);
}
.sp-account-btn--ghost:hover { opacity: .85; }

/* "Crear cuenta" — contorno */
.sp-account-btn--outline {
  background: transparent;
  color: var(--black);
  border: 1px solid var(--black);
}
.sp-account-btn--outline:hover {
  background: var(--black);
  color: var(--bg);
}

/* Fila de login que se despliega */
.sp-login-row {
  display: none;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--light);
}

.sp-login-row.is-open { display: block; }

.sp-login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}

/* Los campos del login: mismo estilo de línea inferior que el resto,
   y alineados abajo para que Correo y Contraseña queden parejos */
.sp-login-grid .sp-field {
  gap: 7px;
  justify-content: flex-end;
}

.sp-login-grid .sp-field label {
  height: 18px;
  line-height: 18px;
  font-size: .8125rem;
  font-weight: 300;
  color: var(--mid);
}

.sp-login-grid .sp-field input {
  border: none;
  border-bottom: 1px solid var(--light);
  background: transparent;
  padding: 10px 0;
  font-family: var(--font);
  font-size: .9375rem;
  font-weight: 300;
  color: var(--black);
  outline: none;
  width: 100%;
  border-radius: 0;
  transition: border-color .2s;
}

.sp-login-grid .sp-field input:focus {
  border-bottom-color: var(--black);
}

.sp-login-btn {
  background: var(--black);
  color: var(--bg);
  border: none;
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 300;
  letter-spacing: .03em;
  padding: 11px 24px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .2s;
  height: 40px;
}

.sp-login-btn:hover { opacity: .85; }
.sp-login-btn:disabled { opacity: .5; cursor: default; }

.sp-login-msg {
  font-size: .8125rem;
  font-weight: 300;
  margin-top: 10px;
  min-height: 1em;
}
.sp-login-msg.ok  { color: #2a7a2a; }
.sp-login-msg.err { color: #c0392b; }

@media (max-width: 768px) {
  .sp-account-box__head {
    flex-direction: column;
    align-items: stretch;
  }
  .sp-account-box__actions {
    width: 100%;
  }
  .sp-account-btn {
    flex: 1;
  }
  .sp-login-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .sp-login-btn { width: 100%; }
}
