/**
 * 類目主題館（pages/catalog）— 麵包屑、左側直列分類、右側搜尋與商品網格
 */
.catalog-theme-page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 56px;
  box-sizing: border-box;
}

.catalog-theme-hero.has-banner {
  width: 100%;
  min-height: 0;
  height: auto;
  max-height: 160px;
  aspect-ratio: 21 / 9;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background-color: #e2e8f0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.catalog-theme-body {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

@media (min-width: 1400px) {
  .catalog-theme-body {
    padding: 0 15px;
  }
}

.catalog-theme-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 8px;
  min-height: 36px;
  box-sizing: border-box;
}

.catalog-theme-crumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--pos-text-color, #334155);
}

.catalog-theme-crumb a {
  color: var(--pos-text-color, #334155);
  text-decoration: none;
}

.catalog-theme-crumb a:hover {
  color: var(--pos-highlight, var(--button-color, #778ca3));
  text-decoration: underline;
}

.catalog-theme-crumb__sep {
  color: #94a3b8;
  font-weight: 500;
}

.catalog-theme-crumb__current {
  color: var(--pos-text-color, #0f172a);
  font-weight: 800;
}

.catalog-theme-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
}

.catalog-theme-layout.has-side {
  flex-direction: row;
  align-items: flex-start;
  gap: 32px;
}

.catalog-theme-side {
  flex: 0 0 190px;
  width: 190px;
  min-width: 0;
  padding-top: 8px;
  box-sizing: border-box;
}

.catalog-theme-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  margin: 0;
}

.catalog-theme-nav__link {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 3px 0 3px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  color: #94a3b8;
  transition: color 0.15s ease;
}

.catalog-theme-nav__link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 1.5px;
  background: transparent;
}

.catalog-theme-nav__link:hover {
  color: var(--pos-text-color, #334155);
}

.catalog-theme-nav__link.is-active {
  color: var(--pos-text-color, #334155);
  font-weight: 600;
}

.catalog-theme-nav__link.is-active::before {
  background: var(--pos-text-color, #334155);
}

.catalog-theme-nav__sub-group {
  min-width: 0;
}

.catalog-theme-nav__sub-head {
  display: flex;
  align-items: center;
}

.catalog-theme-nav__sub-head .catalog-theme-nav__link {
  flex: 1 1 auto;
}

.catalog-theme-nav__toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: 2px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.catalog-theme-nav__toggle svg {
  transition: transform 0.2s ease;
}

.catalog-theme-nav__toggle:hover {
  background: #f1f5f9;
  color: #64748b;
}

.catalog-theme-nav__toggle:focus-visible {
  outline: 2px solid var(--pos-highlight, var(--button-color, #6e7f8d));
  outline-offset: 1px;
}

.catalog-theme-nav__sub-group.is-expanded > .catalog-theme-nav__sub-head > .catalog-theme-nav__toggle {
  color: #64748b;
}

.catalog-theme-nav__sub-group.is-expanded > .catalog-theme-nav__sub-head > .catalog-theme-nav__toggle svg {
  transform: rotate(180deg);
}

.catalog-theme-nav__terts {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.22s ease, opacity 0.18s ease;
  padding-left: 8px;
  margin: 0 0 0 12px;
  border-left: 2px solid #eef1f5;
}

.catalog-theme-nav__sub-group.is-expanded > .catalog-theme-nav__terts {
  max-height: 1000px;
  opacity: 1;
  margin-top: 4px;
}

.catalog-theme-nav__link--tert {
  font-size: 13px;
  padding: 3px 0 3px 10px;
}

.catalog-theme-main {
  flex: 1 1 auto;
  min-width: 0;
}

.catalog-theme-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 4px 0 8px;
}

.catalog-theme-search {
  flex: 0 0 auto;
  width: min(260px, 100%);
  padding: 0;
  margin: 0;
}

.catalog-theme-search__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.catalog-theme-search__row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: none;
  min-height: 36px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 0 10px;
  box-sizing: border-box;
}

.catalog-theme-search__icon {
  font-size: 15px;
  line-height: 1;
  opacity: 0.65;
  flex-shrink: 0;
}

.catalog-theme-search__input {
  flex: 1 1 auto;
  min-width: 0;
  border: none !important;
  background: transparent !important;
  padding: 6px 0 !important;
  margin: 0 !important;
  font-size: 13px !important;
  font-weight: 600;
  color: #0f172a;
  box-shadow: none !important;
  outline: none;
}

.catalog-theme-search__input::placeholder {
  color: #94a3b8;
  font-weight: 500;
}

.catalog-theme-search__count {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
}

.catalog-theme-grid {
  padding: 8px 0 8px;
}

.catalog-theme-grid__empty[hidden] {
  display: none !important;
}

.catalog-theme-page .wx-card-detail-link,
.catalog-theme-page .wx-card-detail-link:visited {
  color: inherit;
  text-decoration: none;
}

.catalog-theme-page .wx-card-detail-link--title:hover {
  color: var(--pos-highlight, var(--button-color, var(--primary-color, #778ca3)));
  text-decoration: none;
}

.catalog-theme-grid__empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 56px 20px;
  color: #64748b;
  font-size: 15px;
  line-height: 1.6;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  border: 1px dashed #cbd5e1;
}

@media (min-width: 1100px) {
  body.wx-static-body .catalog-theme-page .catalog-theme-grid .wx-home-product-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 768px) and (max-width: 1099px) {
  body.wx-static-body .catalog-theme-page .catalog-theme-grid .wx-home-product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 768px) {
  .catalog-theme-hero.has-banner {
    max-height: 110px;
  }

  .catalog-theme-layout.has-side {
    flex-direction: column;
    /* 桌面版 .has-side 是 align-items:flex-start，切成直排後若不覆寫，
       .catalog-theme-main 會縮成內容寬度，右側留下一大塊空白 */
    align-items: stretch;
    gap: 12px;
  }

  .catalog-theme-side {
    display: flex;
    /* 桌面版 flex:0 0 190px 在直排(column)下會變成「固定高度 190px」，
       把裡面的分類藥丸整個拉伸撐高，這裡要清掉 */
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    padding-top: 0;
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .catalog-theme-side::-webkit-scrollbar {
    display: none;
  }

  .catalog-theme-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    width: max-content;
  }

  .catalog-theme-nav__link {
    width: auto;
    padding: 6px 14px;
    border-radius: 999px;
    background: #f1f5f9;
    white-space: nowrap;
  }

  /* 手機版分類是橫向滑動藥丸列，第三層收合在這裡沒有意義：
     把 sub-group 攤平成跟其他藥丸一樣的純連結，展開箭頭跟第三層都不顯示 */
  .catalog-theme-nav__sub-group {
    display: contents;
  }

  .catalog-theme-nav__sub-head {
    display: contents;
  }

  .catalog-theme-nav__toggle,
  .catalog-theme-nav__terts {
    display: none;
  }

  .catalog-theme-nav__link::before {
    display: none;
  }

  .catalog-theme-nav__link.is-active {
    background: var(--pos-highlight, var(--button-color, #587493));
    color: #fff;
  }

  /* 搜尋框改跟麵包屑同一列（在 .catalog-theme-head 內），不再單獨佔一整列 */
  .catalog-theme-head {
    flex-wrap: nowrap;
    gap: 10px;
  }

  .catalog-theme-crumb {
    flex: 1 1 auto;
    min-width: 0;
  }

  .catalog-theme-toolbar {
    flex: 0 0 auto;
    justify-content: flex-end;
    padding: 0;
  }

  .catalog-theme-search {
    width: 150px;
  }

  .catalog-theme-search__count {
    display: none;
  }
}

/* 換頁：桌機顯示頁碼點擊列，手機改滑到底自動載入下一頁 */
.catalog-theme-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0 8px;
}

.catalog-theme-pagination__btn,
.catalog-theme-pagination__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.catalog-theme-pagination__btn:hover,
.catalog-theme-pagination__num:hover {
  border-color: var(--pos-highlight, var(--button-color, #778ca3));
  color: var(--pos-highlight, var(--button-color, #778ca3));
}

.catalog-theme-pagination__btn.is-disabled {
  color: #cbd5e1;
  cursor: default;
  pointer-events: none;
}

.catalog-theme-pagination__num.is-current {
  background: var(--pos-highlight, var(--button-color, #778ca3));
  border-color: var(--pos-highlight, var(--button-color, #778ca3));
  color: #fff;
  cursor: default;
  pointer-events: none;
}

.catalog-theme-pagination__nums {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.catalog-theme-pagination__ellipsis {
  color: #94a3b8;
  font-weight: 700;
  padding: 0 2px;
}

.catalog-theme-pagination__sentinel {
  height: 1px;
}

.catalog-theme-pagination__loading {
  margin: 4px 0 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
}

.catalog-theme-pagination__loading[hidden] {
  display: none !important;
}

@media (max-width: 768px) {
  /* 手機：隱藏頁碼點擊列，改用滑到底自動載入 */
  .catalog-theme-pagination {
    display: none;
  }
}
