/* search.css — 全局搜索弹窗（⌘K 命令面板形态）。
   入口按钮在右上角 header（#searchBtn），复用 main.css 的 .header-btn。 */

/* ── 弹窗：顶部对齐的命令面板 ── */
.search-backdrop {
  align-items: flex-start;
  padding-top: 12vh;
}
.search-modal {
  width: min(640px, 100%);
  max-height: min(560px, 72vh);
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22), 0 4px 16px rgba(0, 0, 0, 0.10);
  overflow: hidden;
  animation: searchModalIn 160ms var(--ease);
}
@keyframes searchModalIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* 头部输入区 */
.search-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.search-head-icon { color: var(--text-4); flex-shrink: 0; }
.search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.search-input::placeholder { color: var(--text-5); }
.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--text-4);
  flex-shrink: 0;
}
.search-clear:hover { background: var(--hover); color: var(--text-2); }
.search-spin {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: searchSpin 700ms linear infinite;
}
@keyframes searchSpin { to { transform: rotate(360deg); } }

/* 结果区 */
.search-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 10px;
  outline: none;
}
.search-body::-webkit-scrollbar { width: 5px; }
.search-body::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 3px; }

.search-group { margin-top: 6px; }
.search-group:first-child { margin-top: 2px; }

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  color: var(--text-2);
}
/* 选中态由 JS 维护（键盘 + 鼠标悬停统一走 .selected），不用 :hover —— 两套会打架 */
.search-row.selected { background: var(--hover-strong); }

.search-row-session { font-weight: 550; color: var(--text); }
.search-sess-icon {
  display: flex;
  align-items: center;
  color: var(--text-4);
  flex-shrink: 0;
}
.search-sess-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.search-badge {
  flex-shrink: 0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink);
  background: var(--ink-soft);
  padding: 2px 7px;
  border-radius: 99px;
}
.search-time {
  flex-shrink: 0;
  margin-left: auto;
  font-size: 11px;
  color: var(--text-5);
  font-variant-numeric: tabular-nums;
}

.search-row-msg { padding-left: 14px; }
.search-role {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  line-height: 17px;
  border-radius: 5px;
}
.search-role.is-user { color: var(--info); background: var(--info-soft); }
.search-role.is-ai { color: var(--green-accent); background: var(--ink-soft); }
.search-snippet {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-3);
}

/* 命中词高亮：浅黄底，深色模式降饱和提对比 */
.search-modal mark {
  background: rgba(240, 185, 11, 0.28);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
  font-weight: 600;
}
html[data-theme="dark"] .search-modal mark {
  background: rgba(227, 176, 87, 0.30);
}

/* 空态 / 引导态 */
.search-empty {
  padding: 44px 20px 48px;
  text-align: center;
}
.search-empty-title { font-size: 13.5px; color: var(--text-2); font-weight: 550; }
.search-empty-sub { margin-top: 6px; font-size: 12px; color: var(--text-4); }

/* 底部提示条 */
.search-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--text-4);
}
.search-foot-hints { display: flex; gap: 12px; }
.search-foot-hints kbd { margin-right: 2px; }
.search-foot-count {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 窄屏：贴顶展开，最大化可视结果 */
@media (max-width: 640px) {
  .search-backdrop { padding: 12px; padding-top: 8vh; }
  .search-modal { max-height: 78vh; }
  .search-foot-hints { display: none; }
}
