/* 购物车侧边栏 - 订单摘要样式 */

/* 主题色变量 - 基于 Figma 设计 */
:root {
  --cart-sidebar-primary: #c68635;
  --cart-sidebar-text: #5c3c30;
  --cart-sidebar-light-text: #999;
  --cart-sidebar-border: #d1d1d1;
  --cart-sidebar-highlight: #ff3b4a;
  --cart-sidebar-progress-bg: #dcdcdc;
}

.main-cart-sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px;
  background-color: rgb(var(--color-background));
  border: 1px solid var(--cart-sidebar-border);
  border-radius: 4px;
}

/* 免费配送进度条 */
.cart-sidebar__free-shipping {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* align-items: center; */
}

.cart-sidebar__free-shipping-text {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  color: var(--cart-sidebar-text);
  text-align: center;
}

.cart-sidebar__highlight-amount {
  color: var(--cart-sidebar-highlight);
  font-weight: 600;
}

.cart-sidebar__add-link {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  color: var(--cart-sidebar-text);
  text-decoration: none;
}

.cart-sidebar__add-link:hover {
  text-decoration: underline;
}

.cart-sidebar__progress-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.cart-sidebar__progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  background-color: var(--cart-sidebar-progress-bg);
  border-radius: 11px;
}

.cart-sidebar__progress-fill {
  height: 100%;
  background-color: var(--cart-sidebar-primary);
  border-radius: 15px;
  transition: width 0.3s ease;
}

.cart-sidebar__progress-labels {
  display: flex;
  justify-content: space-between;
  color: var(--cart-sidebar-text);
}

/* 优惠码区域 */
.cart-sidebar__promo-code {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cart-sidebar__promo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-sidebar__promo-title {
  color: var(--cart-sidebar-text);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.cart-sidebar__see-more {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  color: var(--cart-sidebar-text) !important;
  text-decoration: none;
}

.cart-sidebar__see-more:hover {
  color: #c68635;
  text-decoration: underline;
}

/* 优惠码表单样式覆盖 */
.cart-sidebar__promo-form .cart-coupon__form {
  display: flex;
  width: 100%;
}

.cart-sidebar__promo-form .cart-coupon__form .field {
  flex: 1;
  margin-block-end: 0;
}

.cart-sidebar__promo-form .cart-coupon__form .field__input {
  height: 40px;
  padding: 0 16px;
  font-size: 13px;
  color: var(--cart-sidebar-light-text);
  border: 1px solid var(--cart-sidebar-light-text);
  border-radius: 10px 0 0 10px;
  border-inline-end: none;
}

.cart-sidebar__promo-form .cart-coupon__form .field__input::placeholder {
  color: var(--cart-sidebar-light-text);
  text-transform: uppercase;
  opacity: 1;
}

.cart-sidebar__promo-form .cart-coupon__button {
  flex-shrink: 0;
  width: 144px;
  height: 40px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background-color: var(--cart-sidebar-primary);
  border: none;
  border-radius: 0 10px 10px 0;
}

.cart-sidebar__promo-form .cart-coupon__button:hover {
  opacity: 0.9;
}

/* 优惠码错误状态样式 */
.cart-sidebar__promo-form .field--error .field__input {
  border-color: var(--cart-sidebar-primary);
}

.cart-sidebar__promo-form .cart-coupon__error {
  margin-block-start: 8px;
  margin-block-end: 0;
  font-size: 13px;
  color: var(--cart-sidebar-highlight);
}

.cart-sidebar__promo-form .cart-coupon__error:empty {
  display: none;
}

/* 已应用优惠码列表样式 */
.cart-sidebar__promo-form .cart-coupon__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-start: 12px;
  margin-block-end: 0;
}

.cart-sidebar__promo-form .cart-coupon__list:empty {
  display: none;
}

.cart-sidebar__promo-form .cart-coupon__list-item {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 6px 10px;
  margin: 0;
  font-size: 12px;
  color: var(--cart-sidebar-text);
  background-color: rgba(198, 134, 53, 0.1);
  border: 1px solid var(--cart-sidebar-primary);
  border-radius: 4px;
}

.cart-sidebar__promo-form .cart-coupon__list-tag {
  display: flex;
  align-items: center;
  margin-inline-end: 4px;
  color: var(--cart-sidebar-primary);
  opacity: 1;
}

.cart-sidebar__promo-form .cart-coupon__list-tag svg {
  width: 14px;
  height: 14px;
}

.cart-sidebar__promo-form .cart-coupon__list-code {
  font-weight: 600;
}

.cart-sidebar__promo-form .cart-coupon__list-close {
  display: flex;
  align-items: center;
  margin-inline-start: 8px;
  color: var(--cart-sidebar-light-text);
  cursor: pointer;
  transition: color 0.2s ease;
}

.cart-sidebar__promo-form .cart-coupon__list-close:hover {
  color: var(--cart-sidebar-highlight);
}

.cart-sidebar__promo-form .cart-coupon__list-close svg {
  width: 12px;
  height: 12px;
}

/* 订单摘要 */
.cart-sidebar__order-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cart-sidebar__summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-sidebar__summary-title {
  color: var(--cart-sidebar-text);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.cart-sidebar__summary-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-sidebar__summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-sidebar__summary-label {
  display: flex;
  gap: 4px;
  align-items: center;
  color: var(--cart-sidebar-text);
  font-size: 13px;
  font-weight: 600;
}

.cart-sidebar__info-icon {
  color: var(--cart-sidebar-light-text);
  cursor: pointer;
}

/* Tooltip 样式 */
.cart-sidebar__tooltip-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  /* 防止隐藏的 ::after tooltip 内容扩展页面 scrollWidth 导致水平滚动条 */
  overflow: hidden;
}

.cart-sidebar__tooltip-wrapper:hover {
  overflow: visible;
}

.cart-sidebar__tooltip-wrapper::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background-color: #333;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
  z-index: 100;
  pointer-events: none;
}

