/* ── Search toggle button in nav ── */
.kb-search-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50px;
  cursor: pointer;
  width: 44px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: border-color .2s, color .2s;
  flex-shrink: 0;
}
.kb-search-toggle:hover { border-color: var(--accent); color: var(--accent); }
body.kb-light .kb-search-toggle { border-color: #cccccc; background: #f0f0f0; }

/* ── Overlay backdrop ── */
.kb-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 20px 40px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
  overflow-y: auto;
}
.kb-search-overlay.kb-search-open {
  opacity: 1;
  visibility: visible;
}

/* ── Inner container ── */
.kb-search-overlay__inner {
  width: 100%;
  max-width: 720px;
  position: relative;
}

/* ── Close button ── */
.kb-search-overlay__close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  z-index: 2;
}
.kb-search-overlay__close:hover { background: rgba(255,255,255,.2); }

/* ── Search form ── */
.kb-search-overlay__form-wrap {
  margin-bottom: 12px;
}
.kb-search-overlay__form {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.kb-search-overlay__icon {
  flex-shrink: 0;
  color: #999;
  width: 22px;
  height: 22px;
}
.kb-search-overlay__input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 20px;
  font-family: inherit;
  color: #111;
  background: transparent;
  min-width: 0;
}
.kb-search-overlay__input::placeholder { color: #bbb; }
.kb-search-overlay__esc {
  font-size: 11px;
  font-weight: 600;
  color: #bbb;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  padding: 3px 8px;
  white-space: nowrap;
  font-family: monospace;
}
.kb-search-overlay__hint {
  font-size: 12px;
  color: rgba(255,255,255,.45);
  text-align: center;
  margin-top: 8px;
}
.kb-search-overlay__hint kbd {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 11px;
}

/* ── Results container ── */
.kb-search-results {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  margin-top: 8px;
}

/* Loading state */
.kb-search-results--loading::after {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--accent, #f9572e);
  border-radius: 50%;
  animation: kb-spin .7s linear infinite;
  margin: 28px auto;
}
@keyframes kb-spin { to { transform: rotate(360deg); } }

/* Empty state */
.kb-search-results__empty {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
}
.kb-search-results__empty svg { margin-bottom: 12px; opacity: .4; }
.kb-search-results__empty p  { font-size: 15px; margin: 0; }

/* ── Individual result ── */
.kb-search-result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  color: inherit;
  transition: background .1s;
}
.kb-search-result:last-child { border-bottom: none; }
.kb-search-result:hover { background: #f8faff; }

.kb-search-result__thumb {
  width: 52px;
  height: 44px;
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kb-search-result__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kb-search-result__thumb-icon {
  width: 52px;
  height: 44px;
  border-radius: 7px;
  background: #f3f4f6;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.kb-search-result__body { flex: 1; min-width: 0; }
.kb-search-result__type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent, #f9572e);
  margin-bottom: 3px;
}
.kb-search-result__title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-search-result__title mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.kb-search-result__excerpt {
  font-size: 13px;
  color: #6b7280;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-search-result__excerpt mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.kb-search-result__meta {
  font-size: 11px;
  color: #d1d5db;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── View all row ── */
.kb-search-results__footer {
  padding: 12px 20px;
  background: #f9fafb;
  border-top: 1px solid #f3f4f6;
  display: flex;
  justify-content: center;
}
.kb-search-results__all {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent, #f9572e);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kb-search-results__all:hover { opacity: .75; }

/* ── Type icons map ── */
.kb-search-result__thumb-icon[data-type="post"]          { background: #fff7ed; }
.kb-search-result__thumb-icon[data-type="page"]          { background: #f0f9ff; }
.kb-search-result__thumb-icon[data-type="kb_product"]    { background: #f0fdf4; }
.kb-search-result__thumb-icon[data-type="kb_case_study"] { background: #fdf4ff; }
.kb-search-result__thumb-icon[data-type="kb_service"]    { background: #fffbeb; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .kb-search-overlay { padding: 60px 12px 24px; }
  .kb-search-overlay__input { font-size: 16px; }
  .kb-search-overlay__esc { display: none; }
  .kb-search-result__meta { display: none; }
}
