/* ============================================================
   xingmeng 主题 · 商品筛选悬浮窗升级样式
   覆盖 public/css/app.css 中的旧 filter-* 规则（在 app.css 之后加载）
   ============================================================ */

/* ---------- 触发器列 ---------- */

.filter-triggers-wrapper {
  position: sticky;
  top: 20px;
}

.filter-trigger {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 10px 6px 9px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: .2px;
  color: #555;
  text-align: center;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  cursor: pointer;
  transition: color .18s, border-color .18s, background-color .18s, box-shadow .18s;
}

.filter-trigger:hover {
  color: #e91e63;
  border-color: rgba(233, 30, 99, .35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
}

.filter-trigger:focus-visible {
  outline-offset: 2px;
  outline: 2px solid rgba(233, 30, 99, .4);
}

.filter-trigger.is-active {
  color: #e91e63;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(233, 30, 99, .08), rgba(233, 30, 99, .03));
  border-color: rgba(233, 30, 99, .45);
  box-shadow: 0 2px 10px rgba(233, 30, 99, .12);
}

.filter-trigger.is-active::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -1px;
  width: 3px;
  height: 22px;
  background: #e91e63;
  border-radius: 0 3px 3px 0;
  transform: translateY(-50%);
}

/* 旧的红点由“数量徽标”取代 */
.filter-trigger.has-filter::after {
  display: none;
}

.filter-trigger__label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-trigger__badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: #e91e63;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(233, 30, 99, .45);
}

.filter-trigger__price {
  display: block;
  max-width: 96%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 600;
  color: #e91e63;
}

/* 显式 display 会覆盖 hidden 属性的默认 display:none，必须强制隐藏 */
.filter-trigger__badge[hidden],
.filter-trigger__price[hidden],
.filter-panel__badge[hidden],
.filter-panel__clear[hidden] {
  display: none !important;
}

/* ---------- 悬浮面板（锚定气泡） ---------- */

.filter-panels-layer {
  pointer-events: none;
  z-index: 1050;
}

.filter-panel {
  z-index: 1060;
  position: fixed;
  display: flex;
  flex-direction: column;
  width: 320px;
  max-height: calc(100vh - 40px);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px) scale(.97);
  transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
}

.filter-panel.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity .16s ease, transform .16s ease, visibility;
}

/* 指向触发器的三角箭头 */
.filter-panel__arrow {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 2px;
  transform: translateY(-50%) rotate(45deg);
  pointer-events: none;
}

.filter-panel[data-side="right"] .filter-panel__arrow {
  left: -7px;
}

.filter-panel[data-side="left"] .filter-panel__arrow {
  right: -7px;
}

/* ---------- 面板头部 ---------- */

.filter-panel__header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #f1f1f1;
}

.filter-panel__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  font-size: 13px;
  color: #e91e63;
  background: rgba(233, 30, 99, .08);
  border-radius: 8px;
}

.filter-panel__title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: #222;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-panel__badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #e91e63;
  border-radius: 9px;
}

.filter-panel__clear {
  flex: none;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #e91e63;
  background: rgba(233, 30, 99, .08);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .15s;
}

.filter-panel__clear:hover {
  background: rgba(233, 30, 99, .16);
}

.filter-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 13px;
  color: #999;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: color .15s, background-color .15s;
}

.filter-panel__close:hover {
  color: #444;
  background: #f2f2f2;
}

/* ---------- 面板内容 ---------- */

.filter-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.filter-panel__body::-webkit-scrollbar {
  width: 4px;
}

.filter-panel__body::-webkit-scrollbar-thumb {
  background: #e0e0e0;
  border-radius: 2px;
}

/* ---------- 内容行（链接行 + 勾选行，整行可点） ---------- */

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s;
}

.filter-row:hover {
  background: #f7f7f9;
}

/* 链接行 */
.filter-row--link {
  padding: 0;
}

.filter-row--link .filter-row__main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #333;
  transition: color .15s, background-color .15s;
}

.filter-row--link .filter-row__main:hover {
  color: #e91e63;
  background: rgba(233, 30, 99, .05);
}

.filter-row--link .filter-row__main.active {
  color: #e91e63;
  font-weight: 600;
  background: rgba(233, 30, 99, .08);
}

.filter-row__icon {
  flex: none;
  font-size: 12px;
  color: #999;
}

.filter-row__text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 展开指示箭头：仅表示“有下级”，不可点击；整行都是链接 */
.filter-row__indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 1;
  color: #c2c2c9;
  pointer-events: none;
  transition: color .18s;
}

.filter-row__indicator i {
  transition: transform .2s ease;
}

.filter-row:hover .filter-row__indicator {
  color: #e91e63;
}

