/* src/styles/SearchBar.css */
/* FIXED: Search suggestions z-index issue - ensuring they appear above toolbar */

.search-bar-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  /* CRITICAL FIX: Create new stacking context for search suggestions */
  z-index: 1070; /* Fallback for browsers without CSS variables */
  z-index: var(--z-tooltip);
}

.search-bar {
  width: 100%;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: #6c757d;
  z-index: 1;
  font-size: 1rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 3rem 0.75rem 3rem;
  font-size: 0.875rem;
  border: 2px solid #3a3f4b;
  border-radius: 25px;
  background-color: #2a2d3a;
  color: white;
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: #00d4ff;
  background-color: #1a1c23;
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.search-input.error {
  border-color: #dc3545;
}

.search-input::placeholder {
  color: #6c757d;
}

.search-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.clear-button {
  position: absolute;
  right: 3.5rem;
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.clear-button:hover {
  color: #a2a5b9;
}

.search-button {
  position: absolute;
  right: 0.5rem;
  background-color: #00d4ff;
  border: none;
  color: #000;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-weight: 600;
}

.search-button:hover:not(:disabled) {
  background-color: #00a8cc;
  transform: translateY(-1px);
}

.search-button:active:not(:disabled) {
  transform: translateY(0);
}

.search-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.spinner {
  animation: spin 0.8s linear infinite;
}

.search-error {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: #dc3545;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
  z-index: 1000;
}

/* FIXED: Enhanced search suggestions with proper z-index hierarchy */
.search-suggestions {
  position: fixed;
  /* CRITICAL FIX: Use fixed positioning to break out of container */
  background: var(--color-text-primary);
  border: 2px solid var(--color-primary-border);
  border-radius: var(--border-radius-md);
  margin-top: var(--spacing-xs);
  max-height: 400px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  /* CRITICAL FIX: Use highest z-index to ensure above toolbar */
  z-index: 1170; /* Fallback for browsers without CSS variables */
  z-index: calc(var(--z-tooltip) + 100);
  backdrop-filter: blur(8px);
  /* ADDED: Force new stacking context */
  isolation: isolate;
  /* ADDED: Ensure suggestions container is above everything */
  transform: translateZ(0);
  /* CRITICAL FIX: Ensure suggestions are positioned correctly */
  width: 100%;
  min-width: 400px;
  max-width: 600px;
}

.search-suggestions.loading {
  background: linear-gradient(135deg, var(--color-bg-secondary), var(--color-bg-tertiary));
}

.suggestion-item {
  display: flex;
  align-items: flex-start;
  padding: var(--spacing-md);
  cursor: pointer;
  transition: var(--transition-base);
  border-bottom: 1px solid var(--color-border-light);
  gap: var(--spacing-md);
  /* ADDED: Ensure individual items maintain z-index */
  position: relative;
  z-index: inherit;
}

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

.suggestion-item:hover,
.suggestion-item.selected {
  background: var(--color-primary-light);
  border-left: 4px solid var(--color-primary);
  /* ADDED: Higher z-index for hovered/selected items */
  z-index: 1171; /* Fallback for browsers without CSS variables */
  z-index: calc(var(--z-tooltip) + 1);
}

.suggestion-icon {
  font-size: var(--font-size-lg);
  flex-shrink: 0;
  margin-top: var(--spacing-xs);
}

.suggestion-text {
  flex: 1;
  min-width: 0;
}

.suggestion-main {
  color: var(--color-text-muted);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-base);
  margin-bottom: var(--spacing-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-sub {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

.suggestion-hint,
.suggestion-item.no-results {
  padding: var(--spacing-md);
  text-align: center;
  color: var(--color-text-tertiary);
  font-style: italic;
  background: var(--color-info-light);
  border-top: 1px solid var(--color-info-border);
}

.loading-item {
  justify-content: center;
  font-style: italic;
  color: var(--color-text-tertiary);
}

/* Responsive */
@media (max-width: 768px) {
  .search-bar-container {
    max-width: 100%;
  }

  .search-input {
    font-size: 0.875rem;
    padding: 0.6rem 2.5rem;
  }

  .search-suggestions {
    max-height: 200px;
    /* MOBILE FIX: Even higher z-index on mobile */
    z-index: 1270; /* Fallback for browsers without CSS variables */
    z-index: calc(var(--z-tooltip) + 200);
    /* MOBILE FIX: Full width on mobile */
    min-width: 100%;
    left: 0 !important;
    right: 0 !important;
  }
}

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

/* LEGACY COMPATIBILITY: Fallback search suggestions styling */
.search-suggestions {
  position: fixed;
  /* CRITICAL LEGACY FIX: Use fixed positioning */
  background-color: #2a2d3a;
  border: 1px solid #3a3f4b;
  border-radius: 8px;
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  /* CRITICAL LEGACY FIX: Explicit high z-index */
  z-index: 9999;
  /* CRITICAL LEGACY FIX: Ensure suggestions are positioned correctly */
  width: 100%;
  min-width: 400px;
}

.suggestion-item {
  display: flex;
  align-items: flex-start;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #3a3f4b;
}

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

.suggestion-item:hover {
  background-color: #3a3f4b;
}

.suggestion-icon {
  color: #00d4ff;
  margin-right: 0.75rem;
  margin-top: 0.25rem;
  flex-shrink: 0;
}

.suggestion-text {
  flex: 1;
  overflow: hidden;
}

.suggestion-main {
  color: #fff;
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.suggestion-sub {
  color: #6c757d;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
} 