@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root { }

/* Scope CSS custom properties to the plugin container to avoid leaking into the page */
.wsp-search-shell {
  --wsp-bg: #f7f7fb;
  --wsp-card: #ffffff;
  --wsp-border: #e6e6f0;
  --wsp-primary: #61CE70;
  --wsp-text: #2b2b38;
  --wsp-muted: #8d8da1;
  --wsp-shadow: 0 14px 40px rgba(19, 19, 40, 0.12);
}

.wsp-search-shell {
  position: relative;
  z-index: 9999;
}

/* Mobile-first: inline search */
.wsp-search-inline {
  background: var(--wsp-card);
  border: 1px solid var(--wsp-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(19, 19, 40, 0.06);
  width: 100%;
  margin: 8px 0;
  role: combobox;
}

.wsp-search-inline .wsp-icon {
  font-size: 16px;
  color: var(--wsp-muted);
  display: flex;
}

.wsp-search-inline .wsp-icon svg {
  width: 16px;
  height: 16px;
}

.wsp-search-inline .wsp-search-filter {
  background: transparent;
  border: none;
  color: var(--wsp-muted);
  font-weight: 600;
  padding: 8px 12px;
  margin-left: 8px;
  border-left: 1px solid var(--wsp-border);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wsp-search-filter:hover {
  color: var(--wsp-text);
}

.wsp-search-filter::after {
  content: "▼";
  font-size: 10px;
  transition: transform 0.2s ease;
}

.wsp-search-filter.open::after {
  transform: rotate(180deg);
}

.wsp-category-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--wsp-card);
  border: 1px solid var(--wsp-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(19, 19, 40, 0.1);
  z-index: 1001;
  width: 200px; /* fixed width */
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.wsp-category-dropdown.show {
  display: block;
}

.wsp-category-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--wsp-text);
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.2s ease;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.wsp-category-item:last-child {
  border-bottom: none;
}

.wsp-category-item:hover {
  background: #f8f8f8;
}

.wsp-category-item.selected {
  background: var(--wsp-primary);
  color: white;
}

/* clamp category name to avoid dropdown expanding */
.wsp-cat-name {
  display: inline-block;
  max-width: calc(100% - 48px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wsp-cat-count {
  color: var(--wsp-muted);
  font-size: 12px;
  flex: 0 0 auto;
}

/* show full name on hover */
.wsp-category-item .wsp-cat-name:hover {
  overflow: visible;
  white-space: normal;
}

/* truncated display for selected name in button - but keep full name in title */
.wsp-filter-text {
  display: inline-block;
  max-width: 48px; /* fits ~3ch plus dots visual */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.wsp-search-inline .wsp-search-field {
  border: none;
  outline: none;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  color: var(--wsp-text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  padding: 0;
} 

/* Default: show mobile inline, hide desktop sidebar */
.wsp-shell-desktop .wsp-search-inline,
.wsp-shell-desktop .wsp-results {
  display: none;
}

.wsp-shell-mobile .wsp-trigger,
.wsp-shell-mobile .wsp-overlay,
.wsp-shell-mobile .wsp-panel {
  display: none;
}

.wsp-trigger,
.wsp-overlay,
.wsp-panel {
  display: none;
}

.wsp-close {
  display: none;
}

/* Desktop: sidebar (1200px+) */
@media (min-width: 1200px) {
  .wsp-search-inline {
    display: none;
  }

  .wsp-shell-mobile {
    display: none;
  }

  .wsp-trigger {
    width: auto;
    min-width: 40px;
    height: 40px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--wsp-border);
    background: var(--wsp-card);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--wsp-shadow);
  }

  .wsp-trigger-icon {
    font-size: 18px;
    color: var(--wsp-text);
  }

  /* Desktop logo variant (square rounded icon) */
  .wsp-trigger.wsp-logo {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 10px;
    background: #f6f7f8;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: none;
  }

  .wsp-trigger.wsp-logo .wsp-trigger-icon {
    color: #000000; /* darker black for better contrast */
    font-size: 20px;
  }

  .wsp-trigger.wsp-logo:hover {
    background: #f0f1f2;
    color: #000000;
  }

  /* Keep the desktop shell compact and content-sized */
  .wsp-shell-desktop {
    display: inline-block;
    vertical-align: middle;
  }

  .wsp-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 20, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .wsp-panel {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(360px, 100%);
    background: #fff;
    border-left: 1px solid #ececec;
    border-radius: 26px 0 0 26px;
    box-shadow: -24px 0 50px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    padding: 0;
    flex-direction: column;
    z-index: 10000;
  }

  .wsp-panel.open {
    transform: translateX(0);
  }

  .wsp-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .wsp-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 8px 18px;
    border-bottom: 1px solid #e9e9e9;
  }

  .wsp-panel-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111111;
  }

  .wsp-close {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #111111;
    padding: 4px;
    transition: opacity 0.2s ease;
  }

  .wsp-close:hover {
    opacity: 0.6;
  }

  .wsp-close svg {
    width: 24px;
    height: 24px;
  }
}


.wsp-search-card {
  background: #fdfdfd;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 15, 40, 0.06);
  padding: 10px 14px;
  margin: 12px 16px;
}

.wsp-search-input {
  border: none; /* remove inner border */
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: transparent; /* keep panel/card border only */
  box-shadow: none;
}

/* Force no border for inputs inside the sidebar panel */
.wsp-panel .wsp-search-input .wsp-search-field {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
}

.wsp-panel .wsp-search-input { /* slightly tighten spacing in panel */
  padding: 6px 10px;
}

.wsp-icon {
  font-size: 18px;
  color: #9a9a9a;
}

.wsp-search-field {
  border: none;
  outline: none;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  color: #333333;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

.wsp-search-field::placeholder {
  color: #9a9a9a;
}

.wsp-results-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: #fff;
  border-left: 1px solid #f1f1f1;
}

.wsp-results {
  margin: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  border: none;
  max-height: none;
  overflow-y: visible;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 24px;
}

.wsp-results.show {
  display: flex;
}

.wsp-result-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  padding: 12px 24px; /* full-row padding so hover covers entire item */
  border-bottom: 1px solid #e5e5e5;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, transform 0.15s ease;
  align-items: center;
  position: relative;
  border-radius: 6px;
}

