/* =============================================================
   AMARÍA — Cart / Carrito  ·  cart.css
   Dirección: Ledger editorial (única variante aprobada).
   Autosuficiente: incluye tokens + utilidades reutilizadas
   (.eyebrow, .btn, .rec-grid) para no depender de otra hoja.
   ============================================================= */

/* ───────── Tokens ───────── */
:root {
  --ink: #1B1F1D;
  --ink-60: rgba(27, 31, 29, 0.6);
  --ink-40: rgba(27, 31, 29, 0.4);
  --paper: #FFFFFF;
  --paper-2: #EFEFEE;
  --paper-3: #E5E5E3;
  --mint: #CDE0D8;
  --mint-tint: #EFEFED;
  --mint-deep: #8FB0A4;
  --line: rgba(27, 31, 29, 0.14);
  --line-strong: rgba(27, 31, 29, 0.28);

  /* Fuentes del sitio Amaría (ya cargadas por el tema).
     Fallback a las del prototipo si no estuvieran disponibles. */
  --serif: "Playfair Display", "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Jost", "Manrope", system-ui, -apple-system, sans-serif;

  --eyebrow: 0.66rem;
  --maxw: 1320px;
}

/* ───────── Reset acotado al carrito ───────── */
body.am-cart { overflow-x: hidden; }
.am-cart-page * { box-sizing: border-box; }
.am-cart-page button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
.am-cart-page a { color: inherit; text-decoration: none; }
.am-cart-page img { display: block; max-width: 100%; }
.am-visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
                      overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ───────── Utilidades reutilizadas (de styles.css) ───────── */
.am-cart-page .eyebrow { font-size: var(--eyebrow); letter-spacing: 0.22em; text-transform: uppercase; font-weight: 500; }
.am-cart-page .btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
       padding: 0.95rem 1.4rem; font-size: 0.78rem; letter-spacing: 0.18em; line-height: 1;
       text-transform: uppercase; font-weight: 500; border: 1px solid var(--ink);
       transition: all 0.18s ease; cursor: pointer; background: none; }
.am-cart-page .btn--solid { background: var(--ink); color: var(--paper); }
.am-cart-page .btn--solid:hover { background: transparent; color: var(--ink); }
.am-cart-page .btn--full { width: 100%; }
.am-cart-page .btn--lg { padding: 1.15rem 1.6rem; font-size: 0.82rem; }
.am-cart-page .rec-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.6rem; }
.am-cart-page .rec-card { display: flex; flex-direction: column; gap: 0.8rem; }
.am-cart-page .rec-card__img { aspect-ratio: 4/5; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.am-cart-page .rec-card__img img { width: 100%; height: 100% !important; object-fit: cover; transition: transform 0.4s ease; }
.am-cart-page .rec-card:hover .rec-card__img img { transform: scale(1.04); }
.am-cart-page .rec-card__name { font-family: var(--serif); font-size: 1.15rem; margin: 0; line-height: 1.15; font-weight: 500; }
.am-cart-page .rec-card__sub { font-size: 0.78rem; color: var(--ink-60); margin-top: -0.2rem; }
.am-cart-page .rec-card__row { display: flex; justify-content: space-between; align-items: center; font-size: 0.84rem; }

/* ───────── Página ───────── */
.crt-page { background: var(--paper); min-height: 60vh; font-family: var(--sans); color: var(--ink); }

/* ───────── Encabezado ───────── */
.crt-head { max-width: var(--maxw); margin: 0 auto; padding: 2.6rem 2.2rem 1.6rem;
            display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; }
.crt-head__l .eyebrow { color: var(--ink-60); }
.crt-head__title { font-family: var(--serif); font-size: 3rem; line-height: 1; margin: 0.5rem 0 0;
                   font-weight: 400; letter-spacing: -0.01em; }
.crt-head__title em { font-style: italic; }
.crt-head__back { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.74rem;
                  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink);
                  border-bottom: 1px solid var(--line-strong); padding-bottom: 0.3rem; transition: color 0.15s ease; }
