/* ========== صفحه سبد خرید — سبک دیجیکالا ========== */
:root {
  --cart-red: #ef394e;
  --cart-green: #00a049;
  --cart-text: #0c0c0c;
  --cart-muted: #81858b;
  --cart-hint: #a1a3a8;
  --cart-border: #e0e0e2;
  --cart-bg: #f5f5f5;
  --font: "Yekan Bakh", "YekanBakh", Estedad, Vazirmatn, Tahoma, sans-serif;
}

/* بدون fnav: فقط جا برای نوار معلق پایین */
body.cart-page {
  margin: 0;
  background: var(--cart-bg);
  font-family: var(--font);
  color: var(--cart-text);
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
}
.cart-page .site-footer {
  margin-top: 24px;
  margin-bottom: 8px;
}
body.cart-page.is-empty {
  padding-bottom: 24px;
}
.cart-page a,
.cart-page button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.ti-icon--flame { --ti: url("icons/tabler/flame.svg"); }
.ti-icon--gift { --ti: url("icons/tabler/gift.svg"); }
.ti-icon--shield-check { --ti: url("icons/tabler/shield-check.svg"); }
.ti-icon--plus { --ti: url("icons/tabler/plus.svg"); }
.ti-icon--minus { --ti: url("icons/tabler/minus.svg"); }
.ti-icon--trash { --ti: url("icons/tabler/trash.svg"); }
.ti-icon--check { --ti: url("icons/tabler/check.svg"); }
.ti-icon--chevron-left { --ti: url("icons/tabler/chevron-left.svg"); }
.ti-icon--chevron-down { --ti: url("icons/tabler/chevron-down.svg"); }
.ti-icon--arrow-back { --ti: url("icons/tabler/arrow-back-up.svg"); }
.ti-icon--shopping-cart { --ti: url("icons/tabler/shopping-cart.svg"); }

.cart-page .header {
  position: sticky;
  top: 0;
  z-index: 100;
}

.cart-page-heading {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 800;
  color: var(--cart-text);
}

.cart-main {
  padding-top: 16px;
  padding-bottom: 32px;
}

/* Layout */
.cart-layout {
  display: grid;
  gap: 16px;
  align-items: start;
}
@media (min-width: 960px) {
  .cart-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
  }
  .cart-suggest {
    grid-column: 1 / -1;
  }
  body.cart-page { padding-bottom: 24px; }
}

.cart-maincol {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.cart-box,
.cart-pay,
.cart-suggest {
  background: #fff;
  border: 1px solid var(--cart-border);
  border-radius: 12px;
}

.cart-box__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f1;
}
.cart-box__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}
.cart-box__head span {
  font-size: 13px;
  color: var(--cart-muted);
  font-weight: 600;
}

.cart-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Item row */
.cart-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid #f0f0f1;
  animation: cartItemIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.cart-item:last-child { border-bottom: 0; }

