/* ============================================================
   AppleGang cart redesign — Etapa 1 (ECOA-1208)
   Pure visual shell. ALL rules are scoped under `.ag-cart-page`
   to keep classic theme styles intact. Design tokens follow the
   board-approved spec (navy / green / radii 8-14 / DM Sans).
   ============================================================ */

.ag-cart-page {
  --ag-navy: #1F2A44;
  --ag-green: #3DAA3F;
  --ag-green-dark: #339535;
  --ag-bg: #F8FAFC;
  --ag-surface: #FFFFFF;
  --ag-border: #E5E7EB;
  --ag-border-strong: #CBD5E1;
  --ag-text: #1F2A44;
  --ag-text-muted: #6B7280;
  --ag-warn: #D97706;
  --ag-warn-bg: #FFFBEB;
  --ag-danger: #DC2626;
  --ag-danger-bg: #FEE2E2;
  --ag-radius-sm: 8px;
  --ag-radius-md: 12px;
  --ag-radius-lg: 14px;
  --ag-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --ag-shadow-md: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .05);

  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ag-text);
  background: var(--ag-bg);
  padding: 32px 16px 64px;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
}
.ag-cart-page *, .ag-cart-page *::before, .ag-cart-page *::after { box-sizing: border-box; }

/* ---------- Header ---------------------------------------- */
.ag-cart-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.ag-cart-page__title {
  font-family: "Bricolage Grotesque", "DM Sans", sans-serif;
  font-weight: 600;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.2;
  margin: 0;
  color: var(--ag-navy);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.ag-cart-page__count {
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  color: var(--ag-text-muted);
  font-weight: 400;
}
.ag-cart-page__continue {
  color: var(--ag-navy);
  font-size: 14px;
  text-decoration: none;
  font-weight: 500;
}
.ag-cart-page__continue:hover { color: var(--ag-green); text-decoration: underline; }

/* ---------- Layout grid ----------------------------------- */
.ag-cart-page__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 991px) {
  .ag-cart-page__grid { grid-template-columns: 1fr; }
}

.ag-cart-page__main { min-width: 0; }

/* ---------- Items column ---------------------------------- */
.ag-cart-items { display: grid; gap: 12px; margin: 0; padding: 0; }

/* ---------- Item row -------------------------------------- */
.ag-cart-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto auto auto;
  grid-template-areas: "img info qty price remove";
  gap: 16px;
  align-items: center;
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-md);
  padding: 14px;
  box-shadow: var(--ag-shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}
.ag-cart-row:hover {
  box-shadow: var(--ag-shadow-md);
  border-color: var(--ag-border-strong);
}

@media (max-width: 767px) {
  .ag-cart-row {
    grid-template-columns: 72px minmax(0, 1fr) auto;
    grid-template-areas:
      "img  info   remove"
      "qty  qty    price";
    gap: 12px;
    padding: 12px;
  }
}

.ag-cart-row__image {
  grid-area: img;
  width: 92px;
  height: 92px;
  border-radius: var(--ag-radius-sm);
  overflow: hidden;
  background: #F1F5F9;
  flex-shrink: 0;
  display: block;
}
@media (max-width: 767px) {
  .ag-cart-row__image { width: 72px; height: 72px; }
}
.ag-cart-row__image a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.ag-cart-row__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.ag-cart-row__image-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #E2E8F0, #F8FAFC);
}

