/* ============================================================
   Enterprise Workspace Search — full-screen command center
   ------------------------------------------------------------
   Theme-aware: every colour comes from style.css custom
   properties that flip in dark mode. All classes are
   `wsearch-` prefixed. Sits above modals (z 1200 vs ~500).
   ============================================================ */

/* ---- overlay / scrim ---- */
.wsearch-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: wsearch-scrim-in 0.14s ease-out;
}

/* ---- panel ---- */
.wsearch-panel {
  display: flex;
  flex-direction: column;
  width: 92%;
  max-width: 680px;
  max-height: 72vh;
  overflow: hidden;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-pane);
  box-shadow: var(--shadow-pane);
  animation: wsearch-panel-in 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes wsearch-scrim-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes wsearch-panel-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .wsearch-overlay,
  .wsearch-panel { animation: none; }
}

/* ---- search bar ---- */
.wsearch-searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.wsearch-magnifier {
  display: flex;
  color: var(--text-faint);
  flex-shrink: 0;
}
.wsearch-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
}
.wsearch-input::placeholder { color: var(--text-placeholder); }
.wsearch-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-ctl);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
}
.wsearch-clear:hover { background: var(--bg-hover); color: var(--text-light); }
/* `display: flex` above outranks the UA [hidden] rule, so hiding the button
   from JS needs this to actually hide it. */
.wsearch-clear[hidden] { display: none; }

/* ---- filter chips ---- */
.wsearch-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.wsearch-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-light);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.wsearch-chip:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.wsearch-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.wsearch-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg-active);
  color: var(--text-light);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* same story as .wsearch-clear — the count pill is display: inline-flex, which
   beats the UA [hidden] rule, so an empty badge would sit there as a blob. */
.wsearch-chip-count[hidden] { display: none; }
.wsearch-chip.active .wsearch-chip-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ---- results scroll area ---- */
.wsearch-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 10px;
}

/* ---- groups ---- */
.wsearch-group { margin-top: 6px; }
.wsearch-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 5px;
}
.wsearch-group-name {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.wsearch-group-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ---- result item ---- */
.wsearch-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border-radius: var(--radius-ctl);
  cursor: pointer;
  border-left: 2px solid transparent;
  scroll-margin: 8px;
}
.wsearch-item.sel {
  background: var(--bg-hover);
  border-left-color: var(--accent);
}
.wsearch-item-ic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text-light);
  font-size: 16px;
  line-height: 1;
}
.wsearch-item-ic svg { width: 16px; height: 16px; }
.wsearch-item-body {
  flex: 1;
  min-width: 0;
}
.wsearch-item-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wsearch-item-sub {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wsearch-item-go {
  display: flex;
  flex-shrink: 0;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.wsearch-item.sel .wsearch-item-go { opacity: 1; }

/* matched-substring highlight — accent tint, not default yellow */
.wsearch-item mark {
  background: var(--accent-soft);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
html[data-theme="dark"] .wsearch-item mark,
:root[data-theme="dark"] .wsearch-item mark {
  background: rgba(143, 143, 243, 0.32);
}

/* ---- "+N more" line ---- */
.wsearch-more {
  padding: 6px 14px 8px;
  font-size: 12.5px;
  color: var(--text-faint);
}

/* ---- verified badge ---- */
.wsearch-verified {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  background: rgba(46, 160, 90, 0.14);
  color: #2e9d5b;
}
.wsearch-verified-ic { font-size: 10px; line-height: 1; }
@media (prefers-color-scheme: dark) {
  .wsearch-verified {
    background: rgba(46, 180, 100, 0.2);
    color: #4fd089;
  }
}
:root[data-theme="dark"] .wsearch-verified,
html[data-theme="dark"] .wsearch-verified {
  background: rgba(46, 180, 100, 0.2);
  color: #4fd089;
}
:root[data-theme="light"] .wsearch-verified,
html[data-theme="light"] .wsearch-verified {
  background: rgba(46, 160, 90, 0.14);
  color: #2e9d5b;
}

/* ---- empty / recents state ---- */
.wsearch-recents { margin-top: 4px; }
.wsearch-recents .wsearch-group-head { justify-content: space-between; }
.wsearch-recents-clear {
  border: none;
  background: transparent;
  color: var(--text-light);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.wsearch-recents-clear:hover { background: var(--bg-hover); color: var(--text); }
.wsearch-recent-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 12px 8px;
}
.wsearch-recent {
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-callout);
  color: var(--text-light);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wsearch-recent:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.wsearch-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.wsearch-empty {
  padding: 40px 24px 44px;
  text-align: center;
}
.wsearch-empty-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-light);
}
.wsearch-empty-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-faint);
}

/* ---- keyboard hint pills + footer ---- */
.wsearch-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-callout);
  color: var(--text-light);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
}
.wsearch-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.wsearch-foot-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.wsearch-foot-label {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: 2px;
}

/* ---- "+N more" is a filter shortcut, so it has to look pressable ---- */
.wsearch-more { cursor: pointer; }
.wsearch-more:hover { color: var(--text-light); text-decoration: underline; }

/* ---- deep-pass status ("Searching rows…") -------------------------
   The cheap pass paints on every keystroke; rows and semantic scores
   arrive on a debounce. This is the only thing that says so. */
.wsearch-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.wsearch-status[hidden] { display: none; }

/* ---- "related" tag on a semantic-only hit -------------------------
   A meaning match has no highlighted substring, so without this label a
   correct result reads like a bug. */
.wsearch-tag {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-active);
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.6;
}

/* ---- peek preview (the palette's page preview, carried over) ------
   The inner .pk-* rows are styled globally by css/features/polish.css,
   so only the container lives here. */
.wsearch-peek {
  position: fixed;
  z-index: 2;
  width: 328px;
  overflow-y: auto;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-popover);
  padding: 14px 16px;
  animation: wsearch-peek-in 0.12s var(--ease-out, ease);
  scrollbar-width: thin;
}
.wsearch-peek.hidden { display: none; }
@keyframes wsearch-peek-in {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .wsearch-peek { animation: none; }
}

/* ---- responsive ---- */
@media (max-width: 720px) {
  .wsearch-peek { display: none !important; }
}
@media (max-width: 560px) {
  .wsearch-overlay { padding: 6vh 8px 8px; }
  .wsearch-panel { width: 96%; max-height: 82vh; }
  .wsearch-input { font-size: 16px; }
  .wsearch-foot { gap: 10px; }
  .wsearch-foot-hint:nth-child(3),
  .wsearch-foot-hint:nth-child(4) { display: none; }
  .wsearch-status { width: 100%; margin-left: 0; }
}
