/* ============================================================
   SEARCH.CSS — Global Ctrl+K Command Palette
   ============================================================ */

/* ── Overlay backdrop ── */
#search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 110;
}
#search-overlay.active { display: block; }

/* ── Palette container ── */
#search-palette {
  display: none;
  position: fixed;
  top: 18vh;
  left: 50%;
  transform: translateX(-50%);
  width: 94%;
  max-width: 580px;
  max-height: 62vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
  z-index: 111;
  flex-direction: column;
  overflow: hidden;
}
#search-palette.active { display: flex; }

/* ── Search header / input ── */
#search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

#search-icon {
  font-size: 18px;
  color: var(--text-faint);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  padding: 0;
}
#search-input::placeholder {
  color: var(--text-faint);
}

#search-kbd {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: inherit;
  flex-shrink: 0;
}

/* ── Results container ── */
#search-results {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Category group ── */
.search-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 10px 16px 4px;
}

/* ── Result item ── */
.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.search-result:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.04));
}
.search-result.active {
  background: var(--bg-hover, rgba(255, 255, 255, 0.06));
  border-left-color: var(--accent);
}

.search-result-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.search-result-text {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-subtitle {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* ── Show more link ── */
.search-show-more {
  font-size: 11px;
  color: var(--accent);
  padding: 4px 16px 8px 48px;
  cursor: pointer;
  opacity: 0.8;
}
.search-show-more:hover { opacity: 1; }

/* ── Empty / loading states ── */
.search-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-faint);
  font-size: 13px;
}

.search-loading {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-faint);
  font-size: 13px;
}
.search-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: search-spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes search-spin {
  to { transform: rotate(360deg); }
}

/* ── Footer hints ── */
#search-footer {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
}

.search-hint {
  font-size: 11px;
  color: var(--text-faint);
}
.search-hint kbd {
  font-size: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: inherit;
  margin-right: 3px;
}

/* ── Sidebar trigger ── */
#search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px var(--space-md, 12px);
  margin: var(--space-sm, 8px) var(--space-sm, 8px);
  color: var(--text-faint);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
#search-trigger:hover {
  border-color: var(--accent);
  color: var(--text-muted);
}
#search-trigger kbd {
  font-size: 10px;
  margin-left: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
}

/* Collapsed sidebar: hide labels */
html.nav-collapsed #search-trigger .nav-label,
html.nav-collapsed #search-trigger kbd { display: none; }
html.nav-collapsed #search-trigger {
  justify-content: center;
  padding: 9px 0;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  #search-palette {
    top: 8vh;
    width: 96%;
    max-height: 75vh;
  }
}
