/* ============================================================
   BeirutFlow Shell — Global search command palette (Win11 "Search").
   A taskbar pill + Alt+S open a single reload-free overlay that does
   whole-system DATA search. Reuses the shell design tokens defined in
   taskbar.css (--shell-*, --s-taskbar-h) so it reads as one system in
   both light (azure-light) and dark (cosmos-dark) themes.
   Behaviour: wwwroot/Scripts/search.js.
   ============================================================ */

/* ── Taskbar search pill (next to Start) ─────────────────────── */
.s-search-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 36px;
  flex-shrink: 0;
  min-width: 0;
  max-width: 240px;
  padding-inline: 12px;
  border: 1px solid var(--shell-border);
  border-radius: 9px;
  background: var(--shell-chip);
  color: var(--bs-secondary-color, #64748b);
  cursor: pointer;
  text-align: start;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.s-search-pill:hover {
  background: var(--shell-hover-strong);
  color: var(--bs-body-color);
}
.s-search-pill:focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: 2px;
}
.s-search-pill-icon { font-size: 0.95rem; color: var(--shell-accent); flex-shrink: 0; }
.s-search-pill-text {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Tight taskbars (768–991px): shed the label, keep the icon so the tab
   strip keeps its room. Below 768px the whole taskbar is hidden anyway. */
@media (max-width: 991.98px) {
  .s-search-pill { max-width: none; padding-inline: 9px; }
  .s-search-pill-text { display: none; }
}

/* ── Overlay + scrim ─────────────────────────────────────────── */
.s-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;                 /* above taskbar (1100) and shell popups */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;       /* Win11 spawns the box upper-centre */
  background: rgba(8, 15, 30, 0.48);   /* 40–60% scrim → clear dismiss cue */
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: s-search-fade 0.15s ease;
}
.s-search-overlay[hidden] { display: none; }
@keyframes s-search-fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Panel ───────────────────────────────────────────────────── */
.s-search-panel {
  width: min(640px, 94vw);
  max-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--shell-bg);
  border: 1px solid var(--shell-border);
  border-radius: var(--shell-radius);
  box-shadow: 0 24px 60px rgba(8, 15, 30, 0.32);
  animation: s-search-pop 0.16s ease;
}
@keyframes s-search-pop {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .s-search-overlay, .s-search-panel { animation: none; }
}

