/*!
 * 导航栏常驻搜索框样式
 * 与 Butterfly 主题的 CSS 变量保持一致（自动适配暗色模式）
 */

#nav-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-right: 10px;
  vertical-align: middle;
}

#nav-search-input {
  box-sizing: border-box;
  padding: 0 12px 0 30px;
  width: 188px;
  height: 32px;
  border: 1px solid rgba(144, 147, 153, 0.35);
  border-radius: 16px;
  background: var(--search-bg, #f6f8fa);
  color: var(--search-input-color, #4c4948);
  font-family: inherit;
  font-size: 13px;
  line-height: 30px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: width 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

#nav-search-input::placeholder {
  color: var(--search-input-color, #4c4948);
  opacity: 0.55;
}

#nav-search-input:focus {
  width: 226px;
  border-color: #49b1f5;
  box-shadow: 0 0 0 3px rgba(73, 177, 245, 0.15);
}

.nav-search-icon {
  position: absolute;
  top: 50%;
  left: 11px;
  color: var(--search-input-color, #4c4948);
  font-size: 12px;
  opacity: 0.55;
  pointer-events: none;
  transform: translateY(-50%);
}

#nav-search-results {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1000;
  display: none;
  overflow-y: auto;
  margin: 0;
  padding: 6px 0;
  width: 380px;
  max-height: 70vh;
  border-radius: 10px;
  background: var(--card-bg, #fff);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  text-shadow: none;
}

#nav-search-results.show {
  display: block;
}

#nav-search-results::-webkit-scrollbar {
  width: 6px;
}

#nav-search-results::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: rgba(144, 147, 153, 0.4);
}

#nav .nav-search-item {
  display: block;
  padding: 8px 14px;
  border-left: 3px solid transparent;
  color: var(--font-color, #4c4948) !important;
  text-decoration: none;
  text-shadow: none !important;
  transition: background 0.2s ease, border-color 0.2s ease;
}

#nav .nav-search-item.active,
#nav .nav-search-item:hover {
  border-left-color: #49b1f5;
  background: var(--sidebar-bg, #f6f8fa);
}

#nav .nav-search-item .nav-search-title {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#nav .nav-search-item .nav-search-snippet {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.72;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  word-break: break-word;
}

.nav-search-keyword {
  background: transparent;
  color: #f47466;
  font-weight: 600;
}

.nav-search-empty {
  padding: 12px 14px;
  color: var(--font-color, #4c4948);
  font-size: 13px;
  opacity: 0.7;
}

.nav-search-meta {
  padding: 6px 14px 4px;
  border-top: 1px solid rgba(144, 147, 153, 0.18);
  margin-top: 4px;
  color: var(--font-color, #4c4948);
  font-size: 12px;
  opacity: 0.6;
}

html[data-theme='dark'] #nav-search-input {
  border-color: rgba(255, 255, 255, 0.16);
}

html[data-theme='dark'] #nav .nav-search-item.active,
html[data-theme='dark'] #nav .nav-search-item:hover {
  background: var(--text-bg-hover, #383838);
}

@media (max-width: 768px) {
  #nav-search {
    display: none;
  }
}

/* 仅在搜索框成功初始化后隐藏主题原有的搜索图标，避免 JS 失效时丢失入口 */
@media (min-width: 769px) {
  .nav-search-ready #nav #search-button {
    display: none;
  }
}
