/*
 * 文件作用：
 * WooCommerce 分类页、产品详情页、购物车、结账页、搜索结果页的基础样式。
 * 将 iwamed-wc-products.css 和 iwamed-fixes.css 中依赖
 * body:has(.iwa-content-page) 的规则迁移为 body.pmgr-site-page，
 * 避免主题升级后 :has() 失效。
 *
 * 所有规则以 body.pmgr-site-page 为前缀，不污染非目标页面。
 */

/* ── WC 页面：为 fixed nav 留顶部空间 ── */
body.pmgr-page-wc main.site-main,
body.pmgr-page-search main.site-main {
  padding-top: var(--pmgr-nav-height, 84px) !important;
}

/* ══════════════════════════════════════════════════════════════
   WC 产品列表（分类页 / Shop 列表 / 标签页）
   ══════════════════════════════════════════════════════════════ */

/* 产品网格容器：1280px 居中，4 列 */
body.pmgr-site-page ul.products {
  max-width: 1280px !important;
  margin: 40px auto !important;
  padding: 0 40px !important;
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 24px !important;
  list-style: none !important;
}

/* 产品卡片 */
body.pmgr-site-page ul.products > li.product {
  background: #ffffff !important;
  border: 1px solid #e5e6ea !important;
  border-radius: 10px !important;
  overflow: hidden !important;
  transition: box-shadow 0.25s, transform 0.25s;
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
  float: none !important;
}

body.pmgr-site-page ul.products > li.product:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
  transform: translateY(-4px);
}

/* 图片区：固定高度居中 */
body.pmgr-site-page ul.products > li.product figure,
body.pmgr-site-page ul.products > li.product .ct-media-container {
  height: 220px !important;
  background: #f7f8fa !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
  margin: 0 !important;
  overflow: hidden !important;
  border-radius: 0 !important;
}

body.pmgr-site-page ul.products > li.product .wp-post-image,
body.pmgr-site-page ul.products > li.product img {
  max-width: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  transition: transform 0.35s !important;
  aspect-ratio: auto !important;
}

body.pmgr-site-page ul.products > li.product:hover .wp-post-image {
  transform: scale(1.06) !important;
}

/* 产品标题 */
body.pmgr-site-page ul.products > li.product .woocommerce-loop-product__title {
  font-size: 15px !important;
  font-weight: 600 !important;
  color: #222226 !important;
  line-height: 1.4 !important;
  padding: 16px 18px 4px !important;
  margin: 0 !important;
}