.ag-cart-row__info {
  grid-area: info;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ag-cart-row__brand {
  font-size: 11px;
  color: var(--ag-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}
.ag-cart-row__name {
  color: var(--ag-navy);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  line-height: 1.35;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ag-cart-row__name:hover { color: var(--ag-green); text-decoration: none; }
.ag-cart-row__variant {
  font-size: 13px;
  color: var(--ag-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.ag-cart-row__variant-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #CBD5E1, #94A3B8);
  border: 1px solid var(--ag-border);
  flex-shrink: 0;
}
.ag-cart-row__stock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-top: 4px;
  font-weight: 500;
}
.ag-cart-row__stock-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ag-green);
  flex-shrink: 0;
}
.ag-cart-row__stock--in { color: var(--ag-green); }
.ag-cart-row__stock--low { color: var(--ag-warn); }
.ag-cart-row__stock--low .ag-cart-row__stock-dot { background: var(--ag-warn); }
.ag-cart-row__stock--out { color: var(--ag-danger); }
.ag-cart-row__stock--out .ag-cart-row__stock-dot { background: var(--ag-danger); }
.ag-cart-row__stock--info { color: var(--ag-text-muted); }
.ag-cart-row__stock--info .ag-cart-row__stock-dot { background: var(--ag-text-muted); }
.ag-cart-row__customization { margin-top: 4px; }
.ag-cart-row__customization small { display: block; color: var(--ag-text-muted); font-size: 12px; }

/* ---------- Qty stepper ----------------------------------- */
.ag-cart-row__qty { grid-area: qty; }
.ag-cart-qty-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-sm);
  overflow: hidden;
  background: #fff;
}
.ag-cart-qty-stepper__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 36px;
  color: var(--ag-navy);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  user-select: none;
  background: #F8FAFC;
  transition: background .12s;
}
.ag-cart-qty-stepper__btn:hover { background: #E2E8F0; text-decoration: none; color: var(--ag-navy); }
.ag-cart-qty-stepper__input {
  width: 44px;
  height: 36px;
  border: 0;
  border-left: 1px solid var(--ag-border);
  border-right: 1px solid var(--ag-border);
  text-align: center;
  font-weight: 600;
  color: var(--ag-navy);
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  font-size: 14px;
  background: #fff;
  -moz-appearance: textfield;
}
.ag-cart-qty-stepper__input::-webkit-outer-spin-button,
.ag-cart-qty-stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ag-cart-qty-stepper__input:focus { outline: 2px solid var(--ag-green); outline-offset: -2px; }

/* ---------- Price ---------------------------------------- */
.ag-cart-row__price {
  grid-area: price;
  text-align: right;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.ag-cart-row__price-old {
  font-size: 12px;
  color: var(--ag-text-muted);
  text-decoration: line-through;
}
.ag-cart-row__price-current {
  font-family: "Bricolage Grotesque", "DM Sans", sans-serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--ag-navy);
  line-height: 1.1;
}
.ag-cart-row__price-unit {
  font-size: 11px;
  color: var(--ag-text-muted);
}

/* ---------- Remove --------------------------------------- */
.ag-cart-row__remove { grid-area: remove; }
.ag-cart-row__remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--ag-text-muted);
  border-radius: var(--ag-radius-sm);
  background: transparent;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.ag-cart-row__remove-btn:hover {
  color: var(--ag-danger);
  background: var(--ag-danger-bg);
  text-decoration: none;
}

/* ---------- Summary column (sticky) ----------------------- */
.ag-cart-page__aside { position: sticky; top: 24px; align-self: start; }
@media (max-width: 991px) {
  .ag-cart-page__aside { position: static; top: auto; }
}

.ag-cart-summary {
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-lg);
  padding: 20px;
  box-shadow: var(--ag-shadow-md);
  display: grid;
  gap: 16px;
}
.ag-cart-summary__header h2 {
  font-family: "Bricolage Grotesque", "DM Sans", sans-serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--ag-navy);
  margin: 0;
}

.ag-cart-summary__lines { display: grid; gap: 8px; }
.ag-cart-summary__line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--ag-text);
}
.ag-cart-summary__line-label { color: var(--ag-text-muted); }
.ag-cart-summary__line-value { font-weight: 500; }
.ag-cart-summary__line--discount .ag-cart-summary__line-value { color: var(--ag-green); }
.ag-cart-summary__line--shipping .ag-cart-summary__line-label { color: var(--ag-text); font-weight: 500; }
/* Shipping placeholder before a carrier is chosen (ECOA-1639 #7). */
.ag-cart-summary__line-value--ph { color: var(--ag-text-muted); font-weight: 400; font-style: italic; }

