/* Global search palette — a spotlight / command-palette style pop-out window
   opened from the rail magnifier (and ⌘K / Ctrl-K). Searches across studies,
   investigations, catalog, registry, runs and resources. Works in both live and
   published (snapshot) mode since every source is read client-side via
   DataSource. See search-palette.js. */

#viv-gsearch-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  background: rgba(15, 23, 42, 0.44);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  padding: 10vh 16px 16px;
}
#viv-gsearch-overlay.viv-gsearch-open { display: flex; }

.viv-gsearch-dialog {
  width: 100%;
  max-width: 640px;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.32), 0 2px 8px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  animation: viv-gsearch-pop 120ms ease-out;
}
@keyframes viv-gsearch-pop {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* --- input row --- */
.viv-gsearch-inputrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #eef2f7;
}
.viv-gsearch-ico {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  color: #64748b;
}
#viv-gsearch-input {
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1.05rem;
  color: inherit;
  font-family: inherit;
}
#viv-gsearch-input::placeholder { color: #94a3b8; }
.viv-gsearch-esc {
  flex: 0 0 auto;
  font-size: 0.68rem;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px 6px;
  background: #f8fafc;
}

/* --- results --- */
.viv-gsearch-results {
  overflow-y: auto;
  padding: 6px 6px 8px;
  -webkit-overflow-scrolling: touch;
}
.viv-gsearch-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 12px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}
.viv-gsearch-group-count { font-weight: 600; }

.viv-gsearch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  scroll-margin: 8px;
}
.viv-gsearch-row:hover { background: #f1f5f9; }
.viv-gsearch-row.viv-gsearch-sel { background: #e0e7ff; }
.viv-gsearch-row.viv-gsearch-sel .viv-gsearch-tag { background: #c7d2fe; }

.viv-gsearch-tag {
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #475569;
  background: #f1f5f9;
  border-radius: 5px;
  padding: 3px 6px;
  min-width: 68px;
  text-align: center;
}
.viv-gsearch-body { flex: 1 1 auto; min-width: 0; }
.viv-gsearch-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.viv-gsearch-sub {
  font-size: 0.78rem;
  color: #64748b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.viv-gsearch-empty,
.viv-gsearch-hint {
  padding: 22px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.88rem;
}
.viv-gsearch-loading {
  padding: 4px 14px 10px;
  color: #94a3b8;
  font-size: 0.74rem;
  font-style: italic;
}

/* --- footer --- */
.viv-gsearch-foot {
  display: flex;
  gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid #eef2f7;
  font-size: 0.72rem;
  color: #94a3b8;
}
.viv-gsearch-foot kbd {
  font-family: inherit;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0 5px;
  font-size: 0.7rem;
  color: #475569;
}

/* phone: full-bleed sheet near the top */
@media (max-width: 640px) {
  #viv-gsearch-overlay { padding: 6vh 10px 10px; }
  .viv-gsearch-dialog { max-height: 82vh; }
  #viv-gsearch-input { font-size: 1rem; }
  .viv-gsearch-tag { min-width: 58px; }
  .viv-gsearch-foot { display: none; }
}

/* dark mode — follow the system scheme, matching the app's neutral palette */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .viv-gsearch-dialog {
    background: #0f172a; color: #e2e8f0; border-color: #1e293b;
  }
  :root:not([data-theme="light"]) .viv-gsearch-inputrow,
  :root:not([data-theme="light"]) .viv-gsearch-foot { border-color: #1e293b; }
  :root:not([data-theme="light"]) .viv-gsearch-title { color: #e2e8f0; }
  :root:not([data-theme="light"]) .viv-gsearch-row:hover { background: #1e293b; }
  :root:not([data-theme="light"]) .viv-gsearch-row.viv-gsearch-sel { background: #312e81; }
  :root:not([data-theme="light"]) .viv-gsearch-tag { background: #1e293b; color: #cbd5e1; }
  :root:not([data-theme="light"]) .viv-gsearch-esc,
  :root:not([data-theme="light"]) .viv-gsearch-foot kbd { background: #1e293b; border-color: #334155; color: #cbd5e1; }
}
:root[data-theme="dark"] .viv-gsearch-dialog {
  background: #0f172a; color: #e2e8f0; border-color: #1e293b;
}
:root[data-theme="dark"] .viv-gsearch-inputrow,
:root[data-theme="dark"] .viv-gsearch-foot { border-color: #1e293b; }
:root[data-theme="dark"] .viv-gsearch-title { color: #e2e8f0; }
:root[data-theme="dark"] .viv-gsearch-row:hover { background: #1e293b; }
:root[data-theme="dark"] .viv-gsearch-row.viv-gsearch-sel { background: #312e81; }
:root[data-theme="dark"] .viv-gsearch-tag { background: #1e293b; color: #cbd5e1; }
:root[data-theme="dark"] .viv-gsearch-esc,
:root[data-theme="dark"] .viv-gsearch-foot kbd { background: #1e293b; border-color: #334155; color: #cbd5e1; }