.cart-sidebar__tooltip-wrapper::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #333;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
  z-index: 100;
  pointer-events: none;
}

.cart-sidebar__tooltip-wrapper:hover::after,
.cart-sidebar__tooltip-wrapper:hover::before {
  opacity: 1;
  visibility: visible;
}

/* 移动端无 hover 交互，隐藏 tooltip 伪元素防止横向溢出 */
@media (max-width: 959px) {
  .cart-sidebar__tooltip-wrapper::after,
  .cart-sidebar__tooltip-wrapper::before {
    display: none;
  }
}

.cart-sidebar__summary-value {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 13px;
}

.cart-sidebar__original-price {
  color: var(--cart-sidebar-light-text);
  text-decoration: line-through;
}

.cart-sidebar__current-price {
  color: var(--cart-sidebar-text);
  font-weight: 600;
}

.cart-sidebar__shipping-price {
  color: var(--cart-sidebar-text);
  font-weight: 600;
}

/* 折扣码行 */
.cart-sidebar__summary-discount {
  margin-block-start: 4px;
}

.cart-sidebar__discount-price {
  color: var(--cart-sidebar-text);
  font-weight: 600;
}

/* 总计行 */
.cart-sidebar__summary-total {
  align-items: flex-start;
  margin-block-start: 4px;
}

.cart-sidebar__total-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--cart-sidebar-text);
}

.cart-sidebar__total-value {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
}

.cart-sidebar__total-price {
  font-size: 18px;
  font-weight: 600;
  color: var(--cart-sidebar-text);
}

.cart-sidebar__savings {
  display: flex;
  gap: 4px;
  align-items: center;
}

.cart-sidebar__savings-text {
  color: var(--cart-sidebar-highlight);
  font-size: 13px;
}

/* 节省金额行 */
.cart-sidebar__summary-savings {
  justify-content: flex-end;
  margin-block-start: 4px;
}

