/* ==========================================================================
   Admin search (Ctrl/Cmd+K, S) — Shopify search modal, matched to a 150%-scale
   Shopify admin screenshot (screenshot px / 1.5 = CSS px). Measured values:
     panel 648 x 250 (empty state), radius 12, 4px from the top, backdrop rgba(0,0,0,.71)
     field 32px high, #f7f7f7, 1.5px #1a1a1a ring, radius 8, 12px inset from the panel
     chips 20px high, #e3e3e3, 13px text, 8px gap, 12px below the field
     empty state: 45px icon (#8a8a8a) + 14px #303030 text
   The modal's colours are scoped to .cs-overlay (--cs-*) so the rest of the admin theme is untouched.
   There is deliberately NO blue focus ring / highlight on the field: the field is always drawn
   in its dark "focused" ring, and the global input:focus-visible outline is switched off for it.
   ========================================================================== */

/* Topbar field becomes a trigger for the modal (the real input lives in the modal). */
.topbar-search { cursor: pointer; position: relative; }
.topbar-search input { cursor: pointer; }

.cs-overlay {
  --cs-ink: #303030;      /* primary text */
  --cs-ink-2: #616161;    /* placeholder, secondary text */
  --cs-icon: #8a8a8a;     /* search / filter icons */
  --cs-chip: #e3e3e3;     /* chips, tag */
  --cs-chip-hover: #d4d4d4;
  --cs-field: #f7f7f7;    /* search field fill */
  --cs-line: #1a1a1a;     /* field ring, keyboard focus */
  --cs-hover: #f1f1f1;    /* row hover / active */
  --cs-r: 8px;

  position: fixed; inset: 0; z-index: 300; display: none;
  align-items: flex-start; justify-content: center;
  padding: 4px 16px 16px; background: rgba(0, 0, 0, .71);
}
.cs-overlay.is-open { display: flex; }
.cs-panel {
  width: 100%; max-width: 648px; max-height: min(680px, calc(100vh - 20px));
  display: flex; flex-direction: column; position: relative;
  background: #fff; border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, .25), 0 20px 36px rgba(0, 0, 0, .18);
  animation: csIn .14s ease;
}
@keyframes csIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cs-panel { animation: none; } }

