/* V174 · 商品分类与价格筛选弹层：始终贴合触发控件，内容与操作区不被表格裁剪。 */

.view-root[data-view="productCatalog"] :is(.catalog-filter-deck, .catalog-filter-row),
.view-root[data-view="catalog"] :is(.store-catalog-filter-deck, .store-catalog-filter-row) {
  overflow: visible !important;
}

/* 商品资料是表格内容，不应被误渲染成独立输入框或卡片。 */
body[data-ui-version="44"] .app-shell :is(.catalog-product-summary, .store-product-summary) {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* 筛选栏的“排序”必须始终是一行：中文标签不能在窄列中被逐字拆开。 */
body[data-ui-version="44"] .view-root :is(.catalog-filter-row, .store-catalog-filter-row) .catalog-sort-control {
  display: grid !important;
  grid-template-columns: 42px minmax(88px, 1fr);
  align-items: stretch;
  min-width: 130px !important;
  width: 100%;
  height: 40px !important;
  overflow: hidden;
}

body[data-ui-version="44"] .view-root :is(.catalog-filter-row, .store-catalog-filter-row) .catalog-sort-control > span {
  display: flex !important;
  min-width: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
}

body[data-ui-version="44"] .view-root :is(.catalog-filter-row, .store-catalog-filter-row) .catalog-sort-control select {
  min-width: 88px !important;
  width: 100%;
  height: 38px !important;
  white-space: nowrap;
}

.view-root[data-view="productCatalog"] .catalog-filter-row > details,
.view-root[data-view="catalog"] .store-catalog-filter-row > details {
  position: relative;
  overflow: visible;
  z-index: 12;
}

.view-root[data-view="productCatalog"] .catalog-filter-row > details[open],
.view-root[data-view="catalog"] .store-catalog-filter-row > details[open] {
  z-index: 80;
}

.view-root[data-view="productCatalog"] :is(.catalog-category-popover, .catalog-price-filter-popover),
.view-root[data-view="catalog"] :is(.catalog-category-popover, .catalog-price-filter-popover) {
  position: absolute !important;
  top: calc(100% + 6px) !important;
  left: 0 !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  width: min(320px, calc(100vw - 24px)) !important;
  max-width: calc(100vw - 24px) !important;
  max-height: min(420px, calc(100vh - 112px)) !important;
  box-sizing: border-box;
  z-index: 500 !important;
}

.view-root[data-view="productCatalog"] .catalog-price-filter > .catalog-price-filter-popover,
.view-root[data-view="catalog"] .store-price-filter > .catalog-price-filter-popover {
  left: auto !important;
  right: 0 !important;
}

/* 筛选面板悬浮在数据区上方，不再为弹层制造大块空白。 */
.view-root[data-view="productCatalog"] .catalog-filter-deck:has(.catalog-price-filter[open]),
.view-root[data-view="catalog"] .store-catalog-filter-deck:has(.store-price-filter[open]) {
  min-height: 0 !important;
  height: auto !important;
  padding-bottom: 10px !important;
  overflow: visible !important;
}

.view-root[data-view="productCatalog"] .catalog-price-filter[open] > .catalog-price-filter-popover,
.view-root[data-view="catalog"] .store-price-filter[open] > .catalog-price-filter-popover {
  z-index: 20 !important;
}

.view-root[data-view="productCatalog"] .catalog-category-popover,
.view-root[data-view="catalog"] .store-catalog-filter-row .catalog-category-popover {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.view-root[data-view="productCatalog"] .catalog-category-options,
.view-root[data-view="catalog"] .store-catalog-filter-row .catalog-category-options {
  min-height: 0 !important;
  max-height: min(270px, calc(100vh - 228px)) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

.view-root[data-view="productCatalog"] .catalog-category-actions,
.view-root[data-view="catalog"] .store-catalog-filter-row .catalog-category-actions {
  position: relative;
  z-index: 1;
  margin-bottom: 0;
  background: inherit;
}

@media (max-width: 680px) {
  .view-root[data-view="productCatalog"] :is(.catalog-category-popover, .catalog-price-filter-popover),
  .view-root[data-view="catalog"] :is(.catalog-category-popover, .catalog-price-filter-popover) {
    position: absolute !important;
    width: min(320px, calc(100vw - 24px)) !important;
    max-height: min(380px, calc(100vh - 92px)) !important;
  }
}
