/* ============ 侧栏菜单模糊搜索 2026-11-03 ============
   纯增量增强层：只作用于 #menu 与新增的搜索控件，不改 app.js / 既有样式表
   - 桌面/平板：搜索框固定在本侧栏 logo 与菜单之间
   - 手机 ≤767：侧栏为抽屉，顶部按钮 #menu-search-trigger 唤起抽屉并聚焦搜索框
   ======================================================= */

/* ---------- 搜索框 ---------- */
.ms-search {
  flex: 0 0 auto;
  padding: 10px 12px 4px;
}
.ms-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 9px;
  border-radius: 10px;
  background: var(--ux-bg, #f4f6f8);
  border: 1px solid var(--ux-input-border, rgba(145, 171, 161, .2));
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.ms-search-box:focus-within {
  background: var(--ux-paper, #fff);
  border-color: var(--ux-primary, #14a178);
  box-shadow: 0 0 0 3px var(--ux-soft-primary, rgba(20, 161, 120, .16));
}
.ms-search-ico {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--ux-text-3, #91aba1);
}
.ms-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ux-text, #1c2d27);
  font-size: 13px;
  line-height: 38px;
}
.ms-input::placeholder { color: var(--ux-text-3, #91aba1); opacity: 1; }
.ms-kbd {
  flex: none;
  font-size: 10px;
  line-height: 16px;
  color: var(--ux-text-3, #91aba1);
  background: var(--ux-paper, #fff);
  border: 1px solid var(--ux-input-border, rgba(145, 171, 161, .2));
  border-radius: 4px;
  padding: 0 4px;
  white-space: nowrap;
}
.ms-clear {
  display: none;
  flex: none;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ux-bg, #f4f6f8);
  color: var(--ux-text-2, #628175);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.ms-clear:hover {
  background: var(--ux-soft-primary, rgba(20, 161, 120, .16));
  color: var(--ux-primary-soft-text, #0b7552);
}
.ms-search.has-q .ms-clear { display: inline-flex; }
.ms-search.has-q .ms-kbd { display: none; }
.ms-meta {
  min-height: 15px;
  padding: 5px 2px 0;
  font-size: 11px;
  line-height: 15px;
  color: var(--ux-text-2, #628175);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-meta:empty { padding-top: 0; min-height: 0; }
.ms-empty { color: #b45309; white-space: normal; }

/* ---------- 搜索态菜单：自动展开 + 按得分重排 ---------- */
#menu.ms-searching {
  display: flex;
  flex-direction: column;
}
/* 搜索期间强制展开被折叠分组（只覆盖显示，不改 app.js 的折叠状态/内联值） */
#menu.ms-searching .menu-group-items {
  display: flex !important;
  flex-direction: column;
  order: var(--ms-go, 0);
}
#menu.ms-searching .menu-group { order: var(--ms-go, 0); }
#menu.ms-searching .menu-group.ms-hide,
#menu.ms-searching .menu-group-items.ms-hide { display: none !important; }
.menu-item.ms-hide { display: none !important; }
#menu.ms-searching .menu-item { flex-wrap: wrap; }
#menu.ms-searching .menu-item { order: var(--ms-io, 0); }

/* ---------- 命中高亮 / 选中 / 命中原因 ---------- */
.menu-item mark.ms-hit,
.ms-why mark.ms-hit {
  background: #FDE68A;
  color: #0B7552;
  border-radius: 3px;
  padding: 0 1px;
}
.ms-why {
  flex: 0 0 100%;
  width: 100%;
  margin-top: 2px;
  font-size: 11px;
  line-height: 15px;
  color: var(--ux-text-2, #628175);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-item.ms-sel {
  background: var(--ux-soft-primary, rgba(20, 161, 120, .16)) !important;
  box-shadow: inset 0 0 0 2px rgba(20, 161, 120, .45);
  color: var(--ux-primary-soft-text, #0b7552) !important;
}
.menu-item.ms-sel .ms-why { color: var(--ux-primary-soft-text, #0b7552); }
.menu-item.ms-sel.active {
  background: var(--ux-primary, #14a178) !important;
  color: #fff !important;
  box-shadow: inset 0 0 0 2px rgba(20, 161, 120, .45);
}

/* ---------- 手机抽屉入口按钮（≥768 不显示） ---------- */
.ms-top-trigger { display: none !important; }
@media (max-width: 767px) {
  .ms-top-trigger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
  }
  .ms-search { padding: 8px 12px 2px; }
  .ms-search-box { height: 42px; }
  .ms-input { font-size: 16px; line-height: 42px; } /* 防 iOS 聚焦放大 */
  .ms-kbd { display: none; }
}
