/* Search Modal — WebsiteGecko Smart Search */

/* Backdrop */
.wg-search-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(11, 17, 30, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.wg-search-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Modal container */
.wg-search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  justify-content: center;
  padding: 80px 24px 24px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.wg-search-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Modal card */
.wg-search-card {
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 160px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1);
}
.wg-search-modal.is-open .wg-search-card {
  transform: translateY(0) scale(1);
}

/* Search input row */
.wg-search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}
.wg-search-header svg {
  flex-shrink: 0;
  color: #718096;
}
.wg-search-header input {
  flex: 1;
  border: none;
  background: none;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 17px;
  color: #2d3748;
  outline: none;
  line-height: 1.5;
}
.wg-search-header input::placeholder {
  color: #a0aec0;
}
.wg-search-kbd {
  display: none;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #a0aec0;
  background: #f7f8fc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 2px 6px;
  line-height: 1.4;
  flex-shrink: 0;
}
.wg-search-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  color: #718096;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.wg-search-close-btn:hover {
  background: #f7f8fc;
  color: #2d3748;
}

/* Results area */
.wg-search-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 12px;
  overscroll-behavior: contain;
}
.wg-search-body::-webkit-scrollbar {
  width: 6px;
}
.wg-search-body::-webkit-scrollbar-track {
  background: transparent;
}
.wg-search-body::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 3px;
}

/* Loading state */
.wg-search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  color: #a0aec0;
  font-size: 14px;
}
.wg-search-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e2e8f0;
  border-top-color: #2ecc71;
  border-radius: 50%;
  animation: wg-spin .6s linear infinite;
}
@keyframes wg-spin {
  to { transform: rotate(360deg); }
}

/* Section headers */
.wg-search-section {
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Result items */
.wg-search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background .1s;
}
.wg-search-result:hover,
.wg-search-result.is-active {
  background: #e8f8f0;
}
.wg-search-result:hover .wg-sr-title,
.wg-search-result.is-active .wg-sr-title {
  color: #1a9e5c;
}

/* Result icon */
.wg-sr-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  background: #e8f8f0;
}

/* Result text */
.wg-sr-text {
  flex: 1;
  min-width: 0;
}
.wg-sr-title {
  font-size: 15px;
  font-weight: 500;
  color: #2d3748;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .1s;
}
.wg-sr-meta {
  font-size: 13px;
  color: #a0aec0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Arrow indicator */
.wg-sr-arrow {
  flex-shrink: 0;
  color: #e2e8f0;
  transition: color .1s;
}
.wg-search-result:hover .wg-sr-arrow,
.wg-search-result.is-active .wg-sr-arrow {
  color: #1a9e5c;
}

/* Popular / default state */
.wg-search-popular {
  padding: 4px 0;
}

/* No results */
.wg-search-empty {
  text-align: center;
  padding: 32px 16px;
}
.wg-search-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 4px;
}
.wg-search-empty-sub {
  font-size: 14px;
  color: #a0aec0;
  margin-bottom: 16px;
}

/* GeckoBot answer section */
.wg-search-ai {
  margin: 4px 8px 8px;
  background: #f0fdf4;
  border: 1px solid #d1f2e0;
  border-radius: 12px;
  padding: 16px;
  display: none;
}
.wg-search-ai.is-visible {
  display: block;
}
.wg-search-ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.wg-search-ai-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}
.wg-search-ai-label {
  font-size: 12px;
  font-weight: 600;
  color: #1a9e5c;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.wg-search-ai-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #718096;
}
.wg-search-ai-loading .wg-search-loading-spinner {
  border-color: #d1f2e0;
  border-top-color: #2ecc71;
}
.wg-search-ai-text {
  font-size: 14px;
  line-height: 1.7;
  color: #2d3748;
}
.wg-search-ai-text a {
  color: #1a9e5c;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wg-search-ai-text a:hover {
  color: #2ecc71;
}
.wg-search-ai-text .wg-ai-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #2ecc71;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: wg-blink .6s step-end infinite;
}
@keyframes wg-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}
.wg-search-ai-rate {
  margin-top: 8px;
  font-size: 11px;
  color: #a0aec0;
  text-align: center;
}
.wg-search-ai-error {
  font-size: 13px;
  color: #718096;
  text-align: center;
  padding: 4px 0;
}

/* Footer hint */
.wg-search-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid #eee;
  font-size: 12px;
  color: #a0aec0;
}
.wg-search-footer kbd {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 11px;
  background: #f7f8fc;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 1px 5px;
  color: #718096;
}

/* Nav search button */
.wg-search-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  color: #6b7280;
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s;
}
.wg-search-btn:hover {
  border-color: #2ecc71;
  color: #1a9e5c;
}
.wg-search-btn svg {
  width: 16px;
  height: 16px;
}
.wg-search-btn-kbd {
  display: none;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #c0c8d4;
  background: #f2f4f8;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.4;
}

/* Mobile: full-screen overlay */
@media (max-width: 768px) {
  .wg-search-modal {
    padding: 0;
    align-items: stretch;
  }
  .wg-search-card {
    max-width: none;
    max-height: none;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .wg-search-modal.is-open .wg-search-card {
    transform: none;
  }
  .wg-search-modal-backdrop {
    display: none;
  }
  .wg-search-footer {
    display: none;
  }
  .wg-search-kbd {
    display: none !important;
  }
  .wg-search-header input {
    font-size: 16px; /* prevent iOS zoom */
  }
  .wg-search-btn-kbd { display: none !important; }
}

/* Desktop: show kbd hint */
@media (min-width: 769px) {
  .wg-search-kbd {
    display: inline-block;
  }
  .wg-search-btn-kbd {
    display: inline-block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wg-search-card,
  .wg-search-modal,
  .wg-search-modal-backdrop {
    transition: none;
  }
}
