/**
 * Search UI Styles
 * 
 * Styles for:
 * - Search input with autocomplete
 * - Scenario prompts
 * - Search results with highlighting
 * - Empty state
 * 
 * Requirements: 4.1, 4.2, 4.6, 4.7
 */

/* ============================================================================
   Search Container
   ============================================================================ */

.search-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
}

.search-wrapper {
  position: relative;
  margin-bottom: 2rem;
}

/* ============================================================================
   Search Input
   ============================================================================ */

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.search-input-group:focus-within {
  border-color: #4a90e2;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15);
}

.search-icon {
  font-size: 1.25rem;
  color: #666;
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  color: #333;
  background: transparent;
}

.search-input::placeholder {
  color: #999;
}

.search-clear-btn {
  background: none;
  border: none;
  color: #999;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  margin-left: 0.5rem;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: none;
}

.search-input-group.has-value .search-clear-btn {
  display: block;
}

.search-clear-btn:hover {
  background: #f0f0f0;
  color: #666;
}

/* ============================================================================
   Autocomplete Dropdown
   ============================================================================ */

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #e0e0e0;
  border-top: none;
  border-radius: 0 0 12px 12px;
  margin-top: -10px;
  padding-top: 10px;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
}

.autocomplete-dropdown.visible {
  display: block;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: #f5f5f5;
}

.autocomplete-item-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.autocomplete-item-text {
  flex: 1;
  color: #333;
  font-size: 0.95rem;
}

.autocomplete-item-type {
  font-size: 0.75rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.autocomplete-section-title {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-top: 1px solid #f0f0f0;
  margin-top: 0.5rem;
}

.autocomplete-section-title:first-child {
  border-top: none;
  margin-top: 0;
}

/* ============================================================================
   Scenario Prompts
   ============================================================================ */

.scenario-prompts {
  margin-bottom: 2rem;
}

.scenario-prompts-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.scenario-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.scenario-chip {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.scenario-chip:hover {
  background: #e8f4ff;
  border-color: #4a90e2;
  color: #4a90e2;
}

.scenario-chip-icon {
  font-size: 1rem;
}

/* ============================================================================
   Search Results
   ============================================================================ */

.search-results {
  margin-top: 2rem;
}

.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #e0e0e0;
}

.search-results-count {
  font-size: 1rem;
  color: #666;
}

.search-results-count strong {
  color: #333;
  font-weight: 600;
}

.search-results-sort {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-results-sort label {
  font-size: 0.875rem;
  color: #666;
}

.search-results-sort select {
  padding: 0.25rem 0.5rem;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #333;
  background: white;
  cursor: pointer;
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================================================================
   Search Result Item
   ============================================================================ */

.search-result-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

.search-result-item:hover {
  border-color: #4a90e2;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.15);
  transform: translateY(-2px);
}

.search-result-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.search-result-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.search-result-content {
  flex: 1;
}

.search-result-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.search-result-title mark {
  background: #fff3cd;
  color: #333;
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
}

.search-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: #666;
  margin-bottom: 0.75rem;
}

.search-result-meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.search-result-description {
  color: #666;
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.search-result-description mark {
  background: #fff3cd;
  color: #333;
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
  font-weight: 500;
}

.search-result-matched-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.matched-field-badge {
  background: #e8f4ff;
  color: #4a90e2;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.search-result-relevance {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.5rem;
}

/* ============================================================================
   Empty State
   ============================================================================ */

.search-empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.search-empty-icon {
  font-size: 4rem;
  color: #ccc;
  margin-bottom: 1rem;
}

.search-empty-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 0.5rem;
}

.search-empty-message {
  color: #999;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.search-suggestions {
  margin-top: 2rem;
}

.search-suggestions-title {
  font-size: 1rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 1rem;
}

.search-suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.search-suggestion-chip {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-suggestion-chip:hover {
  background: #4a90e2;
  border-color: #4a90e2;
  color: white;
}

/* ============================================================================
   Loading State
   ============================================================================ */

.search-loading {
  text-align: center;
  padding: 3rem 2rem;
}

.search-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f0f0f0;
  border-top-color: #4a90e2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.search-loading-text {
  color: #999;
  font-size: 0.875rem;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
  .search-container {
    padding: 0 1rem;
  }

  .search-input-group {
    padding: 0.625rem 0.875rem;
  }

  .search-input {
    font-size: 0.9375rem;
  }

  .search-result-item {
    padding: 1rem;
  }

  .search-result-title {
    font-size: 1.125rem;
  }

  .search-results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .scenario-chips {
    gap: 0.375rem;
  }

  .scenario-chip {
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
  }
}

@media (max-width: 480px) {
  .search-result-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-result-icon {
    font-size: 1.5rem;
  }

  .search-result-meta {
    flex-direction: column;
    gap: 0.5rem;
  }
}
