/**
 * ======== sanxio 商城首页区块 MD3 start ===========
 * 配合 template/responsive/mall/index.htm 与各 chip
 */

.sx-mall-index-page {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  max-width: var(--sanxio-page-max-width, 1280px);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  --sx-mall-gutter: var(--sanxio-block-padding-x, var(--sanxio-block-px, 12px));
  padding-top: var(--sanxio-block-padding-y, var(--sanxio-content-gap, 12px));
  padding-bottom: var(--sanxio-block-padding-y, var(--sanxio-block-px, 20px));
  padding-left: var(--sx-mall-gutter) !important;
  padding-right: var(--sx-mall-gutter) !important;
}

/* 桌面：与全站内容轨同宽（--sanxio-page-max-width） */
@media (min-width: 768px) {
  body.sx-mall-premium-page .sx-mall-index-page.sx-mall-page,
  body.sx-mall-premium-page .sx-mall-index-page {
    max-width: var(--sanxio-page-max-width, 1280px);
    --sx-mall-gutter: var(--sanxio-block-px, 20px);
  }
}

body.sx-mall-premium-page .sx-mall-index-page > .sanxio-mall-index-products {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* 首页主区块垂直间距：Premium 页用 flex gap 统一轨距，避免首块 padding + 下块 margin 叠加倍数 */
.sx-mall-index-page > .sanxio-mall-banner,
.sx-mall-index-page > .sx-mall-sec-shelf,
.sx-mall-index-page > .sx-mall-announce,
.sx-mall-index-page > .sx-mall-section,
.sx-mall-index-page > .sx-mall-floor,
.sx-mall-index-page > .sanxio-mall-index-products {
  margin-top: var(--sanxio-content-gap, 12px);
}

.sx-mall-index-page > .sx-mall-index-strip {
  margin-top: 0;
  margin-bottom: 0;
}

/* ---------- 通用区块卡片 ---------- */
.sx-mall-section {
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 0;
}

.sx-mall-card,
.sx-mall-sec-shelf,
.sx-mall-announce,
.sx-mall-floor {
  background: var(--md3-color-surface, #fff);
  border: 1px solid var(--md3-color-outline-variant, #c3c6cf);
  border-radius: var(--md3-shape-lg, 16px);
  box-shadow: var(--md3-elevation-1, 0 1px 4px rgba(0, 0, 0, 0.06));
  padding: var(--sanxio-card-py, 16px) var(--sanxio-card-px, 16px);
}

.sx-mall-card__head,
.sx-mall-sec-shelf__head,
.sx-mall-announce__head,
.sx-mall-floor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sanxio-gap-md, 12px);
  margin-bottom: var(--sanxio-content-gap, 12px);
  padding-bottom: var(--sanxio-gap-sm, 8px);
  border-bottom: 1px solid var(--md3-color-outline-variant, #e7e0ec);
}

.sx-mall-card__title,
.sx-mall-sec-shelf__title,
.sx-mall-announce__title,
.sx-mall-floor__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: var(--text-lg, 16px);
  font-weight: 700;
  color: var(--md3-color-on-surface, #1a1c1e);
}

.sx-mall-card__title .material-symbols-outlined,
.sx-mall-sec-shelf__title .material-symbols-outlined,
.sx-mall-announce__title .material-symbols-outlined {
  font-size: 22px;
  color: var(--md3-color-primary, #005fb8);
}

.sx-mall-sec-shelf__more,
.sx-mall-announce__more,
.sx-mall-floor__more {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--md3-color-primary, #005fb8);
  text-decoration: none;
  white-space: nowrap;
}

.sx-mall-sec-shelf__more .material-symbols-outlined,
.sx-mall-announce__more .material-symbols-outlined,
.sx-mall-floor__more .material-symbols-outlined {
  font-size: 18px;
}

.sx-mall-sec-shelf__count {
  display: inline-flex;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 20px;
  background: var(--md3-color-error-container, #ffdad6);
  color: var(--md3-color-error, #ba1a1a);
}

/* ---------- 限时秒杀横向货架 ---------- */
.sx-mall-sec-shelf__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(142px, 148px);
  gap: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.sx-mall-sec-shelf__track::-webkit-scrollbar {
  height: 6px;
}

.sx-mall-sec-shelf__track::-webkit-scrollbar-thumb {
  background: var(--md3-color-outline-variant, #c3c6cf);
  border-radius: 999px;
}

.sx-mall-sec-card {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: var(--sanxio-gap-sm, 8px);
  text-decoration: none;
  color: inherit;
  background: var(--md3-color-surface-container-low, #f7f8fa);
  border: 1px solid var(--md3-color-outline-variant, #e7e0ec);
  border-radius: var(--md3-shape-md, 12px);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .sx-mall-sec-shelf__track {
    grid-auto-columns: minmax(160px, 168px);
    gap: 12px;
  }
}

.sx-mall-sec-card:hover {
  border-color: var(--md3-color-primary, #005fb8);
  box-shadow: var(--md3-elevation-2, 0 2px 8px rgba(0, 0, 0, 0.08));
}

.sx-mall-sec-card__media {
  display: block;
  aspect-ratio: 1;
  border-radius: var(--md3-shape-sm, 8px);
  overflow: hidden;
  background: var(--md3-color-surface, #fff);
}

.sx-mall-sec-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sx-mall-sec-card__price {
  font-size: 15px;
  font-weight: 800;
  color: var(--md3-color-error, #ba1a1a);
}

.sx-mall-sec-card__badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--md3-color-on-surface-variant, #43474e);
}

.sx-mall-sec-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
  font-size: 12px;
  line-height: 1.35;
  color: var(--md3-color-on-surface, #1a1c1e);
}

.sx-mall-direct,
.sx-mall-direct-badge {
  display: inline-flex;
  padding: 0 5px;
  margin-right: 2px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  background: var(--md3-color-primary, #005fb8);
  color: var(--md3-color-on-primary, #fff);
}

/* ---------- 网站动态 ---------- */
.sx-mall-announce__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sx-mall-announce__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--md3-color-outline-variant, #f0f0f0);
}

.sx-mall-announce__item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sx-mall-announce__link {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--md3-color-on-surface, #1a1c1e);
  text-decoration: none;
}

.sx-mall-announce__link:hover {
  color: var(--md3-color-primary, #005fb8);
}

.sx-mall-announce__time {
  font-size: 12px;
  color: var(--md3-color-on-surface-variant, #43474e);
  white-space: nowrap;
}

.sx-mall-announce__empty {
  margin: 0;
  padding: 20px 0 4px;
  text-align: center;
  font-size: 13px;
  color: var(--md3-color-on-surface-variant, #43474e);
}

/* ---------- 分类目录 ---------- */
.sx-mall-catalog {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sanxio-gap-md, 12px);
}

@media (min-width: 768px) {
  .sx-mall-catalog {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .sx-mall-catalog {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.sx-mall-catalog__group {
  padding: var(--sanxio-gap-sm, 8px) var(--sanxio-gap-md, 12px);
  background: var(--md3-color-surface-container-low, #f7f8fa);
  border: 1px solid var(--md3-color-outline-variant, #e7e0ec);
  border-radius: var(--md3-shape-md, 12px);
  min-width: 0;
}

.sx-mall-catalog__parent {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--md3-color-primary, #005fb8);
  text-decoration: none;
}

.sx-mall-catalog__parent:hover {
  text-decoration: underline;
}

.sx-mall-catalog__subs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.sx-mall-catalog__subs a {
  font-size: 12px;
  color: var(--md3-color-on-surface-variant, #43474e);
  text-decoration: none;
}

.sx-mall-catalog__subs a:hover {
  color: var(--md3-color-primary, #005fb8);
}

/* ---------- 分类楼层 ---------- */
.sx-mall-floor {
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 0;
}

.sx-mall-floor__subs {
  list-style: none;
  margin: 0 0 var(--sanxio-content-gap, 12px);
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sx-mall-floor__subs a {
  display: inline-flex;
  padding: 4px 12px;
  border-radius: var(--md3-shape-full, 9999px);
  border: 1px solid var(--md3-color-outline-variant, #c3c6cf);
  font-size: 12px;
  text-decoration: none;
  color: var(--md3-color-on-surface, #1a1c1e);
  background: var(--md3-color-surface-container-low, #f3f5f9);
}

.sx-mall-floor__subs a:hover {
  border-color: var(--md3-color-primary, #005fb8);
  color: var(--md3-color-primary, #005fb8);
}

.sx-mall-floor__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sanxio-gap-md, 12px);
}

@media (min-width: 600px) {
  .sx-mall-floor__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .sx-mall-floor__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.sx-mall-floor__grid .sanxio-home-product-card {
  min-width: 0;
}

/* ---------- 热销 feed（无外层卡片，仅标题 + 网格） ---------- */
.sx-mall-feed {
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.sx-mall-feed__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sanxio-gap-md, 12px);
  margin-bottom: var(--sanxio-content-gap, 12px);
  padding-bottom: var(--sanxio-gap-sm, 8px);
  border-bottom: 1px solid var(--md3-color-outline-variant, #e7e0ec);
}

.sx-mall-feed__title {
  margin: 0;
  font-size: var(--text-lg, 16px);
  font-weight: 700;
  color: var(--md3-color-on-surface, #1a1c1e);
}

body.sx-mall-premium-page .sx-mall-feed__grid,
body.sx-mall-premium-page .sanxio-mall-index-products__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sanxio-gap-md, 12px);
}

@media (min-width: 600px) {
  body.sx-mall-premium-page .sx-mall-feed__grid,
  body.sx-mall-premium-page .sanxio-mall-index-products__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  body.sx-mall-premium-page .sx-mall-feed__grid,
  body.sx-mall-premium-page .sanxio-mall-index-products__list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

body.sx-mall-premium-page .sx-mall-feed__grid .sanxio-home-product-card,
body.sx-mall-premium-page .sanxio-mall-index-products__list .sanxio-home-product-card {
  min-width: 0;
  height: 100%;
}

body.sx-mall-premium-page .sx-mall-feed__grid .sanxio-home-product-card__link,
body.sx-mall-premium-page .sanxio-mall-index-products__list .sanxio-home-product-card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---------- 顶栏折叠（移动默认收起） ---------- */
.sx-mall-index-strip__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sanxio-gap-md, 12px);
  width: 100%;
  min-width: 0;
}

.sx-mall-index-strip__brand {
  flex: 1;
  min-width: 0;
}

.sx-mall-index-strip__toggle {
  flex-shrink: 0;
  color: var(--md3-color-on-surface-variant, #43474e);
}

.sx-mall-index-strip__toggle-icon {
  transition: transform 0.2s ease;
}

.sx-mall-index-strip:not(.is-collapsed) .sx-mall-index-strip__toggle-icon {
  transform: rotate(180deg);
}

@media (max-width: 767px) {
  .sx-mall-index-strip.is-collapsed .sx-mall-index-strip__actions,
  .sx-mall-index-strip.is-collapsed .sx-mall-index-strip__btn--cart {
    display: none;
  }
}

@media (min-width: 768px) {
  /* 桌面：不展示商城导览卡（顶栏/购物车已覆盖同类入口） */
  .sx-mall-index-strip {
    display: none !important;
  }
}

/* ---------- 顶栏快捷按钮：移动双列网格 ---------- */
.sx-mall-index-strip__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sanxio-gap-sm, 8px);
  width: 100%;
  align-items: stretch;
}

.sx-mall-index-strip__btn.md3-btn {
  min-height: 36px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  justify-content: flex-start;
}

.sx-mall-index-strip__btn.md3-btn > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sx-mall-index-strip__btn--cart {
  justify-content: center;
}

@media (max-width: 767px) {
  .sx-mall-index-page > .sanxio-mall-banner,
  .sx-mall-index-page > .sx-mall-sec-shelf,
  .sx-mall-index-page > .sx-mall-announce,
  .sx-mall-index-page > .sx-mall-section,
  .sx-mall-index-page > .sx-mall-floor,
  .sx-mall-index-page > .sx-mall-feed,
  .sx-mall-index-page > .sanxio-mall-index-products {
    margin-top: 12px;
  }

  .sx-mall-card,
  .sx-mall-sec-shelf,
  .sx-mall-announce,
  .sx-mall-floor {
    padding: var(--sanxio-card-py, 12px) var(--sanxio-card-px, 12px);
  }

  .sx-mall-index-strip__inner {
    padding: var(--sanxio-gap-sm, 8px);
    gap: var(--sanxio-gap-sm, 8px);
  }

  .sx-mall-sec-shelf__track {
    gap: 12px !important;
    column-gap: 12px !important;
    padding-bottom: 6px;
  }

  .sx-mall-catalog {
    gap: 12px;
  }

  .sx-mall-floor__grid,
  body.sx-mall-premium-page .sx-mall-feed__grid,
  body.sx-mall-premium-page .sanxio-mall-index-products__list {
    gap: 12px !important;
  }

  .sx-mall-index-strip__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .sx-mall-index-strip__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sanxio-gap-sm, 8px);
    width: 100%;
  }

  .sx-mall-index-strip__btn {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    justify-content: flex-start;
  }

  .sx-mall-index-strip__btn--cart {
    flex: 1 1 100%;
    width: 100%;
    justify-content: center;
  }
}

/* ======== sanxio 商城首页间距（覆盖 margin:0 / 全站变量） start =========== */
body.sx-mall-premium-page .sx-mall-index-page {
  display: flex;
  flex-direction: column;
  gap: var(--sanxio-gap-md, 12px);
  padding-top: var(--sanxio-gap-md, 12px) !important;
  padding-bottom: var(--sanxio-block-padding-y, var(--sanxio-block-px, 20px));
}

body.sx-mall-premium-page .sx-mall-index-page > .sx-mall-index-strip,
body.sx-mall-premium-page .sx-mall-index-page > .sanxio-mall-banner,
body.sx-mall-premium-page .sx-mall-index-page > .sx-mall-sec-shelf,
body.sx-mall-premium-page .sx-mall-index-page > .sx-mall-announce,
body.sx-mall-premium-page .sx-mall-index-page > .sx-mall-section,
body.sx-mall-premium-page .sx-mall-index-page > .sx-mall-floor,
body.sx-mall-premium-page .sx-mall-index-page > .sx-mall-feed,
body.sx-mall-premium-page .sx-mall-index-page > .sanxio-mall-index-products,
body.sx-mall-premium-page .sx-mall-index-page > .sanxio-content-section {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

body.sx-mall-premium-page .sx-mall-index-page > .sx-mall-index-strip {
  padding-top: 0 !important;
}

body.sx-mall-premium-page .sx-mall-index-page > .sanxio-mall-banner {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

body.sx-mall-premium-page .sx-mall-sec-shelf__track {
  gap: 12px !important;
  column-gap: 12px !important;
}

body.sx-mall-premium-page .sx-mall-floor__grid,
body.sx-mall-premium-page .sanxio-mall-index-products__list,
body.sx-mall-premium-page .sx-mall-catalog {
  gap: 12px !important;
}

@media (max-width: 767px) {
  body.sx-mall-premium-page .sx-mall-index-page {
    gap: var(--sanxio-gap-md, 12px) !important;
    padding-top: var(--sanxio-gap-md, 12px) !important;
  }
}
/* ======== sanxio 商城首页间距 end =========== */

/* ======== sanxio 商城首页区块 MD3 end =========== */
