/**
 * Cart, checkout and order result (Figma 214:8107, 214:8793, 216:9688, 216:10681).
 * Desktop: content on the right, summary on the left (RTL).
 */
.l-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  padding-block: var(--space-6) var(--space-16);
}

.l-flow:focus {
  outline: none;
}

.l-flow .woocommerce {
  display: grid;
  gap: var(--space-4);
}

/* Shared two-column frame */
.c-cart,
.c-checkout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}

/* Summary panel */
.c-summary {
  display: grid;
  gap: var(--space-6);
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  background: var(--color-section-200);
}

.c-summary__title {
  margin: 0;
  color: var(--color-text-primary);
  font-family: var(--font-family-title);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-2xl);
}

.c-summary__rows {
  display: grid;
  gap: var(--space-4);
  margin: 0;
}

.c-summary__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  color: var(--color-text-primary);
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-m);
}

.c-summary__row dt {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-tertiary);
}

.c-summary__row dd {
  margin: 0;
}

.c-summary__strong {
  font-size: var(--font-size-l);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-l);
}

.c-summary__row--discount,
.c-summary__row--discount dt {
  color: var(--color-error-500);
}

.c-summary__badge {
  padding: 0.3125rem 0.625rem;
  border-radius: var(--radius-full);
  background: var(--color-error-500);
  color: var(--color-secondary-50);
  font-family: var(--font-family-caption);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
}

.c-summary__row--coupon a {
  color: var(--color-text-disabled);
  font-size: var(--font-size-s);
}

.c-summary__row--total dd {
  font-family: var(--font-family-title);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-2xl);
}

.c-summary__cta {
  inline-size: 100%;
}

/* Cart items */
.c-cart__items {
  display: grid;
  gap: var(--space-6);
}

.c-cart__list {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.c-cart-item {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
}

.c-cart-item__image {
  display: block;
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  object-fit: cover;
}

.c-cart-item__body {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
}

.c-cart-item__name {
  margin: 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-m);
}

.c-cart-item__name a {
  color: inherit;
  text-decoration: none;
}

.c-cart-item__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.c-cart-item__price {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
}

.c-cart-item__amount {
  color: var(--color-text-primary);
  font-family: var(--font-family-title);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-xl);
}

.c-cart-item__currency {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
}

.c-cart-item__remove a {
  display: grid;
  place-items: center;
  min-inline-size: 2.75rem;
  min-block-size: 2.75rem;
}

/* Quantity stepper around WooCommerce's quantity input */
.c-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border-warm);
  border-radius: var(--radius-xl);
}

.c-stepper__button {
  inline-size: 2rem;
  block-size: 2rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text-secondary);
  font-size: var(--font-size-m);
  cursor: pointer;
}

.no-js .c-stepper__button {
  display: none;
}

.c-stepper .quantity {
  margin: 0;
}

.c-stepper .qty {
  inline-size: 2.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text-secondary);
  font-size: var(--font-size-l);
  font-weight: var(--font-weight-bold);
  text-align: center;
  appearance: textfield;
}

.c-stepper .qty::-webkit-inner-spin-button,
.c-stepper .qty::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.c-cart__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.has-js .c-cart__update {
  display: none;
}

.c-coupon {
  display: flex;
  gap: var(--space-1);
  max-inline-size: 21.25rem;
}

.c-coupon__input {
  flex: 1;
  min-inline-size: 0;
  min-block-size: 2.375rem;
  padding-inline: var(--space-4);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-section-500);
  font-size: var(--font-size-s);
}

/* Checkout fields (WooCommerce form rows) */
.c-checkout__title {
  margin: 0 0 var(--space-6);
  color: var(--color-text-heading);
  font-family: var(--font-family-title);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-xl);
}

.c-checkout__subtitle {
  margin: 0 0 var(--space-4);
  color: var(--color-text-primary);
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-m);
}

.c-checkout__details {
  display: grid;
  gap: var(--space-8);
}

.c-checkout__fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4) var(--space-4);
}

:is(.c-checkout, .c-account) .form-row {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}

:is(.c-checkout, .c-account) .form-row label {
  color: var(--color-text-primary);
  font-size: var(--font-size-s);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-s);
}

:is(.c-checkout, .c-account) .form-row .required {
  color: var(--color-error-500);
  text-decoration: none;
}

:is(.c-checkout, .c-account) .form-row .input-text,
:is(.c-checkout, .c-account) .form-row select {
  inline-size: 100%;
  min-block-size: 2.75rem;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  background: var(--color-white);
  font-size: var(--font-size-s);
  line-height: var(--line-height-s);
}

:is(.c-checkout, .c-account) .form-row select {
  padding-inline-end: calc(var(--space-8) + var(--space-2));
  appearance: none;
  background: var(--color-white) url("../../icons/arrow-down-16.svg") no-repeat left var(--space-4) center;
}

:is(.c-checkout, .c-account) .form-row textarea.input-text {
  min-block-size: 6rem;
  border-radius: var(--radius-lg);
}

:is(.c-checkout, .c-account) .form-row .input-text:focus,
:is(.c-checkout, .c-account) .form-row select:focus {
  border-color: var(--color-focus);
  outline: none;
}

:is(.c-checkout, .c-account) .form-row.woocommerce-invalid .input-text,
:is(.c-checkout, .c-account) .form-row.woocommerce-invalid select {
  border-color: var(--color-error-500);
}

/* Iran-only store: the country is fixed. WooCommerce's country script shows
   this row with an inline style, so the override needs !important. */
#billing_country_field {
  display: none !important;
}