.crt-head__back:hover { color: var(--ink-60); }
.crt-head__back svg { width: 16px; height: 16px; transform: rotate(180deg); }

/* ───────── Barra de envío gratis ───────── */
.crt-ship { display: flex; flex-direction: column; gap: 0.7rem; }
.crt-ship__top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: 0.82rem; line-height: 1.4; }
.crt-ship__top b { font-weight: 600; }
.crt-ship__icon { width: 18px; height: 18px; color: var(--mint-deep); flex-shrink: 0; }
.crt-ship__bar { height: 4px; background: var(--paper-3); position: relative; overflow: hidden; }
.crt-ship__fill { position: absolute; inset: 0 auto 0 0; background: var(--mint-deep); transition: width 0.4s ease; }
.crt-ship.is-free .crt-ship__fill { background: var(--ink); }

/* ───────── Grid ledger ───────── */
.crt-ledger { display: grid; grid-template-columns: 1.7fr 1fr; gap: 3.5rem;
              max-width: var(--maxw); margin: 0 auto; padding: 50px 2.2rem 10px; align-items: start; }
.crt-ledger__col-l { min-width: 0; }
.crt-ledger__actions { margin: 0; }

.crt-tbl__head { display: grid; grid-template-columns: 1fr 130px 110px;
                 gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--ink);
                 font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-60); }
.crt-tbl__head span:nth-child(2) { text-align: center; }
.crt-tbl__head span:last-child { text-align: right; }

.crt-line { display: grid; grid-template-columns: 1fr 130px 110px; gap: 1rem;
            padding: 1.6rem 0; border-bottom: 1px solid var(--line); align-items: center; }
.crt-line__prod { display: flex; gap: 1.2rem; align-items: flex-start; }
.crt-thumb { width: 84px; height: 104px; flex-shrink: 0; background: #fff; border: 1px solid var(--line);
             display: flex; align-items: center; justify-content: center; overflow: hidden; }
.crt-thumb img { width: 100%; height: 100% !important; object-fit: cover; }
.crt-thumb__mono { font-family: var(--serif); font-size: 2rem; color: var(--mint-deep); }
.crt-line__info { display: flex; flex-direction: column; gap: 0px; padding-top: 0.2rem; min-width: 0; }
.crt-line__info * { margin: 0px; padding: 0px; line-height: 1.3rem; }
.crt-line__brand { font-size: 0.62rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-60); }
.crt-line__name { font-family: var(--serif); font-size: 1.3rem; line-height: 1.1; margin: 0; font-weight: 400; }
.crt-line__name a { transition: color 0.15s ease; }
.crt-line__name a:hover { color: var(--ink-60); }
.crt-line__var { font-size: 0.78rem; color: var(--ink-60); }
.crt-line__var b { font-weight: 500; color: var(--ink); }
.crt-line__unit { font-size: 0.78rem; color: var(--ink-60); margin-top: 0.1rem; }
.crt-line__rm { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.7rem; color: var(--ink-60);
                letter-spacing: 0.06em; margin-top: 0.4rem; transition: color 0.15s ease; align-self: flex-start; }
.crt-line__rm:hover { color: var(--ink); }
.crt-line__rm svg { width: 13px; height: 13px; }
.crt-line__total { font-family: var(--serif); font-size: 1.25rem; text-align: right; }

/* Stepper de cantidad */
.crt-qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); margin: 0 auto; }
.crt-qty button { width: 34px; height: 38px; display: flex; align-items: center; justify-content: center;
                  font-size: 1rem; color: var(--ink); transition: background 0.15s ease; }
.crt-qty button:hover:not(:disabled) { background: var(--paper-2); }
.crt-qty button:disabled { color: var(--ink-40); cursor: not-allowed; }
.crt-qty button svg { width: 16px; height: 16px; }
.crt-qty__val { width: 34px; text-align: center; font-size: 0.9rem; }
/* El input numérico solo existe para el envío clásico del formulario (fallback sin JS).
   Samatex fuerza los inputs a display:block, así que lo ocultamos con !important. */