/* 价格：品牌红 */
body.pmgr-site-page ul.products > li.product .price {
  color: var(--pmgr-red, #C8102E) !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  padding: 4px 18px 12px !important;
  margin: 0 !important;
  display: block !important;
}

body.pmgr-site-page ul.products > li.product .price del {
  color: #999 !important;
  font-size: 13px !important;
  font-weight: 400 !important;
}

body.pmgr-site-page ul.products > li.product .price ins {
  text-decoration: none !important;
  color: var(--pmgr-red, #C8102E) !important;
}

/* SALE 角标 */
body.pmgr-site-page ul.products > li.product .onsale {
  background: var(--pmgr-red, #C8102E) !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 4px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  padding: 4px 10px !important;
  position: absolute !important;
  top: 12px !important;
  right: 12px !important;
}

/* Add to Cart 按钮 */
body.pmgr-site-page ul.products > li.product .button.add_to_cart_button,
body.pmgr-site-page ul.products > li.product a.button {
  display: block !important;
  margin: auto 18px 18px !important;
  padding: 10px 0 !important;
  background: #222226 !important;
  color: #ffffff !important;
  text-align: center !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  border-radius: 4px !important;
  text-decoration: none !important;
  border: 0 !important;
  transition: background 0.2s !important;
}

body.pmgr-site-page ul.products > li.product .button.add_to_cart_button:hover,
body.pmgr-site-page ul.products > li.product a.button:hover {
  background: var(--pmgr-red, #C8102E) !important;
  color: #ffffff !important;
}

/* 分类页标题：居中 + 红色下划线 */
body.pmgr-site-page .woocommerce-products-header__title,
body.pmgr-site-page .woocommerce-products-header h1 {
  text-align: center;
  color: #1a1a1d !important;
  font-size: 28px;
  font-weight: 700;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--pmgr-red, #C8102E);
  display: inline-block;
  margin: 40px auto 0;
}

/* 分页 */
body.pmgr-site-page .woocommerce-pagination ul {
  display: flex;
  justify-content: center;
  gap: 6px;
  list-style: none;
  margin: 40px 0;
  padding: 0;
}

body.pmgr-site-page .woocommerce-pagination ul li a,
body.pmgr-site-page .woocommerce-pagination ul li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  border: 1px solid #e5e6ea;
  color: #222226;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

body.pmgr-site-page .woocommerce-pagination ul li a:hover,
body.pmgr-site-page .woocommerce-pagination ul li span.current {
  background: var(--pmgr-red, #C8102E);
  color: #ffffff;
  border-color: var(--pmgr-red, #C8102E);
}

/* ══════════════════════════════════════════════════════════════
   单产品页（single-product）
   ══════════════════════════════════════════════════════════════ */

/* 浅灰背景，区分侧边页脚 */
body.pmgr-site-page.single-product {
  background: #f5f6f8 !important;
}

/* 内容区限宽 */
body.pmgr-site-page.single-product #main-container,
body.pmgr-site-page.single-product main.site-main,
body.pmgr-site-page.single-product .entry-content {
  max-width: 1280px !important;
  margin: 0 auto !important;
  padding: 20px 32px !important;
  width: auto !important;
  background: #ffffff !important;
}

body.pmgr-site-page.single-product .wp-site-blocks {
  max-width: none !important;
}

/* 面包屑 */
body.pmgr-site-page.single-product .ct-breadcrumbs,
body.pmgr-site-page.single-product .woocommerce-breadcrumb {
  color: #666 !important;
  font-size: 13px !important;
  margin-bottom: 24px !important;
}

body.pmgr-site-page.single-product .ct-breadcrumbs a,
body.pmgr-site-page.single-product .woocommerce-breadcrumb a {
  color: var(--pmgr-red, #C8102E) !important;
  font-weight: 500 !important;
}

/* 产品标题 */
body.pmgr-site-page.single-product .product_title,
body.pmgr-site-page.single-product h1.product_title {
  color: #1a1a1d !important;
  font-size: 32px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  margin-bottom: 16px !important;
}

/* 价格 */
body.pmgr-site-page.single-product .price,
body.pmgr-site-page.single-product p.price {
  font-size: 22px !important;
  font-weight: 700 !important;
  color: var(--pmgr-red, #C8102E) !important;
  margin-bottom: 20px !important;
}

body.pmgr-site-page.single-product .price del {
  color: #999 !important;
  font-weight: 400 !important;
  font-size: 18px !important;
}

body.pmgr-site-page.single-product .price ins {
  text-decoration: none !important;
  color: var(--pmgr-red, #C8102E) !important;
}

/* Add to Cart 按钮 */
body.pmgr-site-page.single-product .single_add_to_cart_button,
body.pmgr-site-page.single-product button.single_add_to_cart_button {
  background: var(--pmgr-red, #C8102E) !important;
  background-color: var(--pmgr-red, #C8102E) !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 600 !important;
  padding: 14px 32px !important;
  border-radius: 4px !important;
  transition: background 0.2s !important;
}

body.pmgr-site-page.single-product .single_add_to_cart_button:hover,
body.pmgr-site-page.single-product button.single_add_to_cart_button:hover {
  background: var(--pmgr-red-hover, #E13349) !important;
  background-color: var(--pmgr-red-hover, #E13349) !important;
}

/* SKU / 分类 meta */
body.pmgr-site-page.single-product .product_meta {
  font-size: 14px !important;
  color: #666 !important;
  margin-top: 20px !important;
  padding-top: 20px !important;
  border-top: 1px solid #eee !important;
}

body.pmgr-site-page.single-product .product_meta a {
  color: var(--pmgr-red, #C8102E) !important;
  font-weight: 500 !important;
}

/* Tabs */
body.pmgr-site-page.single-product .woocommerce-tabs ul.tabs > li.active > a {
  color: var(--pmgr-red, #C8102E) !important;
  border-bottom-color: var(--pmgr-red, #C8102E) !important;
}

/* 相关产品 */
body.pmgr-site-page.single-product .related.products h2 {
  color: #1a1a1d !important;
  font-size: 24px !important;
  font-weight: 700 !important;
  padding-bottom: 12px !important;
  margin-bottom: 24px !important;
  border-bottom: 2px solid var(--pmgr-red, #C8102E) !important;
  display: inline-block !important;
}

/* ══════════════════════════════════════════════════════════════
   搜索结果 / Cart / Checkout — 限宽居中
   ══════════════════════════════════════════════════════════════ */

body.pmgr-site-page.search main.site-main,
body.pmgr-site-page.woocommerce-cart main.site-main,
body.pmgr-site-page.woocommerce-checkout main.site-main,
body.pmgr-site-page.search .entry-content,
body.pmgr-site-page.woocommerce-cart .entry-content,
body.pmgr-site-page.woocommerce-checkout .entry-content {
  max-width: 1280px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 20px 32px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Cart 结账按钮：品牌红 */
body.pmgr-site-page.woocommerce-cart .wc-proceed-to-checkout a.checkout-button,
body.pmgr-site-page.woocommerce-cart a.checkout-button {
  background: var(--pmgr-red, #C8102E) !important;
  background-color: var(--pmgr-red, #C8102E) !important;
  color: #ffffff !important;
  border: 0 !important;
  border-radius: 6px !important;
  transition: background 0.15s !important;
}

body.pmgr-site-page.woocommerce-cart .wc-proceed-to-checkout a.checkout-button:hover {
  background: #a50d26 !important;
}

/* ══════════════════════════════════════════════════════════════
   响应式 — 平板/手机
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1023px) {
  body.pmgr-site-page ul.products {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px !important;
    padding: 0 24px !important;
  }

  body.pmgr-site-page ul.products > li.product figure,
  body.pmgr-site-page ul.products > li.product .ct-media-container {
    height: 180px !important;
  }
}

@media (max-width: 639px) {
  body.pmgr-site-page ul.products {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    padding: 0 16px !important;
  }

  body.pmgr-site-page ul.products > li.product figure,
  body.pmgr-site-page ul.products > li.product .ct-media-container {
    height: 140px !important;
  }
}
