/**
 * You May Also Like Section Styles
 * 基于 Figma 设计稿实现
 */

.you-may-also-like {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--page-width-spacing);
}

/* ===== 标题区域 ===== */
.you-may-also-like__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid #d1d1d1;
}

.you-may-also-like__title {
  margin: 0;
  font-family: "Open Sans", sans-serif;
  font-size: 24px;
  font-weight: 400;
  line-height: normal;
  color: #C68635;
}


/* ===== 产品列表区域 ===== */
.you-may-also-like__products {
  position: relative;
  padding: 0 20px 0 0; /* 右侧为箭头留出空间 */
}

.you-may-also-like__carousel {
  position: relative;
  overflow: visible; /* 允许箭头显示在容器外部 */
  width: 100%;
}

.you-may-also-like__grid {
  /* 使用 flex 布局配合 carousel 组件实现滚动切换 */
  display: flex !important; /* 覆盖grid类的display: grid */
  gap: 15px;
  list-style: none;
  margin: 0;
  padding: 0;
  /* carousel 滚动必需样式 */
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  width: 100%;
  flex-wrap: nowrap; /* PC端不换行，确保可以横向滚动 */
  /* 覆盖grid类的grid布局相关属性 */
  grid-template-columns: none !important;
  grid-auto-flow: unset !important;
  grid-auto-columns: unset !important;
}

.you-may-also-like__grid::-webkit-scrollbar {
  display: none;
}

.you-may-also-like__item {
  /* 宽度由 JS 动态计算设置 */
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.you-may-also-like__products {
  position: relative;
  padding-left: 0 !important;
}


/* 产品卡片 */
.you-may-also-like__product-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
}

.you-may-also-like__product-image {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3; /* 高宽比 1.5:1 */
  overflow: hidden;
  background-color: #f5f5f5;
}

.you-may-also-like__product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.you-may-also-like__product-card:hover .you-may-also-like__product-image img {
  transform: scale(1.05);
}

.you-may-also-like__product-price {
  font-family: "Open Sans", sans-serif;
  font-size: 16px;
  font-weight: 700;
  line-height: normal;
  color: #5c3c30;
}

/* 导航按钮 - 参考 product-list 按钮样式 */
.you-may-also-like__nav-btn {
  position: absolute;
  top: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background-color: transparent;
  transform: translateY(-50%);
  transition: all 0.2s ease;
}

.you-may-also-like__nav-btn svg rect {
  transition: fill 0.2s ease;
}

.you-may-also-like__nav-btn svg path {
  transition: fill 0.2s ease;
}

.you-may-also-like__nav-btn:not(:disabled):hover {
  transform: translateY(-50%) scale(1.05);
}

.you-may-also-like__nav-btn:not(:disabled):hover svg rect {
  fill: #b8772a;
}

.you-may-also-like__nav-btn:not(:disabled):hover svg path {
  fill: #fff;
}

.you-may-also-like__nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.you-may-also-like__nav-btn--prev {
  left: -20px;
}

.you-may-also-like__nav-btn--next {
  right: -20px;
}

.you-may-also-like__nav-btn svg {
  width: 40px;
  height: 40px;
}

/* PC端确保箭头显示和所有商品可见 */
@media (min-width: 960px) {
  .you-may-also-like__nav-btn {
    display: flex !important;
  }
  
  .you-may-also-like__nav-btn.hidden-mobile {
    display: flex !important;
  }
  
  /* 确保grid使用flex布局，可以显示所有商品，不被截断 */
  .you-may-also-like__grid {
    display: flex !important;
    overflow-x: auto;
    flex-wrap: nowrap;
    grid-template-columns: none !important;
    grid-auto-flow: unset !important;
  }
  
  /* 确保所有item都显示 */
  .you-may-also-like__item {
    display: block !important;
    visibility: visible !important;
    flex-shrink: 0; /* 防止item被压缩 */
  }
}

/* ===== 骨架屏加载动画 ===== */
.you-may-also-like__item--skeleton .you-may-also-like__product-card {
  pointer-events: none;
}

.you-may-also-like__skeleton-image {
  width: 100%;
  aspect-ratio: 2 / 3; /* 高宽比 1.5:1 */
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: you-may-also-like-shimmer 1.5s infinite;
  border-radius: 4px;
}

.you-may-also-like__skeleton-text {
  width: 60%;
  height: 16px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: you-may-also-like-shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes you-may-also-like-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* 无图片占位 */
.you-may-also-like__placeholder-image {
  width: 100%;
  height: 100%;
  background-color: #f5f5f5;
}

/* ===== 移动端底部附加区域：支付图标 + 自定义徽章 ===== */
.you-may-also-like__mobile-extras {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* 支付方式图标 */
.you-may-also-like__payment-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.you-may-also-like__payment-title {
  font-size: 16px;
  font-weight: 600;
  color: #c68635;
  margin: 0;
}

.you-may-also-like__payment-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.you-may-also-like__payment-icons > svg,
.you-may-also-like__payment-icons > img {
  height: 32px;
  width: auto;
}

/* ===== 响应式设计 ===== */
@media (max-width: 959px) {
  .you-may-also-like {
    padding-left: 16px;
  }

  .you-may-also-like__title {
    font-size: 18px;
  }

  .you-may-also-like__grid {
    gap: 12px;
  }

  .you-may-also-like__product-price {
    font-size: 14px;
  }
}