.crt-qty__input[hidden], .crt-qty__input { display: none !important; }

/* ───────── Resumen ───────── */
.crt-sum { display: flex; flex-direction: column; gap: 1.3rem; min-width: 0; }
.crt-sum--sticky { position: sticky; top: 1.5rem; }
.crt-sum__title { font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-60);
                  padding-bottom: 1rem; border-bottom: 1px solid var(--ink); }
.crt-rows { display: flex; flex-direction: column; gap: 0.7rem; }
.crt-rows__r { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.88rem; }
.crt-rows__r span:first-child { color: var(--ink-60); }
.crt-rows__r b { font-weight: 500; }
.crt-rows__r--disc span, .crt-rows__r--disc b { color: var(--mint-deep); }
.crt-total { display: flex; justify-content: space-between; align-items: baseline;
             padding-top: 1.1rem; border-top: 1px solid var(--line); }
.crt-total__label { font-size: 0.82rem; letter-spacing: 0.06em; }
.crt-total__label small { display: block; font-size: 0.68rem; color: var(--ink-60); letter-spacing: 0; margin-top: 0.15rem; }
.crt-total__val { font-family: var(--serif); font-size: 2rem; }

/* Cupón */
.crt-coupon-wrap { display: flex; flex-direction: column; gap: 0.55rem; }
.crt-coupon { display: flex; border: 1px solid var(--line-strong); }
.crt-coupon input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit;
                    font-size: 0.82rem; padding: 0.85rem 1rem; outline: none; letter-spacing: 0.04em; color: var(--ink); }
.crt-coupon input::placeholder { color: var(--ink-40); letter-spacing: 0.1em; text-transform: uppercase; font-size: 0.72rem; }
.crt-coupon button { padding: 0 1.2rem; font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase;
                     font-weight: 500; border-left: 1px solid var(--line-strong); transition: all 0.15s ease; white-space: nowrap; }
.crt-coupon button:hover { background: var(--ink); color: var(--paper); }
.crt-coupon__msgs { display: flex; flex-direction: column; gap: 0.4rem; }
.crt-coupon__msg { font-size: 0.72rem; color: var(--mint-deep); display: flex; align-items: center; gap: 0.4rem; }
.crt-coupon__msg svg { width: 13px; height: 13px; flex-shrink: 0; }
.crt-coupon__msg.is-err { color: #b06a4f; }
.crt-coupon__rm { margin-left: auto; font-size: 1rem; line-height: 1; color: var(--ink-40); transition: color 0.15s ease; }
.crt-coupon__rm:hover { color: var(--ink); }

/* Addi */
.crt-addi { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem; background: #fff; border: 1px solid var(--line); font-size: 0.8rem; }
.crt-addi b { font-weight: 700; letter-spacing: -0.02em; }
.crt-addi span { color: var(--ink-60); }

/* CTA */
.crt-checkout { margin: 0; }

/* Confianza */
.crt-reassure { display: flex; flex-direction: column; gap: 0.7rem; }
.crt-reassure__r { display: flex; align-items: center; gap: 0.7rem; font-size: 0.78rem; color: var(--ink-60); }
.crt-reassure__r svg { width: 17px; height: 17px; color: var(--ink); flex-shrink: 0; }
.crt-pay { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
           padding-top: 1rem; border-top: 1px solid var(--line); }
.crt-pay__lbl { font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-40); }
.crt-pay__chips { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.crt-pay__chip { font-size: 0.62rem; font-weight: 600; letter-spacing: 0.04em; padding: 0.28rem 0.5rem;
                 border: 1px solid var(--line); color: var(--ink-60); }

/* ───────── Cross-sell ───────── */
.crt-cross { max-width: var(--maxw); margin: 0 auto; padding: 10px 2.2rem; }
section.crt-cross .crt-line__brand { display: none; }
section.crt-cross .rec-card__sub { display: none; }
.crt-cross__head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 2rem; }
.crt-cross__head h2 { font-family: var(--serif); font-size: 2.2rem; margin: 0; font-weight: 400; }
.crt-cross__head h2 em { font-style: italic; }
.crt-cross__head .eyebrow { color: var(--ink-60); }
section.crt-cross .crt-cross__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.6rem; }
.crt-cross__add { display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem;
                  letter-spacing: 0.14em; text-transform: uppercase; border: 1px solid var(--ink);
                  padding: 0.55rem 0.9rem; transition: all 0.15s ease; width: 100%; background: transparent;
                  color: var(--ink); font-weight: 500; line-height: 1; }
