/* StreamCore 2.5.9 - Global Inline Search + Engine Auth Guard FIX7
   Scope: authenticated header/search only. No dashboard/backend/route logic changes.
*/

/* Engine Manager may exist in body, but never outside an authenticated StreamCore shell. */
body:not(:has(.xui-shell)) #sc-unified-engine-btn,
body:not(:has(.xui-shell)) #sc-unified-engine-modal,
body:has(.login-shell) #sc-unified-engine-btn,
body:has(.login-shell) #sc-unified-engine-modal { display:none !important; }

/* Bring Search next to the alert and replace the old button+modal with one inline field. */
.xui-shell .header-actions.top-actions { gap:4px !important; column-gap:4px !important; }
.xui-shell .header-actions .top-search { margin:0 !important; }
.xui-shell .header-actions .alert-center { margin:0 !important; }
.xui-shell .top-search.search-area.sc-global-search-host {
  position:relative !important;
  width:clamp(176px,16vw,238px) !important;
  min-width:176px !important;
  max-width:238px !important;
  height:34px !important;
  flex:0 1 238px !important;
  overflow:visible !important;
  z-index:1250 !important;
}
.xui-shell .sc-global-search-host > .top-search-button,
.xui-shell .sc-global-search-host > .top-search-panel { display:none !important; visibility:hidden !important; pointer-events:none !important; }
.xui-shell .sc-global-search-control {
  width:100% !important; height:34px !important; min-height:34px !important;
  display:flex !important; align-items:center !important; gap:8px !important;
  padding:0 9px 0 11px !important; border-radius:7px !important;
  background:rgba(5,17,44,.48) !important; border:1px solid rgba(148,163,184,.20) !important;
  box-shadow:none !important; transition:border-color .16s ease,background .16s ease,box-shadow .16s ease !important;
}
.xui-shell .sc-global-search-host:focus-within .sc-global-search-control {
  border-color:color-mix(in srgb,var(--theme-accent,#4aa3ff) 62%,rgba(148,163,184,.22)) !important;
  box-shadow:0 0 0 2px color-mix(in srgb,var(--theme-accent,#4aa3ff) 15%,transparent) !important;
}
.xui-shell .sc-global-search-icon { flex:0 0 auto; color:#8fa7c2 !important; font-size:12px !important; }
.xui-shell .sc-global-search-input {
  min-width:0 !important; width:100% !important; height:30px !important; padding:0 !important;
  border:0 !important; outline:0 !important; background:transparent !important; box-shadow:none !important;
  color:#e8f1fc !important; font-size:12px !important; font-weight:550 !important;
}
.xui-shell .sc-global-search-input::placeholder { color:#8fa2ba !important; opacity:1 !important; }
.xui-shell .sc-global-search-input::-webkit-search-cancel-button { opacity:.65; }
.xui-shell .sc-global-search-control kbd {
  flex:0 0 auto; min-width:19px; height:19px; display:grid; place-items:center; padding:0 5px;
  border:1px solid rgba(148,163,184,.18); border-radius:4px; background:rgba(255,255,255,.04);
  color:#7388a1; font:600 10px/1 system-ui,sans-serif; box-shadow:none;
}
.xui-shell .sc-global-search-results {
  position:absolute !important; top:calc(100% + 6px) !important; right:0 !important; left:auto !important;
  width:min(430px,calc(100vw - 24px)) !important; max-height:min(470px,calc(100vh - 92px)) !important;
  overflow:auto !important; padding:6px !important; border-radius:9px !important;
  border:1px solid rgba(148,163,184,.22) !important; background:#0c1728 !important;
  box-shadow:0 18px 48px rgba(0,0,0,.34) !important; z-index:2147480500 !important;
}
.xui-shell .sc-global-search-results[hidden] { display:none !important; }
.xui-shell .sc-search-result {
  width:100%; min-height:52px; display:grid; grid-template-columns:34px minmax(0,1fr) auto; align-items:center;
  gap:9px; padding:7px 9px; border:0; border-radius:7px; background:transparent; color:#dce8f6;
  text-align:left; cursor:pointer; box-shadow:none;
}
.xui-shell .sc-search-result:hover,.xui-shell .sc-search-result.active {
  background:color-mix(in srgb,var(--theme-accent,#4aa3ff) 12%,rgba(255,255,255,.025)) !important;
}
.xui-shell .sc-search-result-icon { width:30px; height:30px; display:grid; place-items:center; border-radius:7px; background:rgba(255,255,255,.055); color:var(--theme-accent,#4aa3ff); }
.xui-shell .sc-search-result-copy { min-width:0; display:grid; gap:2px; }
.xui-shell .sc-search-result-copy strong { color:#edf5ff !important; font-size:12px !important; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.xui-shell .sc-search-result-copy small { color:#8ea3bb !important; font-size:10px !important; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.xui-shell .sc-search-result em { color:#7890aa; font-size:9px; font-style:normal; font-weight:700; text-transform:uppercase; letter-spacing:.35px; white-space:nowrap; }
.xui-shell .sc-search-empty { min-height:104px; display:grid; place-items:center; align-content:center; gap:5px; color:#8ea3bb; text-align:center; }
.xui-shell .sc-search-empty i { color:var(--theme-accent,#4aa3ff); font-size:16px; }
.xui-shell .sc-search-empty strong { color:#dce8f6; font-size:12px; }
.xui-shell .sc-search-empty span { font-size:10px; }

/* Light theme parity. */
.xui-shell.theme-light .sc-global-search-control { background:#fff !important; border-color:#d2dfec !important; }
.xui-shell.theme-light .sc-global-search-icon { color:#60778e !important; }
.xui-shell.theme-light .sc-global-search-input { color:#233c55 !important; }
.xui-shell.theme-light .sc-global-search-input::placeholder { color:#7b8fa4 !important; }
.xui-shell.theme-light .sc-global-search-control kbd { background:#f3f7fb; border-color:#d5e1ed; color:#71859a; }
.xui-shell.theme-light .sc-global-search-results { background:#fff !important; border-color:#d4e0eb !important; box-shadow:0 18px 42px rgba(31,55,80,.18) !important; }
.xui-shell.theme-light .sc-search-result { color:#29445f !important; }
.xui-shell.theme-light .sc-search-result:hover,.xui-shell.theme-light .sc-search-result.active { background:color-mix(in srgb,var(--theme-accent,#4aa3ff) 9%,#f6faff) !important; }
.xui-shell.theme-light .sc-search-result-icon { background:#f0f6fc; }
.xui-shell.theme-light .sc-search-result-copy strong { color:#203b55 !important; }
.xui-shell.theme-light .sc-search-result-copy small,.xui-shell.theme-light .sc-search-result em { color:#687f96 !important; }
.xui-shell.theme-light .sc-search-empty strong { color:#29445f !important; }
.xui-shell.theme-light .sc-search-empty { color:#73899e !important; }

@media (min-width:2000px) {
  .xui-shell .top-search.search-area.sc-global-search-host { width:250px !important; max-width:250px !important; flex-basis:250px !important; }
}
@media (max-width:1180px) {
  .xui-shell .top-search.search-area.sc-global-search-host { width:190px !important; min-width:150px !important; flex-basis:190px !important; }
  .xui-shell .sc-global-search-control kbd { display:none; }
}
@media (max-width:980px) {
  .xui-shell .top-search.search-area.sc-global-search-host { width:clamp(138px,27vw,185px) !important; min-width:138px !important; flex-basis:auto !important; }
  .xui-shell .sc-global-search-results { position:fixed !important; top:64px !important; right:10px !important; width:min(430px,calc(100vw - 20px)) !important; max-height:calc(100vh - 76px) !important; }
}
@media (max-width:620px) {
  .xui-shell .header-actions.top-actions { gap:2px !important; }
  .xui-shell .top-search.search-area.sc-global-search-host { width:136px !important; min-width:122px !important; }
  .xui-shell .sc-global-search-control { padding:0 8px !important; gap:6px !important; }
  .xui-shell .sc-global-search-input { font-size:11px !important; }
  .xui-shell .sc-search-result { grid-template-columns:30px minmax(0,1fr); }
  .xui-shell .sc-search-result em { display:none; }
}