.filter-tree__node.is-open > .filter-row .filter-row__indicator {
  color: #e91e63;
}

.filter-tree__node.is-open > .filter-row .filter-row__indicator i {
  transform: rotate(90deg);
}

/* 分类层级缩进 */
.filter-row--sub .filter-row__main {
  padding-left: 24px;
  font-size: 13px;
  color: #555;
}

.filter-row--sub2 .filter-row__main {
  padding-left: 36px;
  font-size: 12.5px;
  color: #777;
}

/* 分类树子级折叠：悬停一级 / 二级时由脚本切换 is-open */
.filter-tree__children {
  display: none;
}

.filter-tree__node.is-open > .filter-tree__children {
  display: block;
  animation: xmTreeReveal .18s ease-out;
}

@keyframes xmTreeReveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 勾选行：隐藏原生复选框，自定义勾选视觉 */
.filter-row__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.filter-row__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  font-size: 12px;
  color: transparent;
  background: #fff;
  border: 1.5px solid #d5d5da;
  border-radius: 6px;
  transition: background-color .15s, border-color .15s, color .15s;
}

.filter-row__input:checked + .filter-row__check {
  color: #fff;
  background: #e91e63;
  border-color: #e91e63;
}

.filter-row:has(.filter-row__input:checked) {
  background: rgba(233, 30, 99, .06);
}

/* ---------- 已选标签 chips ---------- */

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 4px 8px;
  margin-bottom: 6px;
  border-bottom: 1px dashed #eee;
}

.filter-chips:empty {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 10px;
  font-size: 12px;
  color: #c2185b;
  background: rgba(233, 30, 99, .08);
  border-radius: 999px;
}

.filter-chip__label {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  color: #c2185b;
  background: rgba(233, 30, 99, .14);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color .15s;
}

.filter-chip__remove:hover {
  background: rgba(233, 30, 99, .28);
}

/* ---------- 价格面板 ---------- */

.filter-price {
  padding: 4px 6px 8px;
}

.filter-price__inputs {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.filter-price__field {
  flex: 1;
  min-width: 0;
}

.filter-price__label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: #888;
}

.filter-price__input {
  display: flex;
  align-items: center;
  background: #f7f7f9;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 0 10px;
  transition: border-color .15s, background-color .15s;
}

.filter-price__input:focus-within {
  background: #fff;
  border-color: rgba(233, 30, 99, .5);
}

.filter-price__symbol {
  flex: none;
  margin-right: 4px;
  font-size: 13px;
  color: #999;
}

.filter-price__input input {
  width: 100%;
  padding: 7px 0;
  font-size: 13px;
  color: #333;
  background: transparent;
  border: none;
  box-shadow: none;
  outline: none;
}

.filter-price__sep {
  flex: none;
  padding-bottom: 8px;
  font-size: 13px;
  color: #bbb;
}

/* 双滑杆（沿用旧类名，重定义外观） */
.dual-range-slider {
  height: 40px;
  margin: 18px 0 16px;
  position: relative;
}

.slider-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 6px;
  background: #f0f0f2;
  border-radius: 3px;
  transform: translateY(-50%);
}

.slider-range {
  position: absolute;
  top: 50%;
  height: 6px;
  background: linear-gradient(90deg, #f06292, #e91e63);
  border-radius: 3px;
  transform: translateY(-50%);
}

.slider-thumb {
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 3px solid #e91e63;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
  cursor: grab;
  transform: translate(-50%, -50%);
  transition: box-shadow .15s;
}

.slider-thumb:active {
  cursor: grabbing;
  box-shadow: 0 3px 12px rgba(233, 30, 99, .35);
}

.slider-thumb-min {
  left: 0%;
  z-index: 2;
}

.slider-thumb-max {
  left: 100%;
  z-index: 2;
}

/* ---------- 移动端（<768px）：触发器横排滚动，面板全屏滑入 ---------- */

@media (max-width: 767.98px) {
  .filter-triggers-wrapper {
    position: static;
    margin-bottom: 12px;
  }

  .filter-triggers {
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-triggers::-webkit-scrollbar {
    display: none;
  }

  .filter-trigger {
    flex: none;
    width: auto;
    min-width: 74px;
    padding: 8px 10px;
  }

  .filter-trigger.is-active::before {
    top: auto;
    bottom: -1px;
    left: 50%;
    width: 22px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    transform: translateX(-50%);
  }

  .filter-panel {
    width: 100dvw;
    max-height: 100dvh;
    height: 100dvh;
    left: 0;
    top: 0 !important;
    border: none;
    border-radius: 0;
    transform: translateX(-100%);
  }

  .filter-panel.is-open {
    transform: translateX(0);
  }

  .filter-panel__arrow {
    display: none;
  }
}