.crt-cross__add:hover { background: var(--ink); color: var(--paper); }
.crt-cross__add.loading { opacity: 0.6; pointer-events: none; }
.crt-cross__add.added { background: var(--mint-deep); border-color: var(--mint-deep); color: var(--paper); }
/* ocultar el “Ver carrito” que WooCommerce inyecta tras el botón */
.crt-cross .added_to_cart { display: none !important; }

/* ───────── Estado vacío ───────── */
.crt-empty { max-width: 560px; margin: 0 auto; padding: 5rem 2.2rem 4rem; text-align: center;
             display: flex; flex-direction: column; align-items: center; gap: 1.3rem; }
.crt-empty__icon { width: 92px; height: 92px; border-radius: 50%; background: var(--mint-tint);
                   display: flex; align-items: center; justify-content: center; }
.crt-empty__icon svg { width: 40px; height: 40px; color: var(--mint-deep); }
.crt-empty .eyebrow { color: var(--ink-60); }
.crt-empty__title { font-family: var(--serif); font-size: 2.6rem; line-height: 1.05; margin: 0; font-weight: 400; }
.crt-empty__title em { font-style: italic; }
.crt-empty__sub { font-size: 0.94rem; line-height: 1.6; color: var(--ink-60); max-width: 400px; margin: 0; }
.crt-empty__cta { margin-top: 0.6rem; }

/* ───────── Toast ───────── */
.am-toast { position: fixed; top: 1.4rem; right: 1.4rem; z-index: 9999; background: var(--ink); color: var(--paper);
            font-size: 0.78rem; letter-spacing: 0.02em; padding: 0.85rem 1.2rem; max-width: 320px;
            opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease; }
.am-toast.is-on { opacity: 1; transform: translateY(0); }

/* ───────── estado de carga (AJAX) ───────── */
.crt-ledger__lines.is-busy, .crt-sum.is-busy { opacity: 0.55; pointer-events: none; transition: opacity 0.15s ease; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .crt-head { padding: 2rem 1.2rem 1.2rem; }
  .crt-ledger { grid-template-columns: 1.4fr 1fr; gap: 2rem; padding: 0.5rem 1.2rem 3rem; }
  .crt-cross { padding: 1rem 1.2rem 3.5rem; }
  section.crt-cross .crt-cross__grid { gap: 1.2rem; }
}

