/* =========================================================
   sasangraphic — Cart page (سبد خرید) redesign
   Enqueued on the WooCommerce Cart page only (inc/cart.php) and
   depending on the shared design system (assets/css/style.css +
   account.css): every colour, radius, font, shadow and timing
   comes from that system's tokens, so the night/day switch keeps
   working without a second theme mechanism.

   RTL layout: two columns — cart items on the RIGHT (wider),
   «خلاصه سفارش» + «اطلاعات حساب کاربری» on the LEFT (sticky).
   ========================================================= */

/* ===================== UTILITIES ===================== */

/* The WP/WC screen-reader pattern — WooCommerce's own copy is not part of the
   shared stylesheet, so the cart re-declares it scoped to its own markup. */
.sg-cart .screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ===================== PAGE HERO ===================== */

.sg-cart-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.sg-cart-hero-main {
  min-width: 0;
}
.sg-cart-hero-title {
  /* .shop-title already carries the site's H1 scale */
  margin: 0;
}
.sg-cart-hero-sub {
  color: var(--text-muted);
  font-size: clamp(0.95rem, 0.4vw + 0.85rem, 1.05rem);
  margin-top: 0.4rem;
}
.sg-cart-hero-ic {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: var(--on-accent);
  background: linear-gradient(
    135deg,
    var(--accent),
    color-mix(in oklab, var(--accent) 58%, var(--violet))
  );
  box-shadow: 0 14px 32px -14px var(--accent-glow);
}
.sg-cart-hero-ic svg {
  width: 28px;
  height: 28px;
}

/* ===================== LAYOUT ===================== */

.sg-cart {
  min-width: 0;
}
.sg-cart-layout {
  display: grid;
  /* RTL: the first grid column sits on the RIGHT — the cart items */
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  align-items: start;
  gap: clamp(1.25rem, 2.5vw, 2rem);
}
.sg-cart-main {
  min-width: 0;
}
.sg-cart-side {
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 2.5vw, 1.75rem);
  min-width: 0;
}

/* ===================== GLASS CARDS ===================== */

/* One glass language for the three main surfaces — cart items, order summary
   and customer card — plus the empty state, so they read as three coordinated
   translucent panels floating above the page grid.

   The tokens are derived from the design-system palette (no new colours), so
   both themes get an appropriate translucency: night → translucent navy/indigo,
   day → translucent white / pale lavender. The grid stays gently visible
   through the surfaces while the content stays crisp. */
.sg-cart-page {
  --sg-glass-1: color-mix(in oklab, var(--ink) 72%, transparent);
  --sg-glass-2: color-mix(in oklab, var(--bg-1) 60%, transparent);
  --sg-glass-border: color-mix(in oklab, var(--text) 18%, transparent);
  --sg-glass-highlight: color-mix(in oklab, var(--text) 9%, transparent);
  --sg-glass-blur: 16px;

  /* near-opaque fallbacks for engines without backdrop-filter */
  --sg-glass-solid-1: color-mix(in oklab, var(--bg-1) 94%, transparent);
  --sg-glass-solid-2: color-mix(in oklab, var(--ink) 92%, transparent);

  /* inner surfaces (item rows, info rows, form fields) */
  --sg-cart-inner: color-mix(in oklab, var(--text) 7%, transparent);
  --sg-cart-inner-strong: color-mix(in oklab, var(--text) 11%, transparent);
}

html[data-theme="night"] .sg-cart-page {
  --sg-glass-1: color-mix(in oklab, var(--ink) 74%, transparent);
  --sg-glass-2: color-mix(in oklab, var(--bg-1) 62%, transparent);
  --sg-glass-border: color-mix(in oklab, var(--text) 20%, transparent);
}

html[data-theme="day"] .sg-cart-page {
  --sg-glass-1: color-mix(in oklab, var(--bg-2) 74%, transparent);
  --sg-glass-2: color-mix(in oklab, var(--bg-1) 66%, transparent);
  --sg-glass-border: color-mix(in oklab, var(--ink) 14%, transparent);
  --sg-glass-highlight: color-mix(in oklab, var(--bg-2) 75%, transparent);
  --sg-glass-solid-1: color-mix(in oklab, var(--bg-2) 96%, transparent);
  --sg-glass-solid-2: color-mix(in oklab, var(--bg-1) 94%, transparent);
}

