.mini-cart-drawer {
  height: 100%;
}

.mini-cart-drawer__body {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 478px;
  max-width: 100vw;
  background-color: rgb(var(--color-background, var(--color-page-background, 255, 255, 255)));
  color: rgb(var(--color-text, 0, 0, 0));
  box-sizing: border-box;
}

/* 1. Header (固定) */
.mini-cart-drawer__header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 16px 44px;
  border-bottom: 1px solid rgba(var(--color-text, 0, 0, 0), 0.08);
  flex-shrink: 0;
}

.mini-cart-drawer__tips {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  line-height: 1.3;
  color: rgb(var(--color-text, 0, 0, 0));
}

.mini-cart-drawer__tips svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.mini-cart-drawer__close {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgb(var(--color-text, 0, 0, 0));
  transition: opacity 0.2s ease;
}

.mini-cart-drawer__close:hover {
  opacity: 0.7;
}

/* 2. 优惠凑单 (固定) */
.mini-cart-drawer__promo-info {
  flex-shrink: 0;
  padding: 14px 20px 16px;
  background: #f6f0e8;
}

.mini-cart-drawer__promo-info[hidden] {
  display: none;
}

.mini-cart-drawer__promo-text {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.4;
  color: rgb(var(--color-text, 0, 0, 0));
}

.mini-cart-drawer__promo-text strong {
  font-weight: 700;
}

.mini-cart-drawer__promo-save {
  color: #b42318;
}

.mini-cart-drawer__promo-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-cart-drawer__promo-start,
.mini-cart-drawer__promo-end {
  flex-shrink: 0;
  font-size: 13px;
  line-height: 1;
  color: rgb(var(--color-text, 0, 0, 0));
}

.mini-cart-drawer__promo-track {
  --promo-progress: 0%;
  position: relative;
  flex: 1;
  height: 6px;
  background: #fff;
  border: 1px solid #111;
  border-radius: 999px;
  overflow: visible;
}

.mini-cart-drawer__promo-fill {
  height: 100%;
  width: var(--promo-progress);
  background: #111;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.mini-cart-drawer__promo-knob {
  position: absolute;
  top: 50%;
  left: var(--promo-progress);
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid #111;
  border-radius: 50%;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.35s ease;
}

/* 3. 可配置分类 Tab 导航 (固定) */
.mini-cart-drawer__tabs-wrapper {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid rgba(var(--color-text, 0, 0, 0), 0.08);
  flex-shrink: 0;
  gap: 4px;
}

.mini-cart-drawer__tabs-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.mini-cart-drawer__tabs-scroll {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.mini-cart-drawer__tabs-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.mini-cart-tab-item {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 12px 0 10px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  color: rgba(var(--color-text, 0, 0, 0), 0.4);
  position: relative;
  transition: color 0.2s ease;
}

.mini-cart-tab-item:hover {
  color: rgb(var(--color-text, 0, 0, 0));
  background: transparent;
}

.mini-cart-tab-item.active {
  color: rgb(var(--color-text, 0, 0, 0));
  font-weight: 700;
  background: transparent;
}

.mini-cart-tab-item.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgb(var(--color-text, 0, 0, 0));
}

.mini-cart-drawer__tabs-arrows {
  display: flex;
  gap: 0;
  flex-shrink: 0;
}

.mini-cart-tab-arrow {
  background: transparent;
  border: none;
  border-radius: 0;
  width: 24px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgb(var(--color-text, 0, 0, 0));
  transition: opacity 0.2s ease;
  padding: 0;
}

.mini-cart-tab-arrow:hover:not(:disabled) {
  opacity: 0.7;
  background: transparent;
}

.mini-cart-tab-arrow:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* 4. 商品列表区域 (独立垂直滚动) */
.mini-cart-drawer__products-container {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 16px 8px;
  position: relative;
}

.mini-cart-drawer__products-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.mini-cart-drawer__products-loading svg {
  width: 28px;
  height: 28px;
}

.mini-cart-drawer__empty-tips {
  font-size: 14px;
  color: rgba(var(--color-text, 0, 0, 0), 0.6);
  text-align: center;
  padding: 32px 0;
}

.mini-cart-drawer__products-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 10px;
  align-items: start;
}

