/* Custom Search Styles for Stoplight Elements */

:root {
  --top-banner-height: 0px;
  --top-banner-bg: #EF6F00;
  --top-banner-color: #111827;
}

:root.deprecation-banner {
  --top-banner-height: 40px;
}

body {
  margin: 0;
  padding: 0;
  padding-top: var(--top-banner-height);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.top-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-banner-height);
  background: var(--top-banner-bg);
  color: var(--top-banner-color);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  font-size: 12px;
  z-index: 4000;
}

.top-banner__content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

:root.deprecation-banner .top-banner {
  display: flex;
}

.top-banner__text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-banner__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.top-banner__dismiss {
  border: none;
  background: transparent;
  color: #111827;
  border-radius: 0;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}

.top-banner__dismiss:hover,
.top-banner__dismiss:focus {
  text-decoration: underline;
}

.top-banner__migrate {
  color: #000000;
  border: 1px solid #ffffff;
  background: #ffffff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.top-banner__migrate:hover,
.top-banner__migrate:focus {
  color: #ffffff;
  background: #FF9100;
  border-color: #FF9100;
}

.top-banner__text::before {
  content: "⚠️";
}

@media (max-width: 768px) {
  .top-banner {
    padding: 0 8px;
  }

  .top-banner__content {
    gap: 8px;
  }

  .top-banner__dismiss {
    padding: 4px 8px;
  }
}

elements-api {
  display: block;
  height: 100vh;
  width: 100%;
}

.search-container {
  position: fixed;
  top: calc(var(--top-banner-height) + 16px);
  right: 16px;
  width: 400px;
  z-index: 2000;
  background: transparent;
  padding: 0;
  transition: all 0.3s ease;
}

/* Mobile search toggle button */
.mobile-search-toggle {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 3001;
}

/* Mobile search toggle when injected into Stoplight mobile nav */
[data-test="mobile-top-nav"] .mobile-search-toggle,
.injected-mobile-search {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  display: flex !important;
  margin-left: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  width: 40px;
  height: 40px;
}

[data-test="mobile-top-nav"] .mobile-search-toggle:hover,
.injected-mobile-search:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-test="mobile-top-nav"] .mobile-search-toggle:active,
.injected-mobile-search:active {
  background: rgba(0, 0, 0, 0.1);
}

/* Mobile search expansion when triggered from injected button */
.search-container.mobile-expanded {
  position: fixed !important;
  top: calc(var(--top-banner-height) + 60px) !important;
  left: 16px !important;
  right: 16px !important;
  width: calc(100% - 32px) !important;
  z-index: 9999 !important;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px;
}

.search-container.mobile-expanded .search-wrapper {
  opacity: 1 !important;
  visibility: visible !important;
  transform: scale(1) !important;
  pointer-events: auto !important;
  position: relative !important;
  width: 100% !important;
}

.search-container.mobile-expanded .mobile-search-toggle {
  display: none !important;
}

.mobile-search-toggle:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.mobile-search-toggle:active {
  background: #e5e7eb;
}

.search-toggle-icon {
  color: #6b7280;
  width: 20px;
  height: 20px;
}

/* Desktop search wrapper */
.search-wrapper {
  position: relative;
  width: 100%;
  transition: all 0.3s ease;
}

/* Desktop behavior - ensure search is always visible */
@media (min-width: 769px) {
  .search-container {
    display: block !important;
    position: fixed !important;
    top: calc(var(--top-banner-height) + 16px) !important;
    right: 16px !important;
    width: 400px !important;
    height: auto !important;
    pointer-events: auto !important;
    z-index: 2000;
  }

  .search-wrapper {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1) !important;
    pointer-events: auto !important;
  }

  .mobile-search-toggle {
    display: none !important;
  }
}

/* Mobile responsive behavior */
@media (max-width: 768px) {
  .search-container {
    display: none; /* Hidden by default on mobile to prevent blocking */
    width: auto;
    height: auto;
    position: absolute;
    top: -9999px; /* Move completely out of the way */
    pointer-events: none; /* Prevent any interference */
  }

  .mobile-search-toggle {
    display: flex;
  }

  .search-wrapper {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
    position: relative;
    width: 100%;
    pointer-events: none;
  }
}.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f9fafb;
}

.search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
  background: #ffffff;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: #6b7280;
  background: #e5e7eb;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: monospace;
  font-weight: 500;
}

/* Search results dropdown */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 3000;
}

/* Custom scrollbar styling */
.search-results::-webkit-scrollbar {
  width: 8px;
}

.search-results::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 0 0 6px 0;
}

.search-results::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.search-results.visible {
  display: block;
}

.search-result-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background-color 0.15s;
}

.search-result-item:hover,
.search-result-item.selected {
  background-color: #f3f4f6;
}

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

/* Use Stoplight Elements classes for method badges, so we only need spacing */
.search-result-item .sl-rounded-lg {
  margin-right: 8px;
}

.search-result-path {
  font-family: monospace;
  font-size: 12px;
  color: #374151;
}

.search-result-summary {
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
}

.search-no-results {
  padding: 12px;
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .search-container {
    width: calc(100% - 120px);
    right: 16px;
    left: auto;
    top: calc(var(--top-banner-height) + 8px);
  }
}

/* Adjust for larger screens */
@media (min-width: 1200px) {
  .search-container {
    width: 450px;
  }
}