.sg-cart-card,
.sg-cart-empty {
  position: relative;
  background-color: transparent;
  background-image: linear-gradient(158deg, var(--sg-glass-1), var(--sg-glass-2));
  border: 1px solid var(--sg-glass-border);
  border-radius: var(--radius-md);
  box-shadow:
    var(--shadow-ambient),
    inset 0 1px 0 var(--sg-glass-highlight);
  -webkit-backdrop-filter: blur(var(--sg-glass-blur)) saturate(135%);
  backdrop-filter: blur(var(--sg-glass-blur)) saturate(135%);
  min-width: 0;
}

.sg-cart-card {
  padding: clamp(1.1rem, 2vw, 1.5rem);
}

/* Without backdrop-filter the blur cannot guarantee contrast, so the surfaces
   fall back to a near-opaque version of the same palette. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sg-cart-card,
  .sg-cart-empty {
    background-image: linear-gradient(158deg, var(--sg-glass-solid-1), var(--sg-glass-solid-2));
  }
}
.sg-cart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}
.sg-cart-card-title {
  font-size: clamp(1.05rem, 0.6vw + 0.9rem, 1.25rem);
  font-weight: 800;
  line-height: 1.4;
  margin: 0;
}
.sg-cart-head-ic {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklab, var(--accent) 26%, transparent);
}

/* Sticky summary column — only on viewports that can show the whole sidebar
   (order summary + customer card) at once, so sticking never hides part of the
   account card or fights a short viewport. */
@media (min-width: 981px) and (min-height: 880px) {
  .sg-cart-side {
    position: sticky;
    top: calc(var(--nav-h) + 20px);
    align-self: start;
  }
}
/* ===================== CART ITEMS ===================== */

/* The grid pattern is NOT part of this card anymore — it belongs to the
   page-level background (see PAGE BACKGROUND) so that it also shows in the
   gaps between cards and behind the whole content area. */

/* ----- the WooCommerce cart table becomes a list of item cards ----- */
.sg-cart .woocommerce-cart-form {
  margin: 0;
}
.sg-cart table.shop_table.cart {
  width: 100%;
  border: 0;
  border-collapse: separate;
  border-spacing: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  overflow: visible;
  table-layout: auto;
}

/* Column captions stay in the accessibility tree, out of the layout. */
.sg-cart table.shop_table.cart thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.sg-cart table.shop_table.cart tbody,
.sg-cart table.shop_table.cart tr,
.sg-cart table.shop_table.cart th,
.sg-cart table.shop_table.cart td {
  display: block;
  border: 0;
  background: none;
}