/* تأیید حذف ۵ ثانیه‌ای */
.cart-undo {
  list-style: none;
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--cart-border);
  animation: cartUndoIn 0.4s cubic-bezier(0.22, 1.15, 0.36, 1) both;
}
@keyframes cartUndoIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.cart-undo__card {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: linear-gradient(160deg, #fff5f6 0%, #ffffff 55%);
  border: 1px solid #ffd6db;
  box-shadow: 0 8px 24px rgba(239, 57, 78, 0.08);
  padding: 16px 14px 14px;
  text-align: center;
}
.cart-undo__glow {
  position: absolute;
  inset: -40% auto auto 50%;
  width: 160px;
  height: 160px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(239, 57, 78, 0.16), transparent 68%);
  pointer-events: none;
}
.cart-undo__icon {
  position: relative;
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #ef394e;
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(239, 57, 78, 0.28);
}
.cart-undo__icon .ti-icon {
  width: 22px;
  height: 22px;
  font-size: 22px;
  color: #fff;
}
.cart-undo__ask {
  position: relative;
  margin: 0 0 6px;
  color: #0c0c0c;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.6;
}
.cart-undo__name {
  position: relative;
  margin: 0 0 12px;
  color: #81858b;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cart-undo__track {
  position: relative;
  height: 4px;
  border-radius: 99px;
  background: #ffe3e7;
  overflow: hidden;
  margin-bottom: 12px;
}
.cart-undo__fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ef394e, #ff7a8a);
  transform-origin: right center;
  animation: cartUndoBar 5s linear forwards;
}
@keyframes cartUndoBar {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}
.cart-undo__back {
  position: relative;
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: #0c0c0c;
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.cart-undo__back:hover {
  background: #232933;
}
.cart-undo__back:active {
  transform: scale(0.98);
}
.cart-undo__back .ti-icon {
  width: 18px;
  height: 18px;
  font-size: 18px;
  color: #fff;
}

@keyframes cartItemIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.cart-item > a:first-child {
  display: block;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}
.cart-item__img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 8px;
  background: #fafafa;
  border: 1px solid #f0f0f1;
  display: block;
}
.cart-item__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cart-item__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.75;
  color: #424750;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cart-item__title a {
  color: inherit;
  text-decoration: none;
}
.cart-item__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--cart-muted);
}
.cart-item__meta-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cart-item__meta-row .ti-icon {
  width: 14px;
  height: 14px;
  font-size: 14px;
  color: var(--cart-hint);
}
.cart-item__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.cart-item__price {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.cart-item__old {
  font-size: 12px;
  color: var(--cart-hint);
  text-decoration: line-through;
  direction: ltr;
  unicode-bidi: plaintext;
}
.cart-item__off {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 16px;
  background: var(--cart-red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.cart-item__now {
  font-size: 16px;
  font-weight: 800;
  color: var(--cart-text);
  direction: ltr;
  unicode-bidi: plaintext;
}
.cart-item__now span {
  font-size: 11px;
  font-weight: 500;
  color: var(--cart-muted);
  margin-inline-start: 4px;
}

.cart-item__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}
.cart-qty {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  min-width: 110px;
  height: 40px;
  padding: 0 4px;
  border: 1px solid var(--cart-border);
  border-radius: 10px;
  background: #fff;
}
.cart-qty button {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--cart-red);
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 8px;
}
.cart-qty button .ti-icon {
  width: 18px;
  height: 18px;
  font-size: 18px;
  color: inherit;
}
.cart-qty em {
  font-style: normal;
  font-size: 15px;
  font-weight: 800;
  color: var(--cart-red);
  min-width: 20px;
  text-align: center;
}
/* Payment */
.cart-side {
  display: grid;
  gap: 12px;
}
@media (min-width: 960px) {
  .cart-side {
    position: sticky;
    top: 80px;
  }
}
.cart-pay {
  padding: 18px 16px 16px;
}
.cart-pay h2 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 800;
}
.cart-pay__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #424750;
}
.cart-pay__row strong {
  font-weight: 700;
  direction: ltr;
  unicode-bidi: plaintext;
  color: var(--cart-text);
}
.cart-pay__row.is-profit span,
.cart-pay__row.is-profit strong {
  color: var(--cart-green);
  font-weight: 700;
}
.cart-pay__row.is-total {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f1;
  font-weight: 700;
}
.cart-pay__row.is-total strong {
  font-size: 16px;
  font-weight: 800;
}
.cart-pay__btn {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  border: 0;
  border-radius: 10px;
  background: var(--cart-red);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.cart-pay__btn:hover { background: #e02e44; }
.cart-pay__btn:active { transform: scale(0.98); }
.cart-pay__note {
  margin: 12px 0 0;
  font-size: 11px;
  line-height: 1.8;
  color: var(--cart-hint);
  text-align: center;
}

/* Suggest — زیر جزئیات پرداخت */
.cart-suggest {
  padding: 16px 0 12px;
  overflow: hidden;
}
.cart-suggest__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 12px;
}
.cart-suggest__head .ti-icon {
  width: 20px;
  height: 20px;
  font-size: 20px;
  color: var(--cart-red);
}
.cart-suggest__head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}
.cart-suggest__track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 16px 8px;
  -webkit-overflow-scrolling: touch;
}
.cart-suggest__track::-webkit-scrollbar { display: none; }
.cart-sugg-card {
  flex: 0 0 168px;
  width: 168px;
}
.cart-sugg-card a {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  height: 100%;
}
.cart-sugg-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
  background: #fafafa;
}
.cart-sugg-card h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.65;
  color: #424750;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}