/* ── Input row ───────────────────────────────────────────────── */
.s-search-inputrow {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 14px 16px;
  border-bottom: 1px solid var(--shell-border);
  flex-shrink: 0;
}
.s-search-input-icon { font-size: 1.05rem; color: var(--shell-accent); flex-shrink: 0; }
.s-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--bs-body-color);
  font-size: 1.05rem;
  line-height: 1.4;
  outline: none;
}
.s-search-input::placeholder { color: var(--bs-secondary-color, #94a3b8); }
.s-search-esc {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--shell-border);
  background: var(--shell-chip);
  color: var(--bs-secondary-color, #64748b);
  font-size: 0.68rem;
  line-height: 1.4;
}

/* ── Results list ────────────────────────────────────────────── */
.s-search-results {
  overflow-y: auto;
  padding: 6px;
  min-height: 0;
}
.s-search-group + .s-search-group { margin-top: 2px; }
.s-search-group-head {
  padding: 8px 10px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bs-secondary-color, #64748b);
}
.s-search-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--s-input-text, var(--bs-body-color));
  text-decoration: none;
  cursor: pointer;
}
.s-search-item:hover,
.s-search-item.is-active {
  background: var(--bs-primary-bg-subtle, var(--shell-hover-strong));
  color: var(--shell-accent);
}
.s-search-item-icon {
  width: 1.15rem;
  text-align: center;
  color: var(--shell-accent);
  flex-shrink: 0;
}
.s-search-item-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.s-search-item-label {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.s-search-item-sub {
  font-size: 0.75rem;
  color: var(--bs-secondary-color, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* tabular figures so amounts / numbers don't jitter row to row */
  font-variant-numeric: tabular-nums;
}
.s-search-item.is-active .s-search-item-sub { color: inherit; opacity: 0.8; }

/* Remove "×" on recent rows — subtle by default, clearer on row hover. */
.s-search-item-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  margin-inline-start: auto;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--bs-secondary-color, #94a3b8);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: background 0.13s ease, color 0.13s ease, opacity 0.13s ease;
}
.s-search-item:hover .s-search-item-remove,
.s-search-item.is-active .s-search-item-remove { opacity: 1; }
.s-search-item-remove:hover {
  background: color-mix(in srgb, #e81123 14%, transparent);
  color: #e81123;
  opacity: 1;
}

/* ── Empty / recent / no-result states ───────────────────────── */
.s-search-empty,
.s-search-noresult {
  padding: 28px 16px;
  text-align: center;
  color: var(--bs-secondary-color, #64748b);
  font-size: 0.88rem;
}
.s-search-empty[hidden] { display: none; }

/* ── "See all results" footer ────────────────────────────────── */
.s-search-seeall {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 11px 16px;
  border-top: 1px solid var(--shell-border);
  color: var(--shell-accent);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  background: var(--shell-chip);
}
.s-search-seeall:hover { background: var(--shell-hover-strong); }
.s-search-seeall[hidden] { display: none; }

/* Dark theme: deepen the scrim + lift the panel edge so it separates from
   the dark desktop (the shell vars already re-tint borders/hover). */
:root.theme-cosmos-dark .s-search-overlay { background: rgba(0, 0, 0, 0.58); }
:root.theme-cosmos-dark .s-search-panel { box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6); }

/* ============================================================
   Full-results page (~/Flow/Search) — the palette's "See all" deep
   dive. A polished, centred results view in the shell's language:
   search hero, grouped cards with icon chips + counts, avatar rows.
   Accent tints use color-mix (modern Chromium/Edge) with subtle
   fallbacks so it degrades gracefully.
   ============================================================ */
.s-searchpage {
  --sp-tint: color-mix(in srgb, var(--shell-accent, #3e6fb0) 12%, transparent);
  --sp-tint-strong: color-mix(in srgb, var(--shell-accent, #3e6fb0) 18%, transparent);
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* ── Hero search bar ─────────────────────────────────────────── */
/* The flex "pill" is an inner <div>, NOT the <form> — framework rules like
   `.content form { display:block }` (specificity 0,1,1) would otherwise beat a
   single-class `.s-searchpage-form` and collapse the row into a vertical stack. */
.s-searchpage-hero { margin-bottom: 1.6rem; }
.s-searchpage-form { display: block; margin: 0; }
.s-searchpage-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 8px 8px 8px 18px;
  background: var(--shell-bg, #fff);
  border: 1px solid var(--shell-border, rgba(15, 23, 42, 0.12));
  border-radius: 16px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.10);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.s-searchpage-bar:focus-within {
  border-color: var(--shell-accent, var(--bs-primary));
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14),
              0 0 0 4px color-mix(in srgb, var(--shell-accent, #3e6fb0) 20%, transparent);
}
.s-searchpage-bar-icon { color: var(--shell-accent, var(--bs-primary)); font-size: 1.15rem; flex-shrink: 0; }
/* !important resets defeat the framework's `.content input` box styling
   (border/background/shadow) which is more specific than a bare class. */
.s-searchpage-bar .s-searchpage-input {
  flex: 1;
  min-width: 0;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--bs-body-color);
  font-size: 1.1rem;
  padding: 8px 0;
  margin: 0;
  outline: none;
  height: auto;
}
.s-searchpage-bar .s-searchpage-input:focus { border: none !important; box-shadow: none !important; }
.s-searchpage-input::placeholder { color: var(--bs-secondary-color, #94a3b8); }
.s-searchpage-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 10px 20px;
  border: none;
  border-radius: 11px;
  background: var(--shell-accent, var(--bs-primary));
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.s-searchpage-btn:hover { filter: brightness(1.08); }
.s-searchpage-btn:active { transform: scale(0.97); }
@media (max-width: 520px) { .s-searchpage-btn span { display: none; } }
.s-searchpage-summary {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 1rem 0.3rem 0;
  font-size: 0.95rem;
  color: var(--bs-secondary-color, #64748b);
}
.s-searchpage-summary-count {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--shell-accent, var(--bs-primary));
}
.s-searchpage-summary-q { font-weight: 600; color: var(--bs-body-color); }

/* ── Grouped result cards ────────────────────────────────────── */
/* Tile the cards on wide screens so the full page width is used instead of a
   lone narrow column; collapses to a single column on smaller viewports. */
.s-searchpage-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
  gap: 1rem;
  align-items: start;
}
@media (max-width: 560px) { .s-searchpage-groups { grid-template-columns: 1fr; } }
.s-searchpage-group {
  background: var(--shell-bg, #fff);
  border: 1px solid var(--shell-border, rgba(15, 23, 42, 0.12));
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}
.s-searchpage-group-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--shell-border, rgba(15, 23, 42, 0.08));
}
.s-searchpage-group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--sp-tint, var(--bs-primary-bg-subtle));
  color: var(--shell-accent, var(--bs-primary));
  font-size: 0.9rem;
  flex-shrink: 0;
}
.s-searchpage-group-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bs-body-color);
}
.s-searchpage-group-count {
  margin-inline-start: auto;
  min-width: 1.5rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--shell-chip, rgba(15, 23, 42, 0.06));
  color: var(--bs-secondary-color, #64748b);
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ── Rows ────────────────────────────────────────────────────── */
.s-searchpage-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1rem;
  color: var(--s-input-text, var(--bs-body-color));
  text-decoration: none;
  transition: background 0.13s ease;
}
.s-searchpage-item + .s-searchpage-item { border-top: 1px solid var(--shell-border, rgba(15, 23, 42, 0.06)); }
.s-searchpage-item:hover { background: var(--sp-tint, var(--bs-primary-bg-subtle)); }
.s-searchpage-item-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sp-tint, var(--bs-primary-bg-subtle));
  color: var(--shell-accent, var(--bs-primary));
  font-size: 1rem;
  flex-shrink: 0;
}
.s-searchpage-item:hover .s-searchpage-item-avatar { background: var(--sp-tint-strong, var(--shell-hover-strong)); }
.s-searchpage-item-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.s-searchpage-item-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bs-body-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.s-searchpage-item-sub {
  font-size: 0.82rem;
  color: var(--bs-secondary-color, #94a3b8);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.s-searchpage-item-go {
  flex-shrink: 0;
  color: var(--shell-accent, var(--bs-primary));
  font-size: 0.8rem;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.s-searchpage-item:hover .s-searchpage-item-go { opacity: 1; transform: translateX(0); }
[dir="rtl"] .s-searchpage-item-go { transform: scaleX(-1) translateX(-4px); }
[dir="rtl"] .s-searchpage-item:hover .s-searchpage-item-go { transform: scaleX(-1) translateX(0); }

/* ── Empty / prompt states ───────────────────────────────────── */
.s-searchpage-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 3.5rem 1rem;
  text-align: center;
}
.s-searchpage-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 0.6rem;
  border-radius: 50%;
  background: var(--sp-tint, var(--bs-primary-bg-subtle));
  color: var(--shell-accent, var(--bs-primary));
  font-size: 1.5rem;
}
.s-searchpage-state-title { font-size: 1.05rem; font-weight: 600; color: var(--bs-body-color); }
.s-searchpage-state-sub { font-size: 0.92rem; color: var(--bs-secondary-color, #64748b); }

/* Dark theme: lift card edges so they read on the dark canvas. */
:root.theme-cosmos-dark .s-searchpage-form { box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4); }
:root.theme-cosmos-dark .s-searchpage-group { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); }
