/* مینی‌کارت شناور سندباد */
.sg-minicart {
  --sg-mc-gold: #c2922e;
  --sg-mc-gold-dark: #a8791f;
  --sg-mc-brown: #3b2a1c;
  --sg-mc-surface: #fffdf9;
  --sg-mc-bg: #f7efe2;
  --sg-mc-cream: #f3e7d2;
  --sg-mc-border: #e7d9c2;
  --sg-mc-text: #433424;
  --sg-mc-muted: #897659;
  --sg-mc-width: 360px;
  --sg-mc-radius: 18px;
  --sg-mc-shadow: 0 18px 48px rgba(59, 42, 28, 0.22);

  position: fixed;
  inset-block-end: 24px;
  inset-inline-start: 24px;
  z-index: 9999;
  width: var(--sg-mc-width);
  max-width: calc(100vw - 48px);
  font-family: inherit;
  direction: rtl;
}

.sg-minicart.is-empty {
  display: none;
}

.sg-minicart__shell {
  position: relative;
}

/* نوار جمع‌وجور سبد در حالت بسته */
.sg-minicart__launcher {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--sg-mc-border);
  border-radius: var(--sg-mc-radius);
  background: var(--sg-mc-surface);
  box-shadow: var(--sg-mc-shadow);
  color: var(--sg-mc-brown);
  cursor: pointer;
  font: inherit;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.sg-minicart__launcher:hover {
  transform: translateY(-2px);
}

.sg-minicart__launcher-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--sg-mc-cream);
  color: var(--sg-mc-gold-dark);
}

.sg-minicart__launcher-icon .sg-product-icon {
  width: 24px;
  height: 24px;
}

.sg-minicart__count {
  position: absolute;
  inset-block-start: -6px;
  inset-inline-start: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--sg-mc-gold);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  border: 2px solid var(--sg-mc-surface);
}

.sg-minicart__launcher-label {
  font-weight: 700;
}

.sg-minicart__launcher-total {
  margin-inline-start: auto;
  font-weight: 800;
  color: var(--sg-mc-gold-dark);
  white-space: nowrap;
}

.sg-minicart__launcher-caret {
  display: inline-flex;
  flex: none;
  color: var(--sg-mc-muted);
}

.sg-minicart__launcher-caret .sg-product-icon {
  width: 20px;
  height: 20px;
  transform: rotate(180deg);
}

/* پنل کامل سبد در حالت باز */
.sg-minicart__panel {
  position: absolute;
  inset-block-end: 0;
  inset-inline: 0;
  display: none;
  flex-direction: column;
  max-height: min(74vh, 620px);
  border: 1px solid var(--sg-mc-border);
  border-radius: var(--sg-mc-radius);
  background: var(--sg-mc-surface);
  box-shadow: var(--sg-mc-shadow);
  overflow: hidden;
}

.sg-minicart.is-open .sg-minicart__launcher {
  display: none;
}

.sg-minicart.is-open .sg-minicart__panel {
  display: flex;
}

.sg-minicart__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--sg-mc-border);
  background: var(--sg-mc-bg);
}

.sg-minicart__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--sg-mc-brown);
}

.sg-minicart__head-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--sg-mc-gold);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
}

.sg-minicart__close {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--sg-mc-border);
  border-radius: 50%;
  background: var(--sg-mc-surface);
  color: var(--sg-mc-brown);
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.sg-minicart__close:hover {
  background: var(--sg-mc-gold);
  color: #fff;
  border-color: var(--sg-mc-gold);
}

.sg-minicart__close .sg-product-icon {
  width: 20px;
  height: 20px;
}

.sg-minicart__notice {
  margin: 0;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
}

.sg-minicart__notice--success {
  background: #eef6ec;
  color: #2f6b34;
}

.sg-minicart__notice--warning {
  background: #fbf2dc;
  color: #8a6314;
}

.sg-minicart__notice--error {
  background: #fbeceb;
  color: #a3372f;
}

/* فهرست اقلام */
.sg-minicart__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sg-minicart__body::-webkit-scrollbar {
  width: 4px;
}

.sg-minicart__body::-webkit-scrollbar-thumb {
  background: var(--sg-mc-gold);
  border-radius: 50px;
}

.sg-minicart__items {
  margin: 0;
  padding: 8px 14px;
  list-style: none;
}

.sg-minicart__item {
  display: flex;
  gap: 12px;
  padding: 14px 6px;
  border-bottom: 1px solid var(--sg-mc-border);
}

.sg-minicart__item:last-child {
  border-bottom: 0;
}

.sg-minicart__thumb {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--sg-mc-cream);
}

.sg-minicart__thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sg-minicart__info {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-inline-end: 30px;
}

.sg-minicart__remove {
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sg-mc-muted);
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.sg-minicart__remove:hover {
  background: #fbeceb;
  color: #a3372f;
}

.sg-minicart__remove .sg-product-icon {
  width: 18px;
  height: 18px;
}

.sg-minicart__name {
  font-weight: 700;
  color: var(--sg-mc-brown);
  line-height: 1.4;
}

