/* LocalModels — global search styles (Phase I).
 * Sits inside .lm-topbar-search (already styled in lm-profile.css for the
 * outer pill). Adds:
 *   - real <input> override (transparent, no own border)
 *   - clear (×) button
 *   - dropdown overlay below the input
 *   - mobile fullscreen mode (≤ 767px) when input has focus
 */

/* The wrapper itself: flex container; remove the legacy cursor:pointer
   since the inner input handles focus/cursor now. Keep the surface look. */
.lm-topbar-search {
  position: relative;
  cursor: text;
}
.lm-topbar-search.is-open { border-color: var(--lm-primary); }

/* Real input — transparent, takes the available space inside the pill. */
.lm-topbar-search-input {
  flex: 1 1 auto; min-width: 0;
  background: transparent;
  border: 0; outline: none;
  padding: 0;
  font-size: 13px;
  font-family: inherit;
  color: var(--lm-text);
  /* Hide the native search-field "X" — we render our own. */
  appearance: textfield;
  -webkit-appearance: textfield;
}
.lm-topbar-search-input::placeholder { color: var(--lm-muted); }
.lm-topbar-search-input::-webkit-search-decoration,
.lm-topbar-search-input::-webkit-search-cancel-button,
.lm-topbar-search-input::-webkit-search-results-button,
.lm-topbar-search-input::-webkit-search-results-decoration { display: none; }

/* Clear (×) button — appears once user typed. */
.lm-topbar-search-clear {
  flex: 0 0 auto;
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  background: transparent;
  border: 0; padding: 0;
  border-radius: 50%;
  color: var(--lm-muted);
  cursor: pointer;
  font-family: inherit;
}
.lm-topbar-search-clear:hover { background: var(--lm-bg); color: var(--lm-text); }

/* ── Dropdown overlay ──────────────────────────────────────────── */
.lm-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 200;
  background: var(--lm-bg);
  border: 1px solid var(--lm-border);
  border-radius: 12px;
  box-shadow: 0 16px 40px -8px rgba(15,23,42,0.18), 0 4px 14px -4px rgba(15,23,42,0.10);
  max-height: min(560px, 70vh);
  overflow-y: auto;
  padding: 6px 0;
  animation: lm-search-pop .12s ease-out;
}
@keyframes lm-search-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Section header (TALENTS / CLIENTS) */
.lm-search-section { padding: 6px 0; }
.lm-search-section + .lm-search-section { border-top: 1px solid var(--lm-border-2); }
.lm-search-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px 14px 4px;
}
.lm-search-section-label {
  font-family: var(--lm-font-mono);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--lm-text);
}
.lm-search-section-count {
  font-family: var(--lm-font-mono);
  font-size: 11px; color: var(--lm-muted);
}
.lm-search-section-rows { display: flex; flex-direction: column; }