.wsp-result-item:hover {
  opacity: 1;
  background: rgba(97, 206, 112, 0.06); /* slightly stronger highlight */
  cursor: pointer;
  transform: translateY(-1px);
}

.wsp-result-item::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  background: linear-gradient(90deg, rgba(229,229,229,0), rgba(229,229,229,0.6), rgba(229,229,229,0));
  opacity: 0.6;
}

.wsp-result-item:hover,
.wsp-result-item[aria-selected="true"] {
  background: transparent;
}

.wsp-result-image {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: #ffffff;
  border: 1px solid #dcdcdc;
}

.wsp-result-title {
  margin: 0 0 6px 0;
  font-size: 14px;
  font-weight: 600;
  color: #111111;
  line-height: 1.4;
}

.wsp-result-meta {
  margin: 0;
  font-size: 13px;
  color: #2e7d32;
  font-weight: 600;
}

.wsp-result-meta del {
  color: #9e9e9e;
  margin-right: 6px;
}

.wsp-result-meta ins {
  color: #2e7d32;
  text-decoration: none;
}

.wsp-result-bars {
  display: grid;
  gap: 8px;
}

.wsp-result-bars span {
  height: 6px;
  border-radius: 6px;
  background: rgba(165, 110, 255, 0.3);
}

.wsp-result-bars span:nth-child(1) {
  width: 85%;
}

.wsp-result-bars span:nth-child(2) {
  width: 60%;
}

.wsp-result-bars span:nth-child(3) {
  width: 40%;
}

.wsp-empty {
  padding: 20px;
  text-align: center;
  color: var(--wsp-muted);
}

.wsp-skeleton {
  padding: 16px;
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 16px;
  border-bottom: 1px solid var(--wsp-border);
}

.wsp-skeleton:last-child {
  border-bottom: none;
}

.wsp-lines {
  display: grid;
  gap: 10px;
}

.wsp-line {
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f0f0f5, #e7e7f0, #f0f0f5);
  animation: wsp-pulse 1.2s infinite;
}

.wsp-line.short {
  width: 60%;
}

@keyframes wsp-pulse {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: 200px 0;
  }
}

/* Mobile/Tablet results display (below 1200px) */
@media (max-width: 1199px) {
  .wsp-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--wsp-card);
    border: 1px solid var(--wsp-border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 16px rgba(19, 19, 40, 0.08);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    margin: 0;
    padding: 0;
  }

  .wsp-results.show {
    display: flex;
  }

  .wsp-results-count {
    padding: 12px 16px 8px 16px;
    font-size: 12px;
    color: var(--wsp-muted);
    border-bottom: 1px solid var(--wsp-border);
    background: #fafafa;
    margin: 0;
  }

  .wsp-result-item {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #efefef;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease;
    align-items: start;
  }

  .wsp-result-item:hover {
    background: #f8f8f8;
  }

  .wsp-result-item:last-child {
    border-bottom: none;
  }

  .wsp-result-image {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    background: #ffffff;
    border: 1px solid #e6e6e6;
  }

  .wsp-result-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .wsp-result-title {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: #333333;
    line-height: 1.3;
  }

  .wsp-result-meta {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .wsp-result-meta del {
    color: #9e9e9e;
    font-size: 12px;
    font-weight: 400;
  }

  .wsp-result-meta ins {
    color: #2e7d32;
    text-decoration: none;
  }

  .wsp-view-all-mobile {
    padding: 12px 16px;
    margin: 0;
    border: none;
    border-top: 1px solid #efefef;
    background: transparent;
    color: #666666;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
  }

  .wsp-view-all-mobile:hover {
    background: #f5f5f5;
    color: #333333;
  }

  .wsp-view-all-mobile::after {
    content: " >";
    margin-left: 4px;
  }
}

.wsp-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--wsp-muted);
  font-size: 14px;
}

.wsp-view-all {
  margin-top: auto;
  margin: 16px 24px 24px 24px;
  padding: 12px 36px;
  border-radius: 999px;
  border: 1px solid #d1d1d1;
  background: #fff;
  color: #1f1f1f;
  text-align: center;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 16px rgba(15, 15, 40, 0.08);
}

.wsp-view-all:hover {
  background: #fefefe;
  border-color: #bfbfbf;
}