.sg-minicart__unit {
  font-size: 0.82rem;
  color: var(--sg-mc-muted);
}

.sg-minicart__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.sg-minicart__line {
  font-weight: 800;
  color: var(--sg-mc-brown);
}

.sg-minicart__qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--sg-mc-border);
  border-radius: 999px;
  background: var(--sg-mc-bg);
}

.sg-minicart__qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--sg-mc-surface);
  color: var(--sg-mc-brown);
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.sg-minicart__qty-btn:hover:not([disabled]) {
  background: var(--sg-mc-gold);
  color: #fff;
}

.sg-minicart__qty-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.sg-minicart__qty-btn .sg-product-icon {
  width: 16px;
  height: 16px;
}

.sg-minicart__qty-value {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  color: var(--sg-mc-brown);
}

/* حالت خالی */
.sg-minicart__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--sg-mc-muted);
  text-align: center;
}

.sg-minicart__empty-icon {
  width: 48px;
  height: 48px;
  color: var(--sg-mc-border);
}

.sg-minicart__empty-text {
  margin: 0;
  font-weight: 600;
}

/* بخش پایانی: کوپن، جمع کل و تسویه */
.sg-minicart__foot {
  position: sticky;
  bottom: 0;
  border-top: 1px solid var(--sg-mc-border);
  padding: 16px 18px;
  background: var(--sg-mc-bg);
  margin-top: auto;
}

.sg-minicart__coupon {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.sg-minicart__coupon-applied {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #eef6ec;
  color: #2f6b34;
  font-size: 0.88rem;
}

.sg-minicart__coupon-icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.sg-minicart__coupon-code {
  font-weight: 700;
}

.sg-minicart__coupon-amount {
  margin-inline-start: auto;
  font-weight: 700;
}

.sg-minicart__coupon-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.sg-minicart__coupon-remove .sg-product-icon {
  width: 16px;
  height: 16px;
}

.sg-minicart__coupon-form {
  display: flex;
  gap: 8px;
}

.sg-minicart__coupon-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 0 12px;
  border: 1px solid var(--sg-mc-border);
  border-radius: 10px;
  background: var(--sg-mc-surface);
  color: var(--sg-mc-muted);
}

.sg-minicart__coupon-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 11px 0;
  color: var(--sg-mc-text);
  font: inherit;
}

.sg-minicart__coupon-input:focus {
  outline: none;
}

.sg-minicart__coupon-submit {
  flex: none;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--sg-mc-brown);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease;
}

.sg-minicart__coupon-submit:hover {
  background: var(--sg-mc-gold-dark);
}

.sg-minicart__totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sg-minicart__totals-label {
  color: var(--sg-mc-muted);
  font-weight: 600;
}

.sg-minicart__totals-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--sg-mc-brown);
}

.sg-minicart__checkout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--sg-mc-gold);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  transition:
    background 0.18s ease,
    transform 0.18s ease;
  box-sizing: border-box;
}

.sg-minicart__checkout:hover {
  background: var(--sg-mc-gold-dark);
  transform: translateY(-2px);
}

.sg-minicart__checkout .sg-product-icon {
  width: 20px;
  height: 20px;
  margin-inline: 0;
}

/* لودر هنگام درخواست ای‌جکس */
.sg-minicart__loader {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 253, 249, 0.7);
  backdrop-filter: blur(1px);
  z-index: 5;
}

.sg-minicart.is-loading .sg-minicart__loader {
  display: flex;
}

.sg-minicart__spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid var(--sg-mc-cream);
  border-top-color: var(--sg-mc-gold);
  animation: sg-minicart-spin 0.8s linear infinite;
}

@keyframes sg-minicart-spin {
  to {
    transform: rotate(360deg);
  }
}

/* بازخورد بارگذاری روی دکمه‌های افزودن به سبد */
.sg-shop-card__button.is-loading,
.sg-product-page .single_add_to_cart_button.is-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}

.sg-shop-card__button.is-loading::after,
.sg-product-page .single_add_to_cart_button.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #fff;
  animation: sg-minicart-spin 0.7s linear infinite;
}

/* پشت‌زمینه تیره برای حالت تمام‌صفحه موبایل */
.sg-minicart__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(39, 26, 16, 0.55);
  z-index: -1;
}

/* جلوگیری از اسکرول صفحه هنگام باز بودن سبد در موبایل */
.sg-minicart-locked,
.sg-minicart-locked body {
  overflow: hidden;
}

/* موبایل: عرض کامل با فاصله، و تمام‌صفحه در حالت باز */
@media (max-width: 600px) {
  .sg-minicart {
    inset-block-end: 12px;
    inset-inline: 12px;
    width: auto;
    max-width: none;
  }

  .sg-minicart.is-open {
    inset: 0;
    width: auto;
  }

  .sg-minicart.is-open .sg-minicart__backdrop {
    display: block;
  }

  .sg-minicart.is-open .sg-minicart__panel {
    position: fixed;
    inset: 0;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .sg-minicart.is-open .sg-minicart__foot {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}
