/* =========================================================
   RPS Live Search — Premium UI (FIXED + Overlay + Scoped reset)
   ========================================================= */

/* Overlay (click-blocker) */
.rps-live-search-overlay{
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483646 !important;
  background: transparent !important; /* vaihda esim. rgba(0,0,0,.12) jos haluat himmennystä */
  pointer-events: auto !important;
}

/* Wrapper */
.rps-live-search {
  position: relative;
  width: 100%;
}

/* Panel (PORTAL/FIXED) */
.rps-live-search__panel {
  position: absolute !important;
  left: 0 !important;
  top: 100% !important;
  width: 100%;
  max-width: none;
  margin-top: 8px;             /* Pieni rako kentän ja listan väliin */

  z-index: 2147483647 !important;
  pointer-events: auto;

  border-radius: 16px;
  overflow: hidden;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 18px 55px rgba(0,0,0,0.22);

  /* Peittävä tausta -> ei "läpilyö" */
  background: #ffffff !important;
  color: rgba(17, 24, 39, 0.92);
}

/* Dark mode */
.dark-theme .rps-live-search__panel {
  background: #121826 !important;
  border-color: rgba(255,255,255,0.10);
  box-shadow: 0 18px 55px rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.92);
}

/* ---------------------------------------------------------
   Scoped reset: estää teeman globaalit a/button/list-tyylit
   (korjaa "pillerit", oudot paddingit, box-shadowt, jne.)
   --------------------------------------------------------- */
.rps-live-search__panel,
.rps-live-search__panel *{
  box-sizing: border-box;
}

.rps-live-search__panel a{
  color: inherit !important;
  text-decoration: none !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
}

.rps-live-search__panel img{
  max-width: 100%;
  height: auto;
  display: block;
}

/* Head / Foot */
.rps-live-search__head,
.rps-live-search__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}

.rps-live-search__head {
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.dark-theme .rps-live-search__head {
  border-bottom-color: rgba(255,255,255,0.10);
}

.rps-live-search__title {
  font-weight: 750;
  letter-spacing: 0.2px;
  font-size: 14px;
  opacity: 0.95;
}
.rps-live-search__hint {
  font-size: 12px;
  opacity: 0.65;
  white-space: nowrap;
}

/* List */
.rps-live-search__list {
  max-height: min(56vh, 420px);
  overflow: auto;
  padding: 6px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

/* Item */
.rps-live-search__item{
  display: flex !important;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;

  width: 100%;
  text-decoration: none;
  color: inherit;

  outline: none;
  transition: transform .08s ease, background .12s ease;
}

.rps-live-search__item:hover,
.rps-live-search__item.is-active {
  background: rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
.dark-theme .rps-live-search__item:hover,
.dark-theme .rps-live-search__item.is-active {
  background: rgba(255,255,255,0.08);
}

/* Thumbnail */
.rps-live-search__thumb{
  flex: 0 0 auto;
  width: 44px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.08);
}
.dark-theme .rps-live-search__thumb {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.10);
}

.rps-live-search__thumb--fallback {
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .02em;
  color: rgba(17, 24, 39, 0.6);
}
.dark-theme .rps-live-search__thumb--fallback {
  color: rgba(255,255,255,0.70);
}

/* Title — max 2 riviä */
.rps-live-search__item-title {
  font-weight: 650;
  font-size: 14px;
  line-height: 1.25;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  flex: 1 1 auto;
  min-width: 0;
}

/* Pill */
.rps-live-search__pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);

  background: rgba(255,255,255,0.70);
  opacity: 0.92;
  white-space: nowrap;
}
.dark-theme .rps-live-search__pill {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.14);
}

/* Foot */
.rps-live-search__foot {
  border-top: 1px solid rgba(0,0,0,0.08);
  font-size: 12px;
  opacity: 0.7;
}
.dark-theme .rps-live-search__foot {
  border-top-color: rgba(255,255,255,0.10);
}

/* Empty */
.rps-live-search__empty {
  padding: 14px;
  font-size: 14px;
  opacity: 0.85;
}

/* Skeleton */
.rps-live-search__skeleton {
  padding: 10px 14px 14px;
}
.rps-live-search__sk-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.rps-live-search__sk-thumb {
  width: 44px;
  height: 34px;
  border-radius: 10px;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.06);
}
.rps-live-search__sk-line {
  height: 12px;
  border-radius: 999px;
  width: 100%;
  background: rgba(0,0,0,0.08);
}
.rps-live-search__sk-pill {
  height: 24px;
  border-radius: 999px;
  width: 84px;
  background: rgba(0,0,0,0.06);
}
.dark-theme .rps-live-search__sk-thumb { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.08); }
.dark-theme .rps-live-search__sk-line  { background: rgba(255,255,255,0.10); }
.dark-theme .rps-live-search__sk-pill  { background: rgba(255,255,255,0.08); }

/* Open animation */
.rps-live-search__panel {
  animation: rpsFadeIn .18s ease-out;
  transform-origin: top;
}
@keyframes rpsFadeIn {
  from { opacity: 0; transform: translateY(-6px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mobile */
@media (max-width: 640px) {
  .rps-live-search__panel {
    border-radius: 18px;
    /* left/top/width tulee JS:ltä; älä pakota -8px fixed-mallissa */
  }
}