.sg-cart table.shop_table.cart tbody tr.sg-cart-item {
  display: grid;
  /* One source of truth for the thumbnail tile: the grid track, the square
     tile itself and the mobile overrides all read this variable, so the image
     box can never drift out of step with its column. */
  --sg-cart-thumb: clamp(84px, 9vw, 108px);
  /* RTL column order: thumbnail → details → price → remove */
  grid-template-columns: var(--sg-cart-thumb) minmax(0, 1fr) auto auto;
  grid-template-areas: "thumb info price remove";
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.95rem 1.05rem;
  margin: 0 0 0.85rem;
  background: var(--sg-cart-inner-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition:
    border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}
.sg-cart table.shop_table.cart tbody tr.sg-cart-item:hover {
  border-color: var(--border-strong);
}
.sg-cart table.shop_table.cart tbody tr.sg-cart-item:last-child {
  margin-bottom: 0;
}

.sg-cart table.shop_table.cart td.product-thumbnail {
  grid-area: thumb;
  /* WooCommerce ships 1em of cell padding on .shop_table cells. Left in place it
     narrowed the cell's content box to ~76px while the image kept its 108px
     height, so every thumbnail rendered as a 0.70-ratio rectangle. The tile owns
     its own square box instead. */
  padding: 0;
  width: var(--sg-cart-thumb);
  aspect-ratio: 1 / 1;
}
.sg-cart table.shop_table.cart td.product-name {
  grid-area: info;
  min-width: 0;
  padding: 0;
}
.sg-cart table.shop_table.cart td.product-price {
  grid-area: price;
  padding: 0;
  text-align: end;
  white-space: nowrap;
}
.sg-cart table.shop_table.cart td.product-remove {
  grid-area: remove;
  padding: 0;
}

/* ----- thumbnail -----
   The artwork fills its square tile: `object-fit: cover` is the design's own
   behaviour (the catalog artwork is 1:1, so nothing is cropped today) and it
   guarantees a filled tile — never a stretched or letter-boxed product image —
   if a differently-proportioned image is uploaded later. */
.sg-cart table.shop_table.cart td.product-thumbnail a {
  display: block;
  width: 100%;
  height: 100%;
}
.sg-cart table.shop_table.cart td.product-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--sg-cart-inner);
}
/* ----- item details -----
   The td-level selectors are deliberately specific: the shared account
   stylesheet also themes `.shop_table` cells and must be overridden here. */
.sg-cart table.shop_table.cart td.product-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
}
.sg-cart .product-name a {
  color: var(--text);
  transition: color var(--dur-fast);
}
.sg-cart .product-name a:hover {
  color: var(--accent);
}
.sg-cart-item-sub {
  font-size: 0.88rem;
  line-height: 1.85;
  color: var(--text-muted);
  margin-top: 0.35rem;
  max-width: 52ch;
}
.sg-cart-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-faint);
}
.sg-cart-item-meta-ic {
  display: inline-flex;
  color: var(--accent);
}
.sg-cart-item-meta-sep {
  margin: 0 0.15rem;
  opacity: 0.6;
}
.sg-cart-item-qty {
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}

/* WooCommerce's own variation/custom item data. */
.sg-cart .variation {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
  margin: 0.5rem 0 0;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--text-muted);
}
.sg-cart .variation dt {
  font-weight: 600;
  color: var(--text-muted);
}
.sg-cart .variation dd {
  margin: 0;
  color: var(--text);
}
.sg-cart .variation p {
  margin: 0;
}
.sg-cart .backorder_notification {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--wc-red);
}

/* ----- line price -----
   Price unit = currency label + amount. WooCommerce's format for this store is
   `%1$s%2$s` (currency position "left"), i.e. the markup is
   «تومان» followed by the digits. `wc_price()` wraps that pair in <bdi>, but
   `WC_Cart::get_product_subtotal()` — the source of the item cells — prints it
   without the wrapper, so inside the RTL card the bidi algorithm placed the
   label on the RIGHT of the number. Giving the pair an explicit LTR, isolated
   run renders it in logical order (label on the LEFT of the amount, exactly as
   the cart totals already read) while every digit keeps its own sequence.
   Scoped to this page's prices only — no global RTL override, nothing is
   reformatted or recalculated. */
.sg-cart .woocommerce-Price-amount {
  direction: ltr;
  unicode-bidi: isolate;
  /* the label must never wrap away from its amount */
  white-space: nowrap;
}
.sg-cart table.shop_table.cart td.product-price {
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--text);
}
.sg-cart .product-price .sg-cart-item-was {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-faint);
  text-decoration: line-through;
}
.sg-cart .product-price del,
.sg-cart .product-price ins {
  text-decoration: none;
}
.sg-cart .product-price del {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 0.82rem;
}
.sg-cart .product-price ins {
  color: var(--accent);
}
.sg-cart .product-price .woocommerce-Price-currencySymbol {
  font-size: 0.78em;
  font-weight: 500;
  opacity: 0.8;
}

/* ----- remove (native WooCommerce link, themed) -----
   WooCommerce ships `color: var(--wc-red) !important` on `.remove` — the colour
   declarations therefore carry `!important` as well (the same documented
   exception the shared stylesheet uses). */
