/*
 * 文件作用：
 * 为 iwamed.com 与 ipetmed.com 的自定义商城页面提供稳定的 WordPress/Blocksy 外层修复。
 * 这个文件只依赖 body 上的 pmgr-* class，不依赖 :has()，避免主题升级后选择器失效。
 */

body.pmgr-site-page {
  --pmgr-red: #C8102E;
  --pmgr-red-hover: #E13349;
  --pmgr-dark: #0b0b0c;
  --pmgr-panel: #111113;
  --pmgr-white: #ffffff;
  --pmgr-soft: #d6d6d8;
  --pmgr-gray: #a8a8ad;
  --pmgr-border: #e2e4e8;
  --pmgr-nav-height: 80px;
  margin: 0 !important;
  padding: 0 !important;
}

body.pmgr-site-page *,
body.pmgr-site-page *::before,
body.pmgr-site-page *::after {
  box-sizing: border-box;
}

/*
 * 关键修复：
 * Blocksy 会给 main、article、entry-content 加最大宽度和 padding。
 * 自定义商城页需要自己控制全宽，所以这里统一清掉外层限制。
 */
body.pmgr-site-page #main-container,
body.pmgr-site-page main.site-main,
body.pmgr-site-page main.site-main.hfeed,
body.pmgr-site-page .ct-container,
body.pmgr-site-page .ct-container-full,
body.pmgr-site-page article,
body.pmgr-site-page .hentry,
body.pmgr-site-page .entry-content,
body.pmgr-site-page .entry-content.is-layout-constrained,
body.pmgr-site-page .wp-site-blocks {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  filter: none !important;
  perspective: none !important;
}

body.pmgr-site-page .entry-content > *,
body.pmgr-site-page article > * {
  max-width: none !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/*
 * 隐藏 Blocksy 默认头尾和页面标题区。
 * 旧方案依赖 :has(.iwa-content-page)，这里改为 body class，稳定性更高。
 */
body.pmgr-site-page header#header,
body.pmgr-site-page .ct-header,
body.pmgr-site-page footer.ct-footer,
body.pmgr-site-page #footer.ct-footer,
body.pmgr-site-page .hero-section,
body.pmgr-site-page header.entry-header,
body.pmgr-site-page .entry-header,
body.pmgr-site-page .blocksy-woo-messages-default {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/*
 * 兼容过渡期：
 * 旧页面正文里可能仍有 nav/footer。新插件已经统一输出，正文内旧组件先隐藏，避免重复。
 */
body.pmgr-site-page .entry-content > nav.nav,
body.pmgr-site-page .entry-content > footer.footer,
body.pmgr-site-page .entry-content > .iwa-content-page {
  display: none !important;
}

/*
 * 防止旧 MU 插件在 WooCommerce 页面继续输出第二套导航/页脚。
 * 新插件输出的导航带有 .pmgr-nav，页脚带有 .pmgr-footer，所以不会被这里隐藏。
 */
body.pmgr-site-page > nav.nav:not(.pmgr-nav),
body.pmgr-site-page > footer.footer:not(.pmgr-footer) {
  display: none !important;
}

body.pmgr-site-page a {
  text-decoration: none;
}

body.pmgr-site-page img {
  max-width: 100%;
  height: auto;
}

body.pmgr-site-page .pmgr-page-content,
body.pmgr-site-page .pmgr-home-content,
body.pmgr-site-page .pmgr-shop-content {
  width: 100%;
  margin: 0;
  padding: 0;
}

/*
 * 过渡期兼容：
 * 当新插件（pmgr-site-frontend.php）和旧插件（pmgr-custom-footer.php）
 * 同时运行时，隐藏旧插件输出的重复 nav / footer / 搜索 FAB。
 * 新插件输出的元素带有 .pmgr-nav / .pmgr-footer / id=pmgr-search-fab，不会被这里隐藏。
 * 旧插件输出的 .nav（无 .pmgr-nav）和 .footer（无 .pmgr-footer）会被隐藏。
 */
body.pmgr-site-page > nav.nav:not(.pmgr-nav) {
  display: none !important;
}

body.pmgr-site-page > footer.footer:not(.pmgr-footer) {
  display: none !important;
}

/* 隐藏旧插件注入的 .iwa-content-page marker div（它本身 display:none，此处仅防意外） */
body.pmgr-site-page > .iwa-content-page {
  display: none !important;
}

/* 隐藏旧插件注入的搜索 FAB（新插件用 id=pmgr-search-fab，旧的用 id=iwa-search-fab） */
body.pmgr-site-page #iwa-search-fab {
  display: none !important;
}

/* ══════════════════════════════════════════════════════════════
   搜索 FAB 样式（新插件通过 wp_footer 输出 #pmgr-search-fab）
   迁移自 iwamed-fixes.css，这里作为静态文件加载，> 不会被转义。
   ══════════════════════════════════════════════════════════════ */

a.iwa-search-fab {
  position: fixed !important;
  left: 20px !important;
  bottom: 20px !important;
  top: auto !important;
  right: auto !important;
  z-index: 50 !important;
  width: 56px !important;
  height: 56px !important;
  padding: 0 !important;
  margin: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #222226 !important;
  color: #ffffff !important;
  border: 0 !important;
  border-radius: 50% !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25) !important;
  text-decoration: none !important;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

a.iwa-search-fab:hover,
a.iwa-search-fab:focus-visible {
  background: #C8102E !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(200, 16, 46, 0.4) !important;
  color: #ffffff !important;
}

a.iwa-search-fab:active {
  transform: translateY(0);
}

a.iwa-search-fab .iwa-search-fab__icon {
  width: 24px;
  height: 24px;
  display: block;
  pointer-events: none;
}

@media (max-width: 639px) {
  a.iwa-search-fab {
    left: 16px !important;
    bottom: 16px !important;
    width: 48px !important;
    height: 48px !important;
  }

  a.iwa-search-fab .iwa-search-fab__icon {
    width: 22px;
    height: 22px;
  }
}

/* 隐藏 Blocksy 默认头尾里的站点标题文字（我们只要 Logo 图片）
   注：Blocksy 头部本身已被 body.pmgr-site-page 规则 display:none，
   这里双保险防止某些页面 header 没被完全隐藏时文字溢出。 */
header.ct-header .site-title,
header.ct-header .ct-site-title,
header.ct-header h1.site-title,
header.ct-header h2.site-title,
header.ct-header [class*="site-title"],
header.ct-header .site-description,
header.ct-header .ct-site-description,
header.ct-header [class*="site-description"] {
  display: none !important;
}