.mini-cart-product-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  min-width: 0;
}

.mini-cart-product-card__image-link {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  background: #f7f7f7;
}

.mini-cart-product-card__image-link img {
  width: 100%;
  height: auto;
  display: block;
}

.mini-cart-product-card__image-link svg {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 1 / 1;
}

.mini-cart-product-card__badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: rgb(var(--color-text, 0, 0, 0));
  background: rgba(255, 255, 255, 0.92);
}

.mini-cart-product-card__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}

.mini-cart-product-card__prices {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.mini-cart-product-card__price {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: rgb(var(--color-text, 0, 0, 0));
}

.mini-cart-product-card__price.is-sale {
  color: rgb(var(--color-sale, 185, 28, 28));
}

.mini-cart-product-card__compare {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
  color: rgba(var(--color-text, 0, 0, 0), 0.4);
  text-decoration: line-through;
}

.mini-cart-product-card theme-quick-add-modal {
  display: flex;
  flex-shrink: 0;
  line-height: 0;
  position: relative;
}
.mini-cart-product-card theme-quick-add-modal .mini-cart-product-card__add-btn {
    width: 16px;
    height: 16px;
}

.mini-cart-product-card theme-quick-add-modal > details {
  display: flex;
}

.mini-cart-product-card theme-quick-add-modal .quick-add-modal__modal {
  display: none;
}

.mini-cart-product-card__add-btn {
  background: transparent;
  border: none;
  border-radius: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: rgb(var(--color-text, 0, 0, 0));
  padding: 0;
  list-style: none;
  transition: opacity 0.2s ease;
}

.mini-cart-product-card__add-btn::-webkit-details-marker {
  display: none;
}

.mini-cart-product-card__add-btn:hover {
  opacity: 0.65;
  background: transparent;
}

.mini-cart-product-card__add-btn.disabled,
.mini-cart-product-card__add-btn[disabled],
.mini-cart-product-card__add-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.mini-cart-product-card__add-btn svg {
  width: 18px;
  height: 18px;
}

.mini-cart-product-card__add-btn .icon-loading,
.mini-cart-product-card__add-btn .loading--rotator {
  display: none;
}

.mini-cart-product-card__add-btn.loading {
  pointer-events: none;
}

.mini-cart-product-card__add-btn.loading .icon-quick-add {
  display: none;
}

.mini-cart-product-card__add-btn.loading .icon-loading,
.mini-cart-product-card__add-btn.loading .loading--rotator {
  display: flex;
}

/* 5. 底部固定区域 (固定) */
.mini-cart-drawer__footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(var(--color-text, 0, 0, 0), 0.08);
  flex-shrink: 0;
  background-color: rgb(var(--color-page-background, 255, 255, 255));
}

/* 抽屉内部隐藏已解锁提示块，并清除不必要的虚线和顶边距 */
.mini-cart-drawer .threshold-promo__unlocked-wrapper {
  display: none !important;
}

.mini-cart-drawer .threshold-promo__approaching-wrapper {
  margin-top: 0 !important;
  padding-top: 0 !important;
  border-top: none !important;
}

/* 凑单 Add 按钮弹出模式控制 */
theme-mini-cart-drawer.is-promo-mode .mini-cart-drawer__tips,
theme-mini-cart-drawer.is-promo-mode .mini-cart-drawer__footer,
.mini-cart-drawer theme-threshold-promo .threshold-promo__add-btn {
  display: none !important;
}

.mini-cart-drawer__view-bag-btn {
  width: 100%;
  display: block;
  text-align: center;
  padding: 12px;
  text-decoration: none;
  box-sizing: border-box;
}

/* 移动端从底部弹出 */
@media (max-width: 959px) {
  /* 覆盖 modal 组件的 right placement，移动端改为从底部弹出 */
  theme-mini-cart-drawer theme-modal[data-placement="right"] > details > summary + :not(details, summary) {
    --modal-animation-name: animation-slide-in-bottom !important;
    inset-block: auto 0 !important;
    inset-inline: 0 !important;
    width: 100vw !important;
    height: auto !important;
    max-height: 75vh;
  }

  .mini-cart-drawer__body {
    width: 100vw;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
  }
}