.sg-cart table.shop_table.cart td.product-remove a.remove {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint) !important;
  line-height: 1;
  text-decoration: none;
  transition:
    color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}
.sg-cart table.shop_table.cart td.product-remove a.remove svg {
  width: 18px;
  height: 18px;
}
.sg-cart table.shop_table.cart td.product-remove a.remove:hover,
.sg-cart table.shop_table.cart td.product-remove a.remove:focus-visible {
  color: var(--wc-red) !important;
  border-color: color-mix(in oklab, var(--wc-red) 42%, transparent);
  background: color-mix(in oklab, var(--wc-red) 12%, transparent);
}
.sg-cart table.shop_table.cart td.product-remove a.remove.is-removing {
  opacity: 0.5;
  pointer-events: none;
}

/* ----- extension row (`woocommerce_cart_actions`) -----
   Hidden while it only carries the hidden nonce fields; shown as soon as a
   plugin renders a real control there, so third-party cart actions keep
   working instead of being swallowed by the design. */
.sg-cart table.shop_table.cart tbody tr.sg-cart-actions-row {
  display: none;
}
.sg-cart table.shop_table.cart tbody tr.sg-cart-actions-row:has(td > *:not(input[type="hidden"])) {
  display: grid;
  gap: 0.75rem;
  padding: 0.5rem 0 0;
}
.sg-cart table.shop_table.cart tbody tr.sg-cart-actions-row td.actions {
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

/* Continue shopping — under the items card, at the visual end of the row. */
.sg-cart-continue {
  margin-top: 1.15rem;
  margin-inline-start: auto;
  display: inline-flex;
  width: auto;
}
/* ===================== AJAX BUSY STATE (the white-flash fix) ===================== */

/* While an AJAX round-trip runs, WooCommerce blocks the cart form and the
   totals card with jQuery BlockUI and paints that overlay pure white
   (overlayCSS: { background: '#fff', opacity: 0.6 }). On the night theme that
   is a hard white flash over the whole cart; in the day theme it is a milky
   veil over the glass cards.

   BlockUI writes that background as an inline style, so it can only be
   replaced with !important here. The inline opacity (BlockUI's own fade from
   0 → 0.6) is deliberately left untouched: the overlay still fades in and
   out smoothly, it is only painted with a theme-aware scrim instead of
   white — so the busy state reads as "working", never as a broken page. */

.sg-cart-page {
  /* the scrim the blocked area is covered with */
  --sg-cart-scrim: color-mix(in oklab, var(--bg-1) 78%, transparent);
  /* the direction the rows slide out to (logical, so RTL is correct) */
  --sg-cart-slide-x: 14px;
}
html[data-theme="day"] .sg-cart-page {
  --sg-cart-scrim: color-mix(in oklab, var(--bg-2) 84%, transparent);
}
html[dir="rtl"] .sg-cart-page {
  --sg-cart-slide-x: -14px;
}

.sg-cart-page .blockUI.blockOverlay {
  background: var(--sg-cart-scrim) !important;
  border-radius: var(--radius-md);
}

/* A slim accent line at the top of the blocked area — the "working" cue,
   painted in the theme's own accent. It grows from the centre, so it reads
   the same in RTL and LTR. */
.sg-cart-page .blockUI.blockOverlay::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  transform: scaleX(0.22);
  transform-origin: center;
  animation: sg-cart-busy 1.15s var(--ease) infinite;
}
@keyframes sg-cart-busy {
  0%,
  100% {
    transform: scaleX(0.22);
    opacity: 0.45;
  }
  50% {
    transform: scaleX(1);
    opacity: 1;
  }
}

/* ===================== LIST TRANSITIONS ===================== */

/* The rows WooCommerce sends back settle in (staggered). Only opacity and
   transform are animated, so the card keeps its height and nothing jumps. */
.sg-cart table.shop_table.cart tbody tr.sg-cart-item.sg-cart-enter,
.sg-cart .cart_totals table.shop_table tr.sg-cart-enter {
  animation: sg-cart-row-in 0.34s var(--ease) both;
  animation-delay: var(--sg-cart-enter-delay, 0ms);
}
@keyframes sg-cart-row-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* The row that is being removed — and every row while the cart is being
   cleared — leaves softly. The class is dropped by the script as soon as the
   refreshed list arrives, and restored if the request never comes back. */