.ag-cart-summary__total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ag-border);
  font-weight: 700;
  font-size: 16px;
  align-items: baseline;
}
.ag-cart-summary__total-value {
  font-family: "Bricolage Grotesque", "DM Sans", sans-serif;
  font-size: 22px;
  color: var(--ag-navy);
  line-height: 1.1;
}
.ag-cart-summary__tax-note { font-size: 12px; color: var(--ag-text-muted); margin-top: -8px; }

.ag-cart-summary__min-purchase {
  background: var(--ag-warn-bg);
  color: var(--ag-warn);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--ag-radius-sm);
  border: 1px solid #FCD34D;
}

/* ---------- Voucher / discount code ----------------------- */
.ag-cart-voucher { display: grid; gap: 10px; }
.ag-cart-voucher__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ag-cart-voucher__applied {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(61, 170, 63, .08);
  border: 1px solid rgba(61, 170, 63, .25);
  border-radius: var(--ag-radius-sm);
  padding: 8px 10px;
  font-size: 13px;
}
.ag-cart-voucher__applied-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ag-green-dark);
  font-weight: 600;
  min-width: 0;
}
.ag-cart-voucher__applied-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ag-cart-voucher__applied-name small { color: var(--ag-text-muted); font-weight: 500; flex-shrink: 0; }
.ag-cart-voucher__remove {
  color: var(--ag-text-muted);
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  flex-shrink: 0;
}
.ag-cart-voucher__remove:hover { color: var(--ag-danger); text-decoration: none; }
.ag-cart-voucher__label {
  font-size: 11px;
  color: var(--ag-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}
.ag-cart-voucher__row { display: flex; gap: 8px; }
.ag-cart-voucher__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-sm);
  padding: 0 12px;
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  color: var(--ag-navy);
  background: #fff;
}
.ag-cart-voucher__input::placeholder { color: #9CA3AF; }
.ag-cart-voucher__input:focus { outline: 2px solid var(--ag-green); outline-offset: -1px; border-color: var(--ag-green); }
.ag-cart-voucher__btn {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--ag-navy);
  background: var(--ag-navy);
  color: #fff;
  border-radius: var(--ag-radius-sm);
  font-family: "DM Sans", sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.ag-cart-voucher__btn:hover { background: #16203a; border-color: #16203a; }

.ag-cart-summary__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ag-green);
  color: #fff !important;
  border-radius: var(--ag-radius-md);
  padding: 14px 18px;
  font-weight: 600;
  text-decoration: none;
  font-size: 16px;
  font-family: "DM Sans", sans-serif;
  transition: background .15s, transform .15s, box-shadow .15s;
  box-shadow: 0 4px 12px rgba(61, 170, 63, .25);
  border: 0;
  cursor: pointer;
}
.ag-cart-summary__cta:hover {
  background: var(--ag-green-dark);
  text-decoration: none;
  color: #fff;
  box-shadow: 0 6px 16px rgba(61, 170, 63, .35);
}
.ag-cart-summary__cta.disabled {
  background: #94A3B8;
  box-shadow: none;
  pointer-events: none;
  opacity: .7;
}
.ag-cart-summary__cta-arrow { transition: transform .15s; display: inline-block; }
.ag-cart-summary__cta:hover .ag-cart-summary__cta-arrow { transform: translateX(3px); }

/* ---------- Trust block ----------------------------------- */
.ag-cart-trust {
  list-style: none;
  padding: 12px 0 0;
  margin: 0;
  border-top: 1px dashed var(--ag-border);
  display: grid;
  gap: 10px;
}
.ag-cart-trust__item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.ag-cart-trust__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(61, 170, 63, .10);
  color: var(--ag-green);
  flex-shrink: 0;
}
.ag-cart-trust__text { display: flex; flex-direction: column; }
.ag-cart-trust__text strong { color: var(--ag-navy); font-weight: 600; font-size: 13px; }
.ag-cart-trust__text small { color: var(--ag-text-muted); font-size: 12px; }

