/* =========================================================
   Dark Sistem – Cart page
   Uses the tokens from main.css (light + dark). RTL-first.
   Every selector is namespaced .cp-* so nothing else is touched.
   ========================================================= */

.cp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Hero (dark in both themes) ---------- */
.cp-hero { position: relative; isolation: isolate; overflow: hidden; background: #07051f; color: #fff; border-bottom: 1px solid rgba(139, 92, 246, .35); }
.cp-hero__bg { position: absolute; inset: 0; z-index: -1; background: #0a133b url("../img/cart-hero.webp") 100% center / cover no-repeat; }
.cp-hero__bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to right, rgba(6, 5, 26, .78) 0, rgba(6, 5, 26, .25) 30%, rgba(6, 5, 26, 0) 46%, rgba(6, 5, 26, 0) 66%, rgba(6, 5, 26, .55) 86%, rgba(6, 5, 26, .85) 100%); }
.cp-hero__in { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; min-height: clamp(130px, 18vw, 190px); padding-block: 1.4rem; }
.cp-hero__title { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.cp-hero__title > div { min-width: 0; }
.cp-hero__ic { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border-radius: 16px; border: 1px solid rgba(167, 139, 250, .55); background: rgba(14, 11, 40, .6); color: #d8c7ff; box-shadow: 0 0 24px -4px rgba(139, 92, 246, .7); }
.cp-hero__ic .i { width: 26px; height: 26px; }
.cp-hero h1 { font-family: var(--display); font-size: clamp(1.9rem, 5vw, 2.8rem); font-weight: 400; line-height: 1.25; color: #fff; text-shadow: 0 0 22px rgba(139, 92, 246, .55); }
.cp-hero__title p { margin-top: .15rem; font-size: clamp(.82rem, 1.6vw, .98rem); color: #e4dfff; }
.cp-hero__tag { font-size: clamp(.9rem, 1.8vw, 1.1rem); line-height: 1.9; color: #fff; text-align: start; }
.cp-hero__tag span { color: #cdbaff; }
@media (max-width: 719px) {
  .cp-hero__bg::after { background: linear-gradient(to left, rgba(6, 5, 26, .88) 0, rgba(6, 5, 26, .62) 55%, rgba(6, 5, 26, .12) 100%); }
  .cp-hero__tag { display: none; }
  .cp-hero__title p { text-wrap: balance; }
}
/* narrow phones: no room beside the title for the cart drawing -> show only the lightning part of the image */
@media (max-width: 479px) {
  .cp-hero__bg { background-position: left center; }
  .cp-hero__bg::after { background: linear-gradient(to left, rgba(6, 5, 26, .82), rgba(6, 5, 26, .4)); }
}

/* ---------- Layout ---------- */
.cp-wrap { padding-block: clamp(1.2rem, 3vw, 2rem) clamp(2.4rem, 6vw, 4rem); }
.cp-grid { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: clamp(.9rem, 2vw, 1.4rem); align-items: start; }
.cp-side { display: grid; gap: clamp(.9rem, 2vw, 1.2rem); position: sticky; top: calc(var(--header-h) + 16px); }
.cp-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }
:root[data-theme="dark"] .cp-card { background: linear-gradient(180deg, #0f0c2a, #0a0820); }
.cp-card h2 { font-size: 1.05rem; font-weight: 800; color: var(--text-strong); line-height: 1.5; }

@media (max-width: 991px) {
  .cp-grid { grid-template-columns: minmax(0, 1fr); }
  /* the aside's cards join the grid so only the summary goes above the list (coupon + trust stay below it) */
  .cp-side { display: contents; }
  .cp-sum { order: 1; }
  .cp-list { order: 2; }
  .cp-coupon { order: 3; }
  .cp-trust { order: 4; }
  .cp-sum .cp-checkout, .cp-sum .cp-terms { display: none; }       /* the sticky bar takes over */
  .cp-wrap { padding-bottom: 6.5rem; }
}

/* ---------- Summary ---------- */
.cp-sum { padding: clamp(1.1rem, 2.4vw, 1.4rem); }
.cp-rows { display: grid; gap: .8rem; margin-top: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed var(--line); }
.cp-rows > div { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: .88rem; }
.cp-rows dt { display: flex; align-items: center; gap: .45rem; color: var(--muted); }
.cp-rows dt .i { width: 16px; height: 16px; }
.cp-rows dd { color: var(--text-strong); font-weight: 600; }
.cp-rows dd small, .cp-total small { font-weight: 500; font-size: .75rem; color: var(--muted); }
.cp-free { color: #22c55e !important; }
.cp-disc { color: var(--red) !important; }
.cp-total { display: grid; gap: .45rem; margin: 1rem 0 1.1rem; }
.cp-total > span { font-size: .95rem; font-weight: 700; color: var(--text-strong); }
.cp-total strong { display: flex; align-items: center; gap: .55rem; font-size: 1.55rem; font-weight: 800; color: var(--accent); line-height: 1.4; }
:root[data-theme="dark"] .cp-total strong { color: #c4a8ff; }
.cp-total strong .i { width: 24px; height: 24px; opacity: .85; }
.cp-total strong small { font-size: .8rem; }

.cp-checkout {
  display: flex; align-items: center; justify-content: center; gap: .6rem; width: 100%; min-height: 52px; border: 0; border-radius: 14px;
  background: var(--btn-bg); color: var(--on-accent); font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; box-shadow: var(--btn-shadow);
  transition: transform .18s, filter .18s, opacity .18s;
}
:root[data-theme="dark"] .cp-checkout { background: linear-gradient(90deg, #6d28d9, #8b5cf6 55%, #a78bfa); }
.cp-checkout:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.cp-checkout:focus-visible, .cp-btn:focus-visible, .cp-link:focus-visible, .cp-qty button:focus-visible, .cp-ico:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cp-checkout:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.cp-checkout.is-loading span::before { content: ""; display: inline-block; width: 15px; height: 15px; margin-inline-end: .5rem; vertical-align: -2px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: cp-spin .7s linear infinite; }
@keyframes cp-spin { to { transform: rotate(360deg); } }
.cp-hint { margin-bottom: .8rem; padding: .6rem .8rem; border-radius: 10px; border: 1px solid rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .1); color: #d97706; font-size: .8rem; line-height: 1.8; }
:root[data-theme="dark"] .cp-hint { color: #fbbf24; }
.cp-hint[hidden] { display: none; }
.cp-terms { margin-top: .8rem; text-align: center; font-size: .74rem; color: var(--muted); line-height: 1.8; }
.cp-terms a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
:root[data-theme="dark"] .cp-terms a { color: #b79bff; }

/* ---------- Coupon ---------- */
.cp-coupon { padding: clamp(1rem, 2.4vw, 1.3rem); }
.cp-coupon h2 { display: flex; align-items: center; gap: .5rem; font-size: .95rem; }
.cp-coupon h2 .i { width: 18px; height: 18px; color: var(--accent); }
:root[data-theme="dark"] .cp-coupon h2 .i { color: #b79bff; }
.cp-coupon__form { display: flex; gap: .5rem; margin-top: .8rem; }
.cp-coupon__form input { flex: 1; min-width: 0; height: 44px; padding-inline: .9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: max(16px, .9rem); text-align: right; outline: 0; transition: border-color .15s, box-shadow .15s; }
:root[data-theme="dark"] .cp-coupon__form input { background: rgba(21, 18, 54, .7); }
.cp-coupon__form input::placeholder { color: var(--muted); font-size: .82rem; }
.cp-coupon__form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cp-coupon__btn { flex: none; padding-inline: 1.1rem; height: 44px; border: 0; border-radius: 10px; background: var(--btn-bg); color: #fff; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; transition: filter .15s; }
:root[data-theme="dark"] .cp-coupon__btn { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.cp-coupon__btn:hover { filter: brightness(1.1); }
.cp-coupon__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cp-coupon__msg { margin-top: .6rem; font-size: .8rem; line-height: 1.8; color: #ff4d6d; }
.cp-coupon__msg.is-ok { color: #22c55e; }
.cp-coupon__msg[hidden] { display: none; }
.cp-coupon__clear { margin-top: .55rem; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: .78rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.cp-coupon__clear:hover { color: var(--accent); }
.cp-coupon__clear[hidden] { display: none; }

/* ---------- Trust ---------- */
.cp-trust { padding: .4rem 1.1rem; }
.cp-trust ul { display: grid; }
.cp-trust li { display: flex; align-items: center; gap: .8rem; padding: .85rem 0; }
.cp-trust li + li { border-top: 1px solid var(--line); }
.cp-trust__ic { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .cp-trust__ic { color: #c4a8ff; border-color: rgba(167, 139, 250, .45); }
.cp-trust__ic .i { width: 20px; height: 20px; }
.cp-trust strong { display: block; font-size: .88rem; font-weight: 700; color: var(--text-strong); }
.cp-trust small { font-size: .76rem; color: var(--muted); }

/* ---------- Items list ---------- */
.cp-list { padding: clamp(.9rem, 2.2vw, 1.3rem); }
.cp-list__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: .9rem; margin-bottom: .9rem; border-bottom: 1px solid var(--line); }
.cp-list__head h2 { font-size: .92rem; font-weight: 600; color: var(--muted); }
.cp-list__head h2 b { color: var(--text-strong); font-weight: 800; }
.cp-list__clear { display: flex; align-items: center; gap: .6rem; font-size: .84rem; }
.cp-link { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .5rem; border: 0; border-radius: 8px; background: transparent; color: var(--accent); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; transition: background .15s; }
:root[data-theme="dark"] .cp-link { color: #b79bff; }
.cp-link:hover { background: var(--accent-soft); }
.cp-link--danger { color: #ff4d6d; }
:root[data-theme="dark"] .cp-link--danger { color: #ff7a93; }
.cp-link--danger:hover { background: rgba(255, 77, 109, .12); }
.cp-link--solid { background: #e11d48; color: #fff !important; }
.cp-link--solid:hover { background: #be123c; }

.cp-banner { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: .9rem; padding: .7rem .9rem; border-radius: 12px; border: 1px solid rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .1); color: #b45309; font-size: .84rem; line-height: 1.8; }
:root[data-theme="dark"] .cp-banner { color: #fbbf24; }
.cp-banner[hidden] { display: none; }
.cp-banner .i { width: 20px; height: 20px; flex: none; }
.cp-banner p { flex: 1 1 220px; }

.cp-items { display: grid; gap: .8rem; }
.cp-items[hidden], .cp-list__clear[hidden] { display: none; }
.cp-item {
  position: relative; display: grid; grid-template-columns: 96px minmax(0, 1fr) auto auto; align-items: center; gap: .6rem 1.1rem;
  padding: .8rem; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); transition: border-color .15s, opacity .2s;
}
:root[data-theme="dark"] .cp-item { background: rgba(21, 18, 54, .5); }
.cp-item:hover { border-color: var(--accent); }
.cp-item.is-busy { opacity: .6; pointer-events: none; }
.cp-item.is-gone { opacity: .6; }
.cp-item__img { display: grid; place-items: center; width: 96px; height: 96px; overflow: hidden; border-radius: 12px; background: var(--media-bg); }
.cp-item__img img { width: 100%; height: 100%; object-fit: cover; background: transparent; }
.cp-item.is-gone .cp-item__img img { filter: grayscale(1); opacity: .6; }
.cp-item__info { display: grid; gap: .2rem; min-width: 0; }
.cp-item__brand { font-family: var(--latin); font-size: .82rem; font-weight: 700; letter-spacing: .02em; color: var(--text-strong); }
.cp-item__name { font-size: .9rem; font-weight: 600; line-height: 1.8; color: var(--text); overflow-wrap: anywhere; }
a.cp-item__name:hover { color: var(--accent); }
.cp-item__sku { font-size: .74rem; color: var(--muted); }
.cp-issue { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .6rem; margin-top: .2rem; font-size: .78rem; line-height: 1.7; color: #ff4d6d; }
:root[data-theme="light"] .cp-issue { color: #c81e44; }
.cp-issue .i { width: 15px; height: 15px; }
.cp-issue--warn { color: #d97706; }
:root[data-theme="dark"] .cp-issue--warn { color: #fbbf24; }

.cp-item__buy { display: flex; align-items: center; gap: 1.2rem; }
.cp-qty { display: inline-flex; align-items: center; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
:root[data-theme="dark"] .cp-qty { background: rgba(10, 8, 32, .7); }
.cp-qty button { display: grid; place-items: center; width: 38px; height: 100%; border: 0; background: transparent; color: var(--text-strong); cursor: pointer; transition: background .15s, color .15s; }
.cp-qty button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.cp-qty button:disabled { opacity: .35; cursor: not-allowed; }
.cp-qty .i { width: 16px; height: 16px; }
.cp-qty output { min-width: 34px; text-align: center; font-size: .95rem; font-weight: 700; color: var(--text-strong); }
.cp-price { display: grid; gap: .1rem; min-width: 118px; text-align: start; }
.cp-price del { font-size: .74rem; color: var(--muted); }
.cp-price strong { font-size: 1.02rem; font-weight: 800; color: var(--accent); white-space: nowrap; }
:root[data-theme="dark"] .cp-price strong { color: #c4a8ff; }
.cp-price strong small { font-size: .72rem; font-weight: 500; color: var(--muted); }
.cp-price span { font-size: .72rem; color: var(--muted); }

.cp-item__act { display: flex; align-items: center; gap: .45rem; }
.cp-ico { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s, background .15s; }
:root[data-theme="dark"] .cp-ico { background: rgba(10, 8, 32, .7); }
.cp-ico .i { width: 18px; height: 18px; }
.cp-ico:hover { color: var(--accent); border-color: var(--accent); }
.cp-ico--del:hover { color: #ff4d6d; border-color: #ff4d6d; background: rgba(255, 77, 109, .08); }
.cp-ico[aria-pressed="true"] { color: var(--red); border-color: var(--red); }
.cp-ico[aria-pressed="true"] .i { fill: var(--red); }

/* skeleton */
.cp-skel { height: 112px; border-radius: 16px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: cp-shimmer 1.3s linear infinite; }
@keyframes cp-shimmer { to { background-position: -200% 0; } }

/* footer buttons */
.cp-list__foot { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.cp-btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .55rem 1.3rem; border: 1px solid var(--accent); border-radius: 12px; background: transparent; color: var(--accent); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, filter .15s; }
:root[data-theme="dark"] .cp-btn { color: #c4a8ff; border-color: rgba(167, 139, 250, .6); }
.cp-btn:hover { background: var(--accent); color: #fff; }
.cp-btn .i { width: 18px; height: 18px; }
.cp-btn--ghost { border-color: var(--line); color: var(--muted); }
:root[data-theme="dark"] .cp-btn--ghost { border-color: var(--line); color: var(--muted); }
.cp-btn--fill { background: var(--btn-bg); color: #fff; border-color: transparent; box-shadow: var(--btn-shadow); }
:root[data-theme="dark"] .cp-btn--fill { background: linear-gradient(135deg, #7c3aed, #6d28d9); color: #fff; }
.cp-btn--fill:hover { filter: brightness(1.1); background: var(--btn-bg); }
.cp-btn.is-spin .i { animation: cp-spin .8s linear infinite; }

/* empty / error */
.cp-state { display: grid; justify-items: center; gap: .6rem; padding: clamp(2rem, 7vw, 3.6rem) 1rem; text-align: center; }
.cp-state[hidden] { display: none; }
.cp-state__ic { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--line); }
:root[data-theme="dark"] .cp-state__ic { color: #c4a8ff; }
.cp-state__ic .i { width: 34px; height: 34px; }
.cp-state__ic--err { background: rgba(255, 77, 109, .12); color: #ff4d6d; }
.cp-state h3 { font-size: 1.1rem; font-weight: 800; color: var(--text-strong); }
.cp-state p { max-width: 24rem; font-size: .88rem; line-height: 1.9; color: var(--muted); }
.cp-state .cp-btn { margin-top: .5rem; }

/* page states */
#cpRoot[data-state="empty"] .cp-grid { grid-template-columns: minmax(0, 1fr); }
#cpRoot[data-state="empty"] .cp-side, #cpRoot[data-state="empty"] .cp-list__head, #cpRoot[data-state="empty"] .cp-list__foot,
#cpRoot[data-state="error"] .cp-side, #cpRoot[data-state="error"] .cp-list__head, #cpRoot[data-state="error"] .cp-list__foot { display: none; }
#cpRoot[data-state="error"] .cp-grid { grid-template-columns: minmax(0, 1fr); }
#cpRoot[data-state="empty"] .cp-wrap, #cpRoot[data-state="empty"] { padding-bottom: clamp(2.4rem, 6vw, 4rem); }

/* ---------- sticky checkout bar (≤991px) ---------- */
.cp-bar { position: fixed; z-index: 60; inset-inline: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem var(--gutter); padding-bottom: calc(.7rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--head-bg); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 -10px 30px -14px rgba(0, 0, 0, .35); }
.cp-bar[hidden] { display: none; }
@media (min-width: 992px) { .cp-bar { display: none !important; } }
.cp-bar__sum { display: grid; line-height: 1.5; }
.cp-bar__sum small { font-size: .74rem; color: var(--muted); }
.cp-bar__sum strong { font-size: 1.05rem; font-weight: 800; color: var(--accent); }
:root[data-theme="dark"] .cp-bar__sum strong { color: #c4a8ff; }
.cp-checkout--bar { width: auto; min-width: 150px; min-height: 48px; padding-inline: 1.4rem; }
@media (max-width: 991px) { body.cp-has-bar .to-top { bottom: calc(5.4rem + env(safe-area-inset-bottom, 0px)); } }

/* ---------- toast ---------- */
.cp-toast { position: fixed; z-index: 300; inset-inline: 0; bottom: 1.4rem; width: max-content; max-width: calc(100% - 2rem); margin-inline: auto; display: flex; align-items: center; gap: .8rem; padding: .75rem 1.1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: .86rem; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s; }
:root[data-theme="dark"] .cp-toast { background: #14102f; }
.cp-toast.is-show { opacity: 1; transform: none; pointer-events: auto; }
.cp-toast--err { border-color: #ff4d6d; }
.cp-toast button { border: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: .2rem .4rem; border-radius: 6px; }
:root[data-theme="dark"] .cp-toast button { color: #b79bff; }
@media (max-width: 991px) { body.cp-has-bar .cp-toast { bottom: calc(5.6rem + env(safe-area-inset-bottom, 0px)); } }

/* ---------- responsive rows ---------- */
@media (max-width: 767px) {
  .cp-item { grid-template-columns: 78px minmax(0, 1fr) auto; grid-template-areas: "img info info" "price price price" "qty qty act"; padding: .75rem; gap: .65rem .8rem; align-items: center; }
  .cp-item__buy { display: contents; }
  .cp-item__img { grid-area: img; width: 78px; height: 78px; }
  .cp-item__info { grid-area: info; align-self: start; }
  .cp-price { grid-area: price; display: flex; align-items: baseline; flex-wrap: wrap; gap: .1rem .7rem; min-width: 0; padding-top: .65rem; border-top: 1px dashed var(--line); text-align: start; }
  .cp-price del { order: 3; }
  .cp-qty { grid-area: qty; justify-self: start; }
  .cp-item__act { grid-area: act; }
  .cp-ico { width: 40px; height: 40px; }
  .cp-list__head { flex-wrap: wrap; }
}
@media (max-width: 479px) {
  .cp-list__foot { flex-direction: column-reverse; align-items: stretch; }
  .cp-list__foot .cp-btn { width: 100%; }
  .cp-coupon__form { flex-direction: column; }
  .cp-coupon__btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .cp-checkout, .cp-toast, .cp-item { transition: none; }
  .cp-skel, .cp-btn.is-spin .i { animation: none; }
}

/* ---------- رزرو موجودی (مهلت یک‌ساعته‌ی اقلام سبد) ---------- */
.cp-hold { display: flex; align-items: center; gap: .35rem; margin-top: .35rem; font-size: .74rem; line-height: 1.7; color: var(--muted); }
.cp-hold .i { width: 14px; height: 14px; flex: none; color: var(--accent); }
:root[data-theme="dark"] .cp-hold .i { color: #b79bff; }
.cp-hold-note { margin-top: .9rem; padding: .6rem .75rem; border-radius: 10px; border: 1px dashed var(--line); background: var(--surface-2); font-size: .74rem; line-height: 1.9; color: var(--muted); }
.cp-hold-note[hidden] { display: none; }