.cart-sugg-card__tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--cart-red);
}
.cart-sugg-card__price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-top: auto;
}
.cart-sugg-card__off {
  display: inline-flex;
  height: 18px;
  padding: 0 5px;
  border-radius: 16px;
  background: var(--cart-red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  align-items: center;
}
.cart-sugg-card__price s {
  font-size: 11px;
  color: var(--cart-hint);
  direction: ltr;
}
.cart-sugg-card__price strong {
  font-size: 14px;
  font-weight: 800;
  direction: ltr;
  unicode-bidi: plaintext;
}
.cart-sugg-card__price em {
  font-style: normal;
  font-size: 10px;
  color: var(--cart-muted);
}

/* Empty */
.cart-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 20px;
  background: #fff;
  border: 1px solid var(--cart-border);
  border-radius: 12px;
  margin-top: 8px;
}
.cart-page.is-empty .cart-empty { display: flex; }
.cart-page.is-empty .cart-layout,
.cart-page.is-empty .cart-mobar { display: none !important; }
.cart-empty__ico {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(160deg, #fff1f2, #f5f5f5);
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  animation: cartEmptyPop 0.5s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}
.cart-empty__ico .ti-icon {
  width: 40px;
  height: 40px;
  font-size: 40px;
  color: var(--cart-red);
  opacity: 0.85;
}
@keyframes cartEmptyPop {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: none; }
}
.cart-empty h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 800;
}
.cart-empty p {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--cart-muted);
}
.cart-empty__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 24px;
  border-radius: 10px;
  background: var(--cart-red);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

/* Mobile sticky bar — چسبیده به کف (بدون fnav) */
.cart-mobar {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid var(--cart-border);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
}
.cart-mobar__price {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cart-mobar__price span {
  font-size: 11px;
  color: var(--cart-muted);
}
.cart-mobar__price strong {
  font-size: 14px;
  font-weight: 800;
  direction: ltr;
  unicode-bidi: plaintext;
}
.cart-mobar__btn {
  flex: 1;
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--cart-red);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
@media (min-width: 960px) {
  .cart-mobar { display: none !important; }
  body.cart-page,
  body.cart-page.is-empty {
    padding-bottom: 24px;
  }
}

/* Checkout address sheet — بالاتر از هدر/fnav */
.chk-sheet[hidden] { display: none !important; }
.chk-sheet {
  position: fixed;
  inset: 0;
  z-index: 360;
  display: grid;
  place-items: end center;
}
.chk-sheet__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(12, 12, 12, .48);
  opacity: 0;
  transition: opacity .28s ease;
}
.chk-sheet.is-open .chk-sheet__backdrop { opacity: 1; }
.chk-sheet__panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(92vh, 820px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px 18px 0 0;
  transform: translateY(110%);
  transition: transform .32s cubic-bezier(.22, 1, .36, 1);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, .2);
}
.chk-sheet.is-open .chk-sheet__panel { transform: none; }
.chk-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f1;
  flex-shrink: 0;
}
.chk-sheet__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}
.chk-sheet__close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #f5f5f5;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #424750;
}
.chk-sheet__body {
  overflow: auto;
  padding: 14px 16px 10px;
  flex: 1;
  min-height: 0;
}
.chk-sheet__foot {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #f0f0f1;
  flex-shrink: 0;
  background: #fff;
}
.chk-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: #f5f5f5;
}
.chk-tab {
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  color: #81858b;
  cursor: pointer;
}
.chk-tab.is-on {
  background: #fff;
  color: #0c0c0c;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}
.chk-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: #81858b;
  line-height: 1.6;
  font-weight: 500;
}
.chk-addr-list {
  display: grid;
  gap: 8px;
}
.chk-addr {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid #e0e0e2;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.chk-addr.is-on {
  border-color: #ef394e;
  background: #fff8f9;
  box-shadow: 0 0 0 1px rgba(239, 57, 78, .15);
}
.chk-addr input { margin-top: 3px; accent-color: #ef394e; }
.chk-addr strong {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
}
.chk-addr em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: #62666d;
  line-height: 1.55;
}
.chk-manage {
  display: inline-block;
  margin-top: 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f62fe;
  text-decoration: none;
}
.chk-form {
  display: grid;
  gap: 10px;
}
.chk-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #424750;
}
.chk-form input,
.chk-form textarea {
  height: 44px;
  border: 1px solid #e0e0e2;
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
  width: 100%;
  background: #fff;
}
.chk-form textarea {
  height: auto;
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
}
.chk-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.chk-save-opt {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  font-weight: 600 !important;
}
.chk-save-opt input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: #ef394e;
  flex-shrink: 0;
}
.chk-submit {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--cart-red);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.cart-toast[hidden] { display: none !important; }
.cart-toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  z-index: 100;
  max-width: min(90vw, 360px);
  padding: 12px 16px;
  border-radius: 12px;
  background: #1a1a1a;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
  text-align: center;
}
.cart-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 560px) {
  .cart-item {
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 10px;
    padding: 14px 12px;
  }
  .cart-item__img { width: 80px; height: 80px; }
  .cart-sugg-card { flex-basis: 148px; width: 148px; }
  .chk-row { grid-template-columns: 1fr; }
}