/* ---- search field ---- */
.cs-head { padding: 12px 12px 0; position: relative; flex-shrink: 0; }
.cs-field {
  display: flex; align-items: center; gap: 5px; height: 32px; padding: 0 7px 0 10px; box-sizing: border-box;
  border: 0; border-radius: var(--cs-r); background: var(--cs-field);
  box-shadow: inset 0 0 0 1.5px var(--cs-line);
}
.cs-ico { display: inline-flex; flex-shrink: 0; color: var(--cs-icon); }
.cs-ico svg { display: block; width: 100%; height: 100%; }
.cs-field > .cs-ico { width: 16px; height: 16px; }
.cs-input,
.cs-input:focus,
.cs-input:focus-visible,
.cs-overlay .cs-input:focus-visible {
  outline: none; box-shadow: none; border: 0; border-radius: 0; background: transparent;   /* no focus highlight */
}
.cs-input {
  flex: 1; min-width: 0; height: 100%; padding: 0; margin: 0;
  font-family: inherit; font-size: 13px; line-height: 20px; color: var(--cs-ink);
  -webkit-appearance: none; appearance: none;
}
.cs-input::placeholder { color: var(--cs-ink-2); opacity: 1; }
.cs-input::-webkit-search-cancel-button,
.cs-input::-webkit-search-decoration { display: none; -webkit-appearance: none; }
.cs-filter-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border: 0; background: none; color: var(--cs-icon);
  border-radius: var(--cs-r); cursor: pointer;
}
.cs-filter-btn svg { display: block; width: 20px; height: 20px; }
.cs-filter-btn:hover { background: #ebebeb; }
.cs-filter-btn.is-on { color: var(--cs-ink); background: var(--cs-chip); }
.cs-overlay button:focus-visible { outline: 2px solid var(--cs-line); outline-offset: 1px; }

/* ---- chips ---- */
.cs-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 12px 0; flex-shrink: 0; }
.cs-chips[hidden] { display: none; }
.cs-chip {
  height: 20px; padding: 0 6px; border: 0; cursor: pointer; box-sizing: border-box;
  background: var(--cs-chip); color: var(--cs-ink);
  font-family: inherit; font-size: 13px; line-height: 20px; font-weight: 450; border-radius: var(--cs-r);
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.cs-chip:hover { background: var(--cs-chip-hover); }
.cs-chip[aria-pressed="true"] { background: var(--cs-ink); color: #fff; }

/* ---- results area ---- */
.cs-body { flex: 1; min-height: 0; overflow-y: auto; border-radius: 0 0 12px 12px; }
.cs-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 45px 16px 50px; text-align: center; color: var(--cs-ink);
}
.cs-empty .cs-ico { width: 45px; height: 45px; color: var(--cs-icon); }
.cs-empty p { margin: 0; font-size: 14px; line-height: 20px; color: var(--cs-ink); }
.cs-empty small { font-size: 13px; line-height: 18px; color: var(--cs-ink-2); }

.cs-group { padding: 12px 8px 4px; }
.cs-group-title {
  padding: 4px 8px 6px; font-size: 12px; line-height: 16px; font-weight: 550;
  color: var(--cs-ink-2); display: flex; justify-content: space-between; align-items: center;
}
.cs-group-title button {
  border: 0; background: none; color: var(--color-link); font-size: 12px; font-weight: 500; cursor: pointer; padding: 0;
}
.cs-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0;
  background: none; text-align: left; cursor: pointer; border-radius: var(--cs-r);
  color: var(--cs-ink); font-family: inherit;
}
.cs-item.is-active, .cs-item:hover { background: var(--cs-hover); }
.cs-thumb {
  width: 34px; height: 34px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border-radius: var(--cs-r); background: var(--cs-hover); color: var(--cs-icon);
  overflow: hidden; border: 1px solid #e3e3e3; box-sizing: border-box;
}
.cs-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cs-thumb .ai svg { width: 16px; height: 16px; }
.cs-text { flex: 1; min-width: 0; }
.cs-title { display: block; font-size: 13px; line-height: 20px; font-weight: 450; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-sub { display: block; font-size: 12px; line-height: 16px; color: var(--cs-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* matched text: weight only, no highlighter background */
.cs-title mark, .cs-sub mark { background: none; color: inherit; font-weight: 650; }
.cs-meta { flex-shrink: 0; font-size: 12px; color: var(--cs-ink-2); font-variant-numeric: tabular-nums; }
.cs-go { flex-shrink: 0; color: var(--cs-icon); opacity: 0; display: inline-flex; }
.cs-item.is-active .cs-go { opacity: 1; }

.cs-status { padding: 18px 16px; font-size: 13px; color: var(--cs-ink-2); text-align: center; }
.cs-skel { display: flex; align-items: center; gap: 12px; padding: 10px 20px; }
.cs-skel i { display: block; border-radius: var(--cs-r); background: var(--cs-hover); animation: cs-pulse 1.5s ease-in-out infinite; }
@keyframes cs-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .cs-skel i { animation: none; } }
.cs-skel i:first-child { width: 34px; height: 34px; }
.cs-skel i:last-child { height: 12px; flex: 1; max-width: 320px; }

/* ---- counts on smart filters ---- */
.cs-count { font-size: 12px; font-weight: 600; color: var(--cs-ink-2); font-variant-numeric: tabular-nums; }
.cs-chip[aria-pressed="true"] .cs-count { color: inherit; }

/* ---- all-filters menu ---- */
.cs-menu {
  position: absolute; right: 12px; top: 48px; z-index: 5; min-width: 230px; padding: 4px;
  background: #fff; border: 0; border-radius: 12px;
  box-shadow: 0 0 1px rgba(0, 0, 0, .2), 0 3px 6px -3px rgba(26, 26, 26, .2), 0 8px 16px -4px rgba(26, 26, 26, .22);
}
.cs-menu[hidden] { display: none; }
.cs-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 8px; border: 0; background: none;
  font-family: inherit; font-size: 13px; color: var(--cs-ink); text-align: left; cursor: pointer; border-radius: var(--cs-r);
}
.cs-menu-item span:first-of-type { flex: 1; }
.cs-menu-item .ai { color: var(--cs-icon); display: inline-flex; }
.cs-menu-item .ai svg { width: 16px; height: 16px; }
.cs-menu-item:hover { background: var(--cs-hover); }
.cs-menu-item.is-on { background: var(--cs-hover); font-weight: 550; }
.cs-menu-item.is-on .ai { color: var(--cs-ink); }
.cs-menu-item:focus-visible { outline: 2px solid var(--cs-line); outline-offset: -2px; }

/* ---- recent searches ---- */
.cs-recent { display: flex; align-items: center; border-radius: var(--cs-r); }
.cs-recent:hover { background: var(--cs-hover); }
.cs-recent-go {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px; border: 0; background: none;
  font-family: inherit; font-size: 13px; color: var(--cs-ink); text-align: left; cursor: pointer;
}
.cs-recent-go span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-recent-go .ai { color: var(--cs-icon); display: inline-flex; }
.cs-recent-go .ai svg { width: 16px; height: 16px; }
.cs-recent-go:focus-visible { outline: 2px solid var(--cs-line); outline-offset: -2px; }

.cs-more { padding: 6px 8px 12px; text-align: center; }
.cs-more button {
  border: 1px solid #d4d4d4; background: #fff; color: var(--cs-ink); font-family: inherit;
  font-size: 13px; font-weight: 550; height: 28px; padding: 0 12px; cursor: pointer; border-radius: var(--cs-r);
}
.cs-more button:hover { background: var(--cs-hover); }

/* Picked filter lives inside the field as a tag */
.cs-tag {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 2px; height: 20px; padding: 0 2px 0 6px;
  background: var(--cs-chip); border-radius: var(--cs-r);
  font-size: 13px; line-height: 20px; font-weight: 450; color: var(--cs-ink);
}
.cs-tag[hidden] { display: none; }
.cs-tag-x {
  width: 16px; height: 16px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none;
  color: var(--cs-ink-2); cursor: pointer; border-radius: 6px;
}
.cs-tag-x:hover { background: var(--cs-chip-hover); color: var(--cs-ink); }
.cs-tag-x .ai svg { width: 12px; height: 12px; }

/* Phones: header search icon (the desktop topbar field is hidden there). */
.icon-btn.cs-mobile-btn { display: none; }
@media (max-width: 860px) { .icon-btn.cs-mobile-btn { display: inline-flex; } }

/* Phones: full-screen sheet; 16px input text so iOS does not zoom on focus. */
@media (max-width: 680px) {
  .cs-overlay { padding: 0; }
  .cs-panel { max-width: none; max-height: 100vh; height: 100%; border-radius: 0; }
  .cs-body { border-radius: 0; }
  .cs-input { font-size: 16px; }
}