.sg-cart table.shop_table.cart tbody tr.sg-cart-item.sg-cart-row-leaving {
  opacity: 0;
  transform: translateX(var(--sg-cart-slide-x, 14px)) scale(0.99);
  transition:
    opacity 0.28s var(--ease) var(--sg-cart-leave-delay, 0ms),
    transform 0.28s var(--ease) var(--sg-cart-leave-delay, 0ms);
}
/* While the cart is cleared nothing in the items card may be clicked again. */
.sg-cart-items.is-clearing {
  pointer-events: none;
}

/* ===================== PAGE BACKGROUND (grid + ambient) ===================== */

/* The grid belongs to the Cart page content area, not to a single card: the
   `sg-cart-page` class is added to the page's <main> by woocommerce/wc-shell.php
   on the Cart page only, so the pattern covers the whole content area — behind
   the hero, the items card, the summary, the customer card and the gaps between
   them — and never reaches the global header, footer or any other page.

   Pure layered gradients: no image asset, no extra element, no seams (the tiles
   are anchored to the element box and scroll with the content). The grid lines
   paint above the ambient gradients, so they stay crisp while the light haze
   stays behind them. */
.sg-cart-page {
  --sg-grid-line: color-mix(in oklab, var(--text) 6%, transparent);
  --sg-grid-size: 64px;

  background-color: transparent;
  background-image:
    linear-gradient(to right, var(--sg-grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--sg-grid-line) 1px, transparent 1px),
    radial-gradient(48rem 26rem at 10% -8%, color-mix(in oklab, var(--violet) 13%, transparent), transparent 72%),
    radial-gradient(38rem 22rem at 92% 4%, color-mix(in oklab, var(--blue) 9%, transparent), transparent 70%);
  background-repeat: repeat, repeat, no-repeat, no-repeat;
  background-size:
    var(--sg-grid-size) var(--sg-grid-size),
    var(--sg-grid-size) var(--sg-grid-size),
    auto,
    auto;
  background-position: 0 0, 0 0, 0 0, 0 0;
}

/* Both themes share the same technique — only the line colour (and therefore
   its contrast against the page) differs. */
html[data-theme="night"] .sg-cart-page {
  --sg-grid-line: color-mix(in oklab, var(--paper) 7%, transparent);
}
html[data-theme="day"] .sg-cart-page {
  --sg-grid-line: color-mix(in oklab, var(--ink) 7%, transparent);
}

/* ===================== ORDER SUMMARY («خلاصه سفارش») ===================== */

.sg-cart .cart_totals {
  width: 100%;
  float: none;
}
.sg-cart .cart_totals table.shop_table {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  border-collapse: separate;
  border-spacing: 0;
  overflow: visible;
}

/* each totals line: label at the start, value at the end (RTL) */
.sg-cart .cart_totals table.shop_table tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.35rem 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid color-mix(in oklab, var(--border) 55%, transparent);
}
.sg-cart .cart_totals table.shop_table tr:last-child {
  border-bottom: 0;
}
.sg-cart .cart_totals table.shop_table tr > th,
.sg-cart .cart_totals table.shop_table tr > td {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: start;
  vertical-align: baseline;
}
.sg-cart .cart_totals table.shop_table tr > td {
  font-weight: 700;
  color: var(--text);
  text-align: end;
}

/* applied coupons */
.sg-cart .cart_totals tr.cart-discount > th,
.sg-cart .cart_totals tr.cart-discount > td {
  color: var(--accent);
}
.sg-cart .cart_totals .woocommerce-remove-coupon {
  display: inline-flex;
  margin-inline-start: 0.5rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--wc-red);
}
.sg-cart .cart_totals .woocommerce-remove-coupon:hover {
  text-decoration: underline;
}

/* the final total */
.sg-cart .cart_totals tr.order-total {
  align-items: center;
  margin-top: 0.5rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}
