/* Search UI Styles */

/* Search button in the header */
.search-button {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary-color);
  border-radius: var(--header-button-border-radius);
  transition: all 0.2s ease;
  padding: var(--header-button-padding);
  position: relative;
  width: 32px;
  height: 32px;
  margin: 0 4px;
}

.search-button:hover {
  background-color: var(--hover-bg);
  color: var(--link-hover-color);
  transform: var(--hover-transform);
  box-shadow: var(--hover-shadow);
}

.search-button:active {
  transform: translateY(0);
  box-shadow: none;
}

.search-button svg {
  width: 20px;
  height: 20px;
}

/* Fix header buttons to use consistent styling */
.header-right button, 
.header-right a {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
}

/* All header buttons should have the same hover effects */
.header-right button:hover, 
.header-right a:hover {
  background-color: var(--hover-bg);
  color: var(--link-hover-color);
  transform: var(--hover-transform);
  box-shadow: var(--hover-shadow);
}

.header-right button:active,
.header-right a:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Make sure SVG icons are consistent */
.header-right button svg, 
.header-right a svg {
  width: 20px;
  height: 20px;
}

/* Fix header alignment while preserving gap */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Search overlay (background) */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  padding-top: 80px;
  backdrop-filter: blur(2px);
}

/* Main search container */
.search-container {
  width: 600px;
  max-width: calc(100% - 32px);
  background-color: var(--background-color);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  max-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
}

/* Search input field */
.search-input {
  width: 100%;
  padding: 16px;
  border: none;
  border-bottom: 1px solid var(--border-color);
  font-size: 18px;
  outline: none;
  background-color: var(--background-color);
  color: var(--text-color);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.search-input:focus {
  border-color: var(--link-color);
  box-shadow: 0 0 0 1px var(--link-color, #0077cc);
}

.search-input:placeholder-shown {
  box-shadow: inset 0 0 6px rgba(0, 119, 204, 0.1);
}

:root.dark-theme .search-input:placeholder-shown {
  box-shadow: inset 0 0 6px rgba(88, 166, 255, 0.1);
}

.search-input::placeholder {
  color: var(--text-light);
  opacity: 0.7;
}

/* Search results container */
.search-results {
  overflow-y: auto;
  max-height: 450px;
  padding: 0;
  border-top: 1px solid var(--border-color);
}

/* Empty search state */
.search-message {
  padding: 16px;
  text-align: center;
  color: var(--text-light);
}

/* Individual search result */
.search-result {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--primary-color);
}

.search-result:hover, 
.search-result.selected {
  background-color: var(--hover-bg);
  text-decoration: none;
}

.search-result.selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: var(--primary-color, #4a6da7);
}

/* Result title */
.result-title {
  font-weight: 500;
  margin-bottom: 4px;
}

/* Result footer with path and type */
.result-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

/* Result source path */
.result-path {
  font-size: 14px;
  color: var(--text-light);
}

/* Result preview content */
.result-preview {
  padding: 8px;
  background-color: var(--code-bg);
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
  white-space: pre-wrap;
  position: relative;
  max-height: none;
  overflow-x: visible;
  line-height: 1.3;
}

/* Code-specific styling */
.code-preview {
  background-color: var(--code-bg, #f5f5f5);
}

.code-highlight {
  display: block;
  background-color: var(--highlight-color, #f0f0f0);
  font-weight: bold;
}

.code-context {
  display: block;
  opacity: 0.7;
}

/* Highlight matched text in previews */
.result-match {
  background-color: rgba(255, 255, 0, 0.4);
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 -2px;
  font-weight: bold;
  display: inline;
}

/* Fix for consecutive highlighted characters */
.result-match + .result-match {
  margin-left: 0;
  padding-left: 0;
}

/* Different result types styling */
.result-type {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: bold;
}

.result-type-code {
  background-color: #e3f2fd;
  color: #1565c0;
}

.result-type-header {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.result-type-module {
  background-color: #fff3e0;
  color: #e65100;
}

/* Dark theme overrides */
.dark-theme .result-match {
  background-color: rgba(255, 255, 0, 0.25);
  color: var(--text-color);
}

.dark-theme .result-type-code {
  background-color: rgba(25, 118, 210, 0.2);
  color: #90caf9;
}

.dark-theme .result-type-header {
  background-color: rgba(46, 125, 50, 0.2);
  color: #a5d6a7;
}

.dark-theme .result-type-module {
  background-color: rgba(230, 81, 0, 0.2);
  color: #ffcc80;
}

.dark-theme .code-highlight {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Apply blur to main content when search is active */
body.search-active .main-wrapper {
  filter: blur(2px);
}

/* Keyboard shortcut hint in results */
.keyboard-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 11px;
  color: var(--text-light);
  opacity: 0.7;
  user-select: none;
}

/* Add extra room at bottom of results */
.search-results::after {
  content: '';
  display: block;
  height: 16px;
}

/* Empty results state */
.no-results {
  padding: 24px;
  text-align: center;
  color: var(--text-light);
}

/* Loading indicator */
.search-loading {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.search-loading-spinner {
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .search-container {
    width: 100%;
    max-width: calc(100% - 16px);
    border-radius: 8px 8px 0 0;
    position: fixed;
    bottom: 0;
    top: auto;
    max-height: 80vh;
  }
  
  .search-overlay {
    padding-top: 0;
    align-items: flex-end;
  }

  .search-input {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 18px 16px;
  }

  .search-results {
    max-height: calc(80vh - 80px); /* Account for input height */
  }

  .search-result {
    padding: 16px;
  }

  .result-preview {
    font-size: 14px;
  }

  .result-path {
    font-size: 12px;
  }

  .result-type {
    font-size: 10px;
    padding: 1px 4px;
  }
}

@media (max-width: 480px) {
  .search-container {
    max-width: calc(100% - 8px);
    border-radius: 4px 4px 0 0;
  }

  .search-input {
    padding: 16px 12px;
    font-size: 16px;
  }

  .search-results {
    max-height: calc(80vh - 70px);
  }

  .search-result {
    padding: 12px;
  }

  .result-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .result-type {
    align-self: flex-end;
  }
} 