/* Result row */
.lm-search-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--lm-text);
  cursor: pointer;
  transition: background .08s;
}
.lm-search-row:hover { background: var(--lm-surface); }
.lm-search-row-avatar {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--lm-surface-2);
}
.lm-search-row-body { flex: 1; min-width: 0; }
.lm-search-row-name {
  display: flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 600;
  color: var(--lm-text);
  line-height: 1.2;
}
.lm-search-row-name > span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.lm-search-row-verified { color: var(--lm-primary); flex: 0 0 auto; }
.lm-search-row-tier {
  flex: 0 0 auto;
  font-family: var(--lm-font-mono);
  font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  color: #fff;
}
.lm-search-row-tier-pro   { background: #2563eb; }
.lm-search-row-tier-vip   { background: #d4a93f; color: #1f2937; }
.lm-search-row-tier-elite { background: #0f172a; color: #d4a93f; }

.lm-search-row-meta {
  font-size: 12px; color: var(--lm-muted);
  margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
  overflow: hidden;
}
.lm-search-row-meta-text {
  flex: 0 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Phase I R2: matched-field chips show WHICH field(s) hit the query.
   Compact pills next to the meta line so user understands relevance
   ("matched: Service" tells them this isn't a name match). */
.lm-search-row-matched {
  display: inline-flex; gap: 4px;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  overflow: hidden;
}
.lm-search-row-match {
  display: inline-block;
  padding: 1px 6px;
  background: var(--lm-primary-soft);
  color: var(--lm-primary-text);
  border-radius: 999px;
  font-size: 10.5px; font-weight: 600;
  font-family: var(--lm-font-mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* "View all N talents →" footer link inside each section */
.lm-search-view-all {
  display: flex; align-items: center; gap: 4px;
  margin: 4px 14px 4px;
  padding: 6px 0;
  font-size: 12.5px; font-weight: 600;
  color: var(--lm-primary-text);
  text-decoration: none;
}
.lm-search-view-all:hover { color: var(--lm-primary); }

/* Empty / loading states */
.lm-search-state {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--lm-muted);
}
.lm-search-state-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lm-search-state-empty svg { color: var(--lm-muted); }
.lm-search-state-empty strong { color: var(--lm-text); }

.lm-search-state-loading { display: flex; flex-direction: column; gap: 10px; }
.lm-search-skel {
  height: 36px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--lm-surface) 25%, var(--lm-surface-2) 50%, var(--lm-surface) 75%);
  background-size: 200% 100%;
  animation: lm-search-shimmer 1.2s infinite;
}
@keyframes lm-search-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Dark theme ────────────────────────────────────────────────── */
html[data-lm-theme="dark"] .lm-topbar-search-input { color: var(--lm-text); }
html[data-lm-theme="dark"] .lm-topbar-search-clear:hover { background: var(--lm-surface-2); }
html[data-lm-theme="dark"] .lm-search-dropdown {
  background: var(--lm-surface);
  border-color: var(--lm-border);
  box-shadow: 0 16px 40px -8px rgba(0,0,0,0.5), 0 4px 14px -4px rgba(0,0,0,0.3);
}
html[data-lm-theme="dark"] .lm-search-row:hover { background: var(--lm-surface-2); }
html[data-lm-theme="dark"] .lm-search-skel {
  background: linear-gradient(90deg, var(--lm-surface-2) 25%, #2a3447 50%, var(--lm-surface-2) 75%);
  background-size: 200% 100%;
}

/* ════════════════════════════════════════════════════════════════════
   Dedicated /search results page (lm.search.tpl)
   ════════════════════════════════════════════════════════════════════ */
.lm-search-page {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 24px;
}
.lm-search-page-head { margin-bottom: 24px; }
.lm-search-page-title {
  font-size: 22px; font-weight: 700;
  color: var(--lm-text);
  margin: 0 0 16px;
}
.lm-search-page-title strong { color: var(--lm-primary); font-weight: 700; }
.lm-search-page-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--lm-border);
}
.lm-search-page-tab {
  padding: 10px 16px;
  font-size: 14px; font-weight: 600;
  color: var(--lm-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s;
}
.lm-search-page-tab:hover { color: var(--lm-text); }
.lm-search-page-tab.is-active {
  color: var(--lm-primary);
  border-bottom-color: var(--lm-primary);
}
.lm-search-page-tab-count {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  background: var(--lm-surface);
  color: var(--lm-muted);
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  font-family: var(--lm-font-mono);
}
.lm-search-page-tab.is-active .lm-search-page-tab-count {
  background: var(--lm-primary-soft);
  color: var(--lm-primary-text);
}

.lm-search-page-section { margin: 28px 0; }
.lm-search-page-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.lm-search-page-section-label {
  font-family: var(--lm-font-mono);
  font-size: 12px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--lm-text);
}
.lm-search-page-section-count { font-size: 12.5px; color: var(--lm-muted); }

.lm-search-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.lm-search-page-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: var(--lm-bg);
  border: 1px solid var(--lm-border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--lm-text);
  transition: border-color .12s, box-shadow .12s;
}
.lm-search-page-card:hover {
  border-color: var(--lm-primary-soft-2);
  box-shadow: var(--lm-shadow-sm);
}
.lm-search-page-card-avatar {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--lm-surface-2);
}
.lm-search-page-card-body { flex: 1; min-width: 0; }
.lm-search-page-card-name {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600;
  margin-bottom: 2px;
}
.lm-search-page-card-name > span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.lm-search-page-card-verified { color: var(--lm-primary); flex: 0 0 auto; }
.lm-search-page-card-meta {
  font-size: 12.5px; color: var(--lm-muted);
  display: flex; align-items: center; gap: 6px;
  overflow: hidden;
}
.lm-search-page-card-meta-text {
  flex: 0 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lm-search-page-card-matched {
  display: inline-flex; gap: 4px;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  overflow: hidden;
}
.lm-search-page-card-match {
  display: inline-block;
  padding: 1px 6px;
  background: var(--lm-primary-soft);
  color: var(--lm-primary-text);
  border-radius: 999px;
  font-size: 10.5px; font-weight: 600;
  font-family: var(--lm-font-mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.lm-search-page-view-more {
  display: inline-block;
  margin-top: 14px;
  font-size: 13px; font-weight: 600;
  color: var(--lm-primary-text);
  text-decoration: none;
}
.lm-search-page-view-more:hover { color: var(--lm-primary); }

.lm-search-page-empty {
  text-align: center;
  padding: 60px 16px;
  color: var(--lm-muted);
}
.lm-search-page-empty h2 {
  margin: 16px 0 6px;
  font-size: 18px;
  color: var(--lm-text);
}
.lm-search-page-empty p { font-size: 13.5px; }

.lm-search-page-pagination {
  display: flex; justify-content: center; align-items: center; gap: 16px;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--lm-border-2);
  font-size: 13px; color: var(--lm-muted);
}
.lm-search-page-pagination a {
  color: var(--lm-primary-text);
  text-decoration: none; font-weight: 600;
}
.lm-search-page-pagination a:hover { color: var(--lm-primary); }

/* Dark theme */
html[data-lm-theme="dark"] .lm-search-page-card { background: var(--lm-surface); }
html[data-lm-theme="dark"] .lm-search-page-card:hover { border-color: var(--lm-muted-2); }
html[data-lm-theme="dark"] .lm-search-page-tab-count { background: var(--lm-surface-2); }

/* ── Mobile (≤ 767px) — fullscreen overlay on focus ─────────────
   When the input is focused on mobile, the dropdown takes over the
   whole viewport so the keyboard + results have room to breathe.
   Implementation: when input has :focus-within, we expand the wrap
   to viewport-fixed, and the dropdown fills the remaining space. */
@media (max-width: 767px) {
  .lm-topbar-search.is-open {
    position: fixed;
    inset: 0;
    z-index: 9999;
    margin: 0;
    border-radius: 0;
    border: 0;
    border-bottom: 1px solid var(--lm-border);
    background: var(--lm-bg);
    padding: 14px 16px;
    max-width: none;
  }
  .lm-topbar-search.is-open .lm-search-dropdown {
    position: fixed;
    top: 56px; left: 0; right: 0; bottom: 0;
    max-height: none;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    animation: none;
  }
  /* On mobile while the overlay is open, hide the kbd shortcut hint —
     no keyboard shortcuts on touch. */
  .lm-topbar-search.is-open .lm-topbar-kbd { display: none; }
}

/* Kill the browser autofill "highlighted bar" (yellow/blue fill) on the topbar
   search — keep the field transparent and on-brand in both themes. The inset
   box-shadow trick paints over the autofill background; text-fill-color keeps
   the typed text the theme colour. */
.lm-topbar-search-input:-webkit-autofill,
.lm-topbar-search-input:-webkit-autofill:hover,
.lm-topbar-search-input:-webkit-autofill:focus,
.lm-topbar-search-input:-webkit-autofill:active {
  -webkit-box-shadow: inset 0 0 0 1000px transparent !important;
  box-shadow: inset 0 0 0 1000px transparent !important;
  -webkit-text-fill-color: var(--lm-text) !important;
  caret-color: var(--lm-text);
  transition: background-color 9999s ease-in-out 0s; /* defer autofill bg paint */
}
html[data-lm-theme="dark"] .lm-topbar-search-input:-webkit-autofill,
html[data-lm-theme="dark"] .lm-topbar-search-input:-webkit-autofill:hover,
html[data-lm-theme="dark"] .lm-topbar-search-input:-webkit-autofill:focus,
html[data-lm-theme="dark"] .lm-topbar-search-input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--lm-text) !important;
}