.sg-cart .cart_totals tr.order-total > th {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.sg-cart .cart_totals tr.order-total > td {
  font-size: clamp(1.2rem, 0.8vw + 1rem, 1.45rem);
  font-weight: 800;
  color: var(--accent);
}
/* ----- coupon (single, native WooCommerce form) ----- */
.sg-cart-coupon {
  margin: 0 0 1.15rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
}
.sg-cart-coupon-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.sg-cart-coupon-row {
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
}
.sg-cart-coupon-input {
  flex: 1;
  min-width: 0;
  width: auto;
  background: var(--sg-cart-inner-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  padding: 0.7rem 1rem;
  transition:
    border-color var(--dur-fast),
    box-shadow var(--dur-fast);
}
.sg-cart-coupon-input::placeholder {
  color: var(--text-faint);
}
.sg-cart-coupon-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.sg-cart-coupon-submit {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--accent),
    color-mix(in oklab, var(--accent) 62%, var(--violet))
  );
  color: var(--on-accent);
  border: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.7rem 1.5rem;
  box-shadow: 0 10px 24px -12px var(--accent-glow);
  transition:
    transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    filter var(--dur-fast) var(--ease);
}
.sg-cart-coupon-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px -14px var(--accent-glow);
  filter: brightness(1.05);
  color: var(--on-accent);
}
.sg-cart-coupon-submit:disabled,
.sg-cart-coupon-submit.is-busy {
  opacity: 0.65;
  cursor: progress;
  transform: none;
  box-shadow: none;
}

/* ----- primary action ----- */
.sg-cart .wc-proceed-to-checkout {
  padding: 1.15rem 0 0;
}
.sg-cart .wc-proceed-to-checkout .checkout-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  background: linear-gradient(
    135deg,
    var(--accent),
    color-mix(in oklab, var(--accent) 62%, var(--violet))
  );
  color: var(--on-accent);
  font-weight: 800;
  font-size: 1rem;
  padding: 0.95rem 1.5rem;
  border: none;
  border-radius: 999px;
  box-shadow:
    0 12px 30px -12px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  text-shadow: none;
  white-space: nowrap;
  transition:
    transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    filter var(--dur-fast) var(--ease);
}
.sg-cart .wc-proceed-to-checkout .checkout-button:hover,
.sg-cart .wc-proceed-to-checkout .checkout-button:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 20px 44px -14px var(--accent-glow);
  filter: brightness(1.05);
  color: var(--on-accent);
}
.sg-cart .wc-proceed-to-checkout .checkout-button svg {
  width: 18px;
  height: 18px;
}

/* ----- security note ----- */
.sg-cart-secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.sg-cart-secure svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}
/* The shared account table styles tint every body row on hover; the totals
   lines are a definition list, not interactive rows. */
.sg-cart .cart_totals table.shop_table tr:hover {
  background: none;
}

/* ===================== CUSTOMER CARD («اطلاعات حساب کاربری») ===================== */