.cart-sidebar__summary-savings .cart-sidebar__summary-value {
  justify-content: flex-end;
  width: 100%;
}

/* 结账按钮 */
.cart-sidebar__checkout-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-block-end: 24px;
}

.cart-sidebar__checkout-btn {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  background-color: var(--cart-sidebar-primary);
  border: none;
  border-radius: 10px;
}

.cart-sidebar__checkout-btn:hover {
  opacity: 0.9;
}

/* 覆盖全局按钮的 ::after 伪元素边框效果 */
.cart-sidebar__checkout-btn::after {
  box-shadow: none !important;
}

.cart-sidebar__klarna-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cart-sidebar-primary);
  background-color: transparent;
  border: 1px solid var(--cart-sidebar-primary);
  border-radius: 10px;
}

.cart-sidebar__klarna-btn:hover {
  background-color: rgba(198, 134, 53, 0.05);
}

/* 分期付款信息 */
.cart-sidebar__installments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  color: var(--cart-sidebar-text);
  font-size: 13px;
  font-weight: 600;
}

.cart-sidebar__paypal-logo {
  display: flex;
  gap: 4px;
  align-items: center;
}

.cart-sidebar__paypal-logo img {
  height: 14px;
  width: auto;
}

/* 接受的支付方式 - 与 footer 保持一致 */
.cart-sidebar__payment-methods {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cart-sidebar__payment-title {
  color: var(--cart-sidebar-primary);
  font-size: 18px;
  font-weight: 700;
}

.cart-sidebar__payment-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 使用 SHOPLINE 内置支付图标的 SVG 样式 */
.cart-sidebar__payment-icons svg {
  width: 48px;
  height: 30px;
}

/* 支付认证与奖项展示 */
.cart-sidebar__trust-awards {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-block-start: 8px;
}

.cart-sidebar__trust-section,
.cart-sidebar__awards-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cart-sidebar__trust-title,
.cart-sidebar__awards-title {
  margin: 0;
  color: var(--cart-sidebar-primary);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.cart-sidebar__trust-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.cart-sidebar__trust-icons > svg,
.cart-sidebar__trust-icons > img {
  width: auto;
  height: 32px;
}

.cart-sidebar__awards-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.cart-sidebar__award-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
  background: none;
  border-radius: 0;
}

.cart-sidebar__award-image,
.cart-sidebar__award-item img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.cart-sidebar__award-item svg {
  width: 100%;
  height: auto;
  max-height: 88px;
  opacity: 0.35;
}

/* ========================================
   优惠券弹窗样式
   ======================================== */

/* 弹窗容器 */
.coupon-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  /* 创建独立的堆叠上下文，隔离内外元素 */
  isolation: isolate;
}

.coupon-modal.open {
  display: flex;
}

/* 遮罩层 */
.coupon-modal__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

/* 弹窗主体 */
.coupon-modal__container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  /* 确保内容不会被外部元素穿透 */
  isolation: isolate;
}

/* 弹窗头部 */
.coupon-modal__header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  border-block-end: 1px solid #eee;
}

.coupon-modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.coupon-modal__close {
  position: absolute;
  inset-block-start: 16px;
  inset-inline-end: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #666;
  cursor: pointer;
  background: transparent;
  border: none;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.coupon-modal__close:hover {
  background-color: #f5f5f5;
}

/* Tab 切换 */
.coupon-modal__tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background-color: #fff;
  border-block-end: 1px solid #eee;
}

.coupon-modal__tab {
  position: relative;
  padding: 16px 24px;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: color 0.2s ease;
}

.coupon-modal__tab:hover {
  color: var(--cart-sidebar-primary);
}

.coupon-modal__tab.active {
  color: var(--cart-sidebar-primary);
}