/* Shipping method cards */
.c-shipping-options__list {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.c-shipping-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  min-block-size: 4.5rem;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-disabled);
  border-radius: var(--radius-lg);
  background: var(--color-white);
  cursor: pointer;
}

.c-shipping-option:has(:checked) {
  border-color: var(--color-secondary);
}

.c-shipping-option__input {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  margin: 0;
  accent-color: var(--color-secondary);
}

.c-shipping-option__title {
  color: var(--color-text-primary);
  font-size: var(--font-size-s);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-s);
}

.c-shipping-option__cost {
  color: var(--color-text-primary);
  font-size: var(--font-size-s);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

/* Payment (WooCommerce's payment template, restyled) */
.c-checkout__aside #payment {
  display: grid;
  gap: var(--space-4);
  margin-block-start: var(--space-6);
}

.c-checkout__aside .wc_payment_methods {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--font-size-s);
}

.c-checkout__aside .wc_payment_method > label {
  font-weight: var(--font-weight-bold);
}

/* Gateway logo (e.g. ZarinPal) beside its title, not on a line of its own. */
.c-checkout__aside .wc_payment_method > label img {
  display: inline-block;
  inline-size: auto;
  block-size: 1.5rem;
  margin-inline-start: var(--space-2);
  vertical-align: middle;
}

.c-checkout__aside .payment_box {
  margin-block-start: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}

.c-checkout__aside .payment_box p {
  margin: 0;
}

.c-checkout__aside .place-order {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}

.c-checkout__aside #place_order {
  inline-size: 100%;
  padding: 0.6875rem 1.625rem;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-brand);
  box-shadow: var(--shadow-primary-sm);
  color: var(--color-on-brand);
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-m);
  cursor: pointer;
}

.c-checkout__aside #place_order:hover {
  background: var(--color-brand-hover);
}

.c-checkout__aside .woocommerce-privacy-policy-text {
  color: var(--color-text-disabled);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
  text-align: center;
}

.c-checkout__aside .woocommerce-privacy-policy-text p {
  margin: 0;
}

/* Blocked state while WooCommerce recalculates */
.blockUI.blockOverlay {
  border-radius: var(--radius-xl);
}

/* Order result */
.c-order-result {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  max-inline-size: 36rem;
  margin-inline: auto;
  text-align: center;
}

.c-order-result__badge {
  position: relative;
  display: block;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  margin-block-end: var(--space-2);
  border-radius: var(--radius-full);
}

.c-order-result__badge--success {
  background: var(--color-success-500);
}

/* Check mark: a glyph, not layout, so physical sides keep it upright in RTL. */
.c-order-result__badge--success::after {
  position: absolute;
  top: 0.85rem;
  left: 0.8rem;
  inline-size: 1.1rem;
  block-size: 0.55rem;
  border-bottom: 2px solid var(--color-white);
  border-left: 2px solid var(--color-white);
  content: "";
  transform: rotate(-45deg);
}

.c-order-result__badge--error {
  background: var(--color-error-500);
}

/* Cross */
.c-order-result__badge--error::before,
.c-order-result__badge--error::after {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  inline-size: 1rem;
  block-size: 2px;
  background: var(--color-white);
  content: "";
  transform: translate(50%, -50%) rotate(45deg);
}

.c-order-result__badge--error::after {
  transform: translate(50%, -50%) rotate(-45deg);
}

.c-order-result__status {
  margin: 0;
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-m);
}

.c-order-result__status--success {
  color: var(--color-success-500);
}

.c-order-result__status--error {
  color: var(--color-error-500);
}

.c-order-result__title {
  margin: var(--space-2) 0 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-l);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-l);
}

.c-order-result__text {
  margin: 0;
  color: var(--color-text-disabled);
  font-size: var(--font-size-m);
  line-height: var(--line-height-m);
}

.c-order-result__number {
  margin: 0;
  color: var(--color-text-primary);
  font-family: var(--font-family-latin);
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-bold);
}

.c-order-result__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
  inline-size: 100%;
  margin-block-start: var(--space-6);
}

.c-order-table {
  display: grid;
  gap: var(--space-4);
  inline-size: 100%;
  margin-block-start: var(--space-6);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-white);
}

.c-order-table__title {
  margin: 0;
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-bold);
}

.c-order-table table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-s);
}

.c-order-table thead th {
  padding: var(--space-2);
  background: var(--color-gray-50);
  color: var(--color-text-disabled);
  font-weight: var(--font-weight-medium);
  text-align: start;
}

.c-order-table td,
.c-order-table tbody th,
.c-order-table tfoot th {
  padding: var(--space-3) var(--space-2);
  border-block-end: 1px solid var(--color-border-light);
  font-weight: var(--font-weight-medium);
  text-align: start;
}

.c-order-table__product {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.c-order-table__product img {
  inline-size: 2.5rem;
  block-size: 2.5rem;
  object-fit: contain;
}

@media (min-width: 576px) {
  .c-cart-item {
    grid-template-columns: 6.25rem minmax(0, 1fr) auto;
    padding: var(--space-6);
  }

  .c-checkout__fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  :is(.c-checkout, .c-account) .form-row-wide {
    grid-column: 1 / -1;
  }

  .c-order-result__actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .l-flow {
    gap: var(--space-8);
    padding-block-start: var(--space-8);
  }

  .c-cart,
  .c-checkout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 32.625rem);
    gap: 7.375rem;
  }

  .c-cart__summary,
  .c-checkout__aside {
    position: sticky;
    inset-block-start: var(--space-4);
  }

  .c-cart-item__row {
    flex-wrap: nowrap;
  }

  .c-shipping-options__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