.sg-cart-info-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}
.sg-cart-info-row {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.7rem;
  padding: 0.7rem 1rem;
  background: var(--sg-cart-inner-strong);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.sg-cart-info-label {
  flex: none;
  font-size: 0.86rem;
  color: var(--text-muted);
}
.sg-cart-info-value {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  text-align: end;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sg-cart-info-row.is-empty .sg-cart-info-value {
  font-weight: 500;
  font-size: 0.84rem;
  color: var(--text-muted);
}
.sg-cart-info-fix {
  margin-inline-start: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.sg-cart-info-fix:hover {
  text-decoration: underline;
}
.sg-cart-info-ic {
  flex: none;
  display: inline-flex;
  color: var(--text-faint);
}
.sg-cart-info-ic svg {
  width: 18px;
  height: 18px;
}
.sg-cart-account-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
}
.sg-cart-account-link:hover {
  text-decoration: underline;
}
.sg-cart-account-link svg {
  width: 16px;
  height: 16px;
}
.sg-cart-account-guest {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  line-height: 1.9;
  color: var(--text-muted);
}
.sg-cart-account-login {
  width: 100%;
  justify-content: center;
}

/* ===================== EMPTY CART ===================== */

/* The glass surface is shared with .sg-cart-card (see GLASS CARDS) — only the
   layout/centring differs here. */
.sg-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1.25rem, 4vw, 2.5rem);
}
.sg-cart-empty-ic {
  display: inline-grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklab, var(--accent) 28%, transparent);
}
.sg-cart-empty-ic svg {
  width: 34px;
  height: 34px;
}
.sg-cart-empty-title {
  margin: 0;
  font-size: clamp(1.25rem, 1vw + 1rem, 1.6rem);
  font-weight: 800;
  line-height: 1.4;
}
.sg-cart-empty-text {
  max-width: 46ch;
  margin: 0;
  color: var(--text-muted);
}
.sg-cart-empty-btn {
  margin-top: 0.5rem;
}
/* The empty state arrives with a soft fade (after «حذف همه» as well as on a
   plain visit) — it never pops in. */
.sg-cart-empty {
  animation: sg-cart-empty-in 0.42s var(--ease) both;
}
@keyframes sg-cart-empty-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===================== CLEAR CART («حذف همه») ===================== */

/* The trigger sits in the items card header, at the visual end of the row
   (the left side in RTL). It only opens the confirmation strip — the cart is
   emptied by the nonce-protected request in assets/js/cart.js. */
.sg-cart-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--wc-red) 26%, transparent);
  background: color-mix(in oklab, var(--wc-red) 8%, transparent);
  color: var(--wc-red);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}
.sg-cart-clear-btn:hover,
.sg-cart-clear-btn:focus-visible {
  background: color-mix(in oklab, var(--wc-red) 16%, transparent);
  border-color: color-mix(in oklab, var(--wc-red) 42%, transparent);
  transform: translateY(-1px);
}
.sg-cart-clear-btn svg {
  width: 16px;
  height: 16px;
}

/* The confirmation strip — it slides open right under the card header. */
.sg-cart-clear-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem 1rem;
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in oklab, var(--wc-red) 28%, transparent);
  background: color-mix(in oklab, var(--wc-red) 10%, transparent);
  animation: sg-cart-confirm-in 0.24s var(--ease) both;
}
.sg-cart-clear-confirm[hidden] {
  display: none;
}
.sg-cart-clear-confirm.is-closing {
  animation: sg-cart-confirm-out 0.2s var(--ease) both;
}
@keyframes sg-cart-confirm-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes sg-cart-confirm-out {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.sg-cart-clear-question {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.6;
}
.sg-cart-clear-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.sg-cart-clear-yes,
.sg-cart-clear-no {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}
.sg-cart-clear-yes {
  background: var(--wc-red);
  color: #ffffff;
}
.sg-cart-clear-yes:hover:not(:disabled) {
  filter: brightness(1.08);
}
.sg-cart-clear-no {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.sg-cart-clear-no:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
}
.sg-cart-clear-yes:disabled,
.sg-cart-clear-no:disabled {
  opacity: 0.55;
  cursor: progress;
}

/* ===================== RESPONSIVE ===================== */

/* The layout adapts in steps — laptop, tablet, mobile — changing proportions
   (column width, card/item padding, thumbnail size, gaps), not just scale. */

/* ----- laptop / small desktop and tablet landscape ----- */
@media (max-width: 1180px) {
  .sg-cart-layout {
    grid-template-columns: minmax(0, 1fr) minmax(258px, 302px);
    gap: 1.25rem;
  }
  .sg-cart-card {
    padding: 1.15rem;
  }
  .sg-cart table.shop_table.cart tbody tr.sg-cart-item {
    --sg-cart-thumb: clamp(76px, 8vw, 96px);
    grid-template-columns: var(--sg-cart-thumb) minmax(0, 1fr) auto auto;
    gap: 0.45rem 0.85rem;
    padding: 0.85rem 0.9rem;
  }
  .sg-cart-item-sub {
    font-size: 0.85rem;
  }
  .sg-cart .cart_totals tr.order-total > td {
    font-size: 1.2rem;
  }
}

/* ----- tablet portrait and below: stack (items first, then the sidebar) ----- */
@media (max-width: 980px) {
  .sg-cart-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.35rem;
  }
  .sg-cart-side {
    /* the sticky column only exists on the two-column layout */
    position: static;
    gap: 1.35rem;
  }
  .sg-cart-main {
    min-width: 0;
  }
}