@media (max-width: 768px) {
  /* El tema mete el carrito en un .container con max-width:85%, así que el
     contenido queda más angosto que la tienda (que va a ~16px del borde).
     Rompemos ese contenedor (full-bleed) y replicamos el mismo gutter de 16px. */
  .am-cart-page { width: 100vw; max-width: 100vw; margin-left: calc(50% - 50vw); }

  .crt-head { flex-direction: column; align-items: flex-start; gap: 0.8rem; padding: 1.6rem 16px 1rem; }
  .crt-head__title { font-size: 2.4rem; }

  .crt-ledger { grid-template-columns: 1fr; gap: 2rem; padding: 0.5rem 16px 2.5rem; }
  .crt-sum--sticky { position: static; }
  .crt-tbl__head { display: none; }
  .crt-line { grid-template-columns: 1fr auto; gap: 0.8rem 1rem; padding: 1.3rem 0; align-items: start; }
  .crt-line__prod { grid-column: 1 / -1; }
  .crt-thumb { width: 70px; height: 88px; }
  .crt-line__name { font-size: 1.15rem; }
  .crt-qty { grid-column: 1; margin: 0; justify-self: start; }
  .crt-line__total { grid-column: 2; grid-row: 2; font-size: 1.1rem; align-self: center; }

  .crt-cross { padding: 1rem 16px 3rem; }
  .crt-cross__head h2 { font-size: 1.8rem; }
  section.crt-cross .crt-cross__grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .crt-empty { padding: 3.5rem 16px 3rem; }
  .crt-empty__title { font-size: 2.1rem; }
  .am-toast { top: auto; bottom: 1.4rem; right: 1rem; left: 1rem; max-width: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   OVERRIDES · conflictos con el tema Samatex
   El tema pinta los <button> con su color de marca (melocotón). Forzamos
   los controles del carrito a fondo blanco/transparente con !important.
   ═══════════════════════════════════════════════════════════════════ */
.am-cart-page .crt-qty button,
.am-cart-page .crt-coupon button {
  background: #fff !important;
  border: 0 !important;
  border-radius: 0 !important;
  color: var(--ink) !important;
  box-shadow: none !important;
	margin:0px !important;
}
.am-cart-page .crt-qty button:hover:not(:disabled) { background: var(--paper-2) !important; }
.am-cart-page .crt-coupon button:hover { background: var(--ink) !important; color: #fff !important; }
.am-cart-page .crt-qty button:disabled { color: var(--ink-40) !important; }

/* Botón "+ Añadir al carrito" del cross-sell (fuera de .am-cart-page) */
.crt-cross__add {
  background: #fff !important;
  color: var(--ink) !important;
  border: 1px solid var(--line-strong) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.crt-cross__add:hover { background: var(--ink) !important; color: #fff !important; }
.crt-cross__add.added { background: var(--mint-deep) !important; border-color: var(--mint-deep) !important; color: #fff !important; }

/* Cupón · igualar altura de input y botón (el tema infla el botón con padding) */
.am-cart-page .crt-coupon { align-items: stretch; }
.am-cart-page .crt-coupon input,
.am-cart-page .crt-coupon button {
  height: 52px !important;
  min-height: 52px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: normal !important;
  box-sizing: border-box !important;
  margin-bottom: 0px;
}

/* ═══════════════════════════════════════════════════════════════════
   NOTICES DE WOOCOMMERCE  ("Producto se ha añadido", info, error)
   El tema los pinta en verde; los alineamos con la estética Amaría.
   ═══════════════════════════════════════════════════════════════════ */
body.am-cart .woocommerce-message,
body.am-cart .woocommerce-info,
body.am-cart .woocommerce-error {
  background: #fff !important;
  border: 1px solid var(--line) !important;
  border-top: 2px solid var(--ink) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: var(--ink) !important;
  font-family: var(--sans) !important;
  font-size: 0.9rem;
  line-height: 1.5;
  letter-spacing: 0.01em;
  padding: 1.1rem 1.4rem !important;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
}
body.am-cart .woocommerce-error { border-top-color: #b06a4f !important; }
/* Ícono ::before que añade WooCommerce/el tema */
body.am-cart .woocommerce-message::before,
body.am-cart .woocommerce-info::before { color: var(--mint-deep) !important; top: 1.1rem !important; }
body.am-cart .woocommerce-error::before { color: #b06a4f !important; top: 1.1rem !important; }

/* Botón "Ver carrito" dentro del notice */
body.am-cart .woocommerce-message .button,
body.am-cart .woocommerce-message a.button,
body.am-cart .woocommerce-info .button,
body.am-cart .woocommerce-info a.button {
  background: var(--ink) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.66rem !important;
  font-weight: 500 !important;
  padding: 0.75rem 1.3rem !important;
  margin: 0 0 0 auto !important;
  order: 2;
}
body.am-cart .woocommerce-message .button:hover,
body.am-cart .woocommerce-info .button:hover { background: var(--mint-deep) !important; color: #fff !important; }