.coupon-modal__tab.active::after {
  content: "";
  position: absolute;
  inset-block-end: -1px;
  inset-inline-start: 24px;
  inset-inline-end: 24px;
  height: 2px;
  background-color: var(--cart-sidebar-primary);
  border-radius: 1px;
}

/* 优惠券内容区域 */
.coupon-modal__content {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  background-color: #fff;
}

.coupon-modal__panel {
  display: none;
}

.coupon-modal__panel.active {
  display: block;
}

/* 优惠券列表 */
.coupon-modal__list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 优惠券卡片 */
.coupon-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  transition: border-color 0.2s ease;
}

.coupon-card:hover {
  border-color: #ccc;
}

.coupon-card--disabled {
  opacity: 0.6;
}

/* 优惠券卡片头部 */
.coupon-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-block-end: 8px;
}

.coupon-card__discount {
  font-size: 20px;
  font-weight: 700;
  color: #333;
}

/* Use Now 按钮 */
.coupon-card__action {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background-color: var(--cart-sidebar-primary);
  border: none;
  border-radius: 6px;
  transition: opacity 0.2s ease;
}

.coupon-card__action:hover {
  opacity: 0.9;
}

.coupon-card__action:disabled {
  cursor: not-allowed;
  background-color: #ccc;
}

/* 优惠券信息 */
.coupon-card__info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coupon-card__condition {
  font-size: 14px;
  color: #666;
}

.coupon-card__validity {
  font-size: 14px;
  color: #666;
}

/* 优惠券详情/规则 */
.coupon-card__details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-block-start: 12px;
  margin-block-start: 12px;
  border-block-start: 1px dashed #e0e0e0;
}

.coupon-card__rule {
  font-size: 13px;
  color: #999;
}

.coupon-card__rule::before {
  content: "•";
  margin-inline-end: 6px;
}

/* 空状态 */
.coupon-modal__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #999;
  font-size: 14px;
}

.coupon-modal__empty.hidden {
  display: none;
}

/* PC 端隐藏奖项展示模块 */
@media (min-width: 960px) {
  .cart-sidebar__awards-section {
    display: none;
  }
}

/* 响应式设计 */
@media (max-width: 959px) {
  .main-cart-sidebar {
    margin-block-start: 24px;
  }

  /* 移动端隐藏订单摘要和结账按钮 */
  .cart-sidebar__order-summary,
  .cart-sidebar__checkout-buttons,
  .cart-sidebar__trust-awards {
    display: none;
  }

  /* 优惠券弹窗移动端样式 */
  .coupon-modal__container {
    max-width: 100%;
    max-height: 90vh;
    margin: 16px;
    border-radius: 12px;
  }

  .coupon-modal__header {
    padding: 16px 20px;
  }

  .coupon-modal__title {
    font-size: 16px;
  }

  .coupon-modal__tabs {
    padding: 0 16px;
  }

  .coupon-modal__tab {
    flex: 1;
    padding: 14px 12px;
    font-size: 13px;
    text-align: center;
  }

  .coupon-modal__tab.active::after {
    inset-inline-start: 12px;
    inset-inline-end: 12px;
  }

  .coupon-modal__content {
    padding: 16px;
  }

  .coupon-card {
    padding: 16px;
  }

  .coupon-card__discount {
    font-size: 18px;
  }

  .coupon-card__action {
    padding: 8px 16px;
    font-size: 12px;
  }

  .cart-sidebar__promo-form .cart-coupon__form {
    flex-direction: column;
  }

  .cart-sidebar__promo-form .cart-coupon__form .field__input {
    border-radius: 10px;
    border-inline-end: 1px solid var(--cart-sidebar-light-text);
    margin-block-end: 8px;
  }

  .cart-sidebar__promo-form .cart-coupon__button {
    width: 100%;
    border-radius: 10px;
  }

  /* 移动端错误状态下输入框边框保持四边完整 */
  .cart-sidebar__promo-form .field--error .field__input {
    border: 1px solid var(--cart-sidebar-primary);
  }
}