/* ----- mobile ----- */
@media (max-width: 600px) {
  /* calmer, smaller tiles and a lighter blur keep the glass cheap on mobile */
  .sg-cart-page {
    --sg-grid-size: 46px;
    --sg-glass-blur: 12px;
  }
  .sg-cart-card {
    padding: 1rem;
  }
  .sg-cart-layout,
  .sg-cart-side {
    gap: 1rem;
  }

  /* the item becomes a two-row card: thumbnail + details + remove, then the
     price aligned under the details (not under the remove control) */
  .sg-cart table.shop_table.cart tbody tr.sg-cart-item {
    --sg-cart-thumb: clamp(64px, 18vw, 88px);
    grid-template-columns: var(--sg-cart-thumb) minmax(0, 1fr) auto;
    grid-template-areas:
      "thumb info remove"
      ".     price .";
    align-items: start;
    gap: 0.5rem 0.7rem;
    padding: 0.8rem;
  }
  .sg-cart table.shop_table.cart td.product-price {
    text-align: start;
    white-space: normal;
  }
  .sg-cart table.shop_table.cart td.product-remove a.remove {
    width: 38px;
    height: 38px;
  }
  .sg-cart table.shop_table.cart td.product-name a {
    /* long names wrap instead of pushing the price out of the card */
    overflow-wrap: anywhere;
  }
  .sg-cart-item-sub {
    max-width: none;
    font-size: 0.85rem;
    line-height: 1.8;
  }
  .sg-cart-item-meta {
    font-size: 0.76rem;
  }
  .sg-cart-card-title {
    font-size: 1.02rem;
  }
  .sg-cart-card-head {
    margin-bottom: 0.9rem;
  }

  /* contact rows become two lines instead of squeezing the value */
  .sg-cart-info-row {
    flex-wrap: wrap;
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
  }
  .sg-cart-info-value {
    flex: 1 1 60%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: start;
  }

  .sg-cart-coupon-submit {
    padding-inline: 1.15rem;
  }

  /* primary action: full width, comfortable tap target */
  .sg-cart .wc-proceed-to-checkout .checkout-button {
    padding: 1rem 1.25rem;
    font-size: 0.98rem;
  }
  .sg-cart-continue {
    width: 100%;
    margin-inline-start: 0;
    justify-content: center;
  }
  .sg-cart-empty {
    padding: 2.25rem 1.25rem;
  }
  .sg-cart-empty-ic {
    width: 72px;
    height: 72px;
  }
}

/* ----- very narrow phones ----- */
@media (max-width: 380px) {
  .sg-cart table.shop_table.cart tbody tr.sg-cart-item {
    --sg-cart-thumb: clamp(56px, 20vw, 72px);
    grid-template-columns: var(--sg-cart-thumb) minmax(0, 1fr) auto;
    padding: 0.7rem;
  }
  .sg-cart-coupon-row {
    flex-wrap: wrap;
  }
  .sg-cart-coupon-submit {
    width: 100%;
  }
}

/* ===================== REDUCED MOTION ===================== */

@media (prefers-reduced-motion: reduce) {
  .sg-cart *,
  .sg-cart-hero * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* The empty state is rendered outside .sg-cart (it replaces the whole
   WooCommerce block), so the reduced-motion rule above does not reach it —
   and the busy line must stop pulsing as well. */
@media (prefers-reduced-motion: reduce) {
  .sg-cart-empty,
  .sg-cart-empty * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  .sg-cart-page .blockUI.blockOverlay::before {
    animation: none !important;
    transform: scaleX(1);
    opacity: 0.7;
  }
}