/* ---------- Payment chips --------------------------------- */
.ag-cart-payments {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--ag-border);
}
.ag-cart-payments__label {
  font-size: 11px;
  color: var(--ag-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}
.ag-cart-payments__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-cart-pay-chip {
  font-size: 11px;
  padding: 5px 10px;
  background: #F1F5F9;
  color: var(--ag-navy);
  border: 1px solid var(--ag-border);
  border-radius: 999px;
  font-weight: 500;
  line-height: 1;
}

/* ---------- Empty state ----------------------------------- */
.ag-cart-empty {
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-lg);
  padding: 48px 24px;
  text-align: center;
  box-shadow: var(--ag-shadow-sm);
}
.ag-cart-empty p {
  color: var(--ag-text-muted);
  font-size: 16px;
  margin: 0 0 16px;
}
.ag-cart-empty__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ag-green);
  color: #fff !important;
  padding: 12px 20px;
  border-radius: var(--ag-radius-md);
  text-decoration: none;
  font-weight: 600;
}
.ag-cart-empty__cta:hover { background: var(--ag-green-dark); color: #fff; text-decoration: none; }

/* ---------- Etapa 2: AJAX interaction states (ECOA-1209) -- */
/* Busy / loading feedback while a mutation is in flight. */
.ag-cart-page--busy { cursor: progress; }
.ag-cart-page--busy .ag-cart-qty-stepper,
.ag-cart-page--busy .ag-cart-voucher__btn { pointer-events: none; }
.ag-cart-row--loading { opacity: .55; transition: opacity .15s; }
.ag-cart-row--loading .ag-cart-qty-stepper,
.ag-cart-row--loading .ag-cart-row__remove-btn { pointer-events: none; }

/* Highlight a freshly applied voucher row. */
@keyframes agVoucherFlash {
  0%   { background: rgba(61, 170, 63, .35); }
  100% { background: rgba(61, 170, 63, .08); }
}
.ag-cart-voucher__applied--new { animation: agVoucherFlash 1.6s ease-out; }

/* ---------- Etapa 2: Free-shipping progress bar (ECOA-1209)
   Feature-flag gated — only rendered when the module flag is ON and a
   threshold is configured. Default state ships nothing. */
.ag-freeship {
  display: grid;
  gap: 8px;
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: var(--ag-shadow-sm);
}
.ag-freeship__text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ag-text);
}
.ag-freeship__text strong { color: var(--ag-navy); font-weight: 700; }
.ag-freeship__icon { color: var(--ag-green); flex-shrink: 0; }
.ag-freeship__track {
  height: 8px;
  border-radius: 999px;
  background: #E2E8F0;
  overflow: hidden;
}
.ag-freeship__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--ag-green);
  transition: width .35s ease;
}
.ag-freeship--qualified .ag-freeship__text { color: var(--ag-green-dark); font-weight: 600; }
.ag-freeship--qualified .ag-freeship__fill { background: var(--ag-green-dark); }

/* ---------- Cross-sell "Hodí se k tomu" (ECOA-1210) -------- */
.ag-cart-page .ag-crosssell {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--ag-border);
}
.ag-cart-page .ag-crosssell__title {
  font-family: "Bricolage Grotesque", "DM Sans", sans-serif;
  font-weight: 600;
  font-size: 20px;
  color: var(--ag-navy);
  margin: 0 0 16px;
}
.ag-cart-page .ag-crosssell__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.ag-cart-page .ag-crosssell__grid .product-miniature,
.ag-cart-page .ag-crosssell__grid > article,
.ag-cart-page .ag-crosssell__grid > .js-product {
  margin: 0;
  width: auto;
}
@media (max-width: 575px) {
  .ag-cart-page .ag-crosssell__grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
