/**
 * 🎨 ADVANCED SEARCH STYLES
 * Estilos para autocomplete, highlight e busca avançada
 * @author Senior Fullstack Developer
 * @version 2.0.0
 */

/* ============================================================================
   HIGHLIGHT - Destaque de termos encontrados
   ============================================================================ */

.search-highlight {
  background: linear-gradient(120deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(251, 191, 36, 0.1);
  transition: all 0.2s ease;
}

.search-highlight:hover {
  background: linear-gradient(120deg, #fde68a 0%, #fcd34d 100%);
  box-shadow: 0 2px 4px rgba(251, 191, 36, 0.2);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .search-highlight {
    background: linear-gradient(120deg, #78350f 0%, #92400e 100%);
    color: #fef3c7;
  }
  
  .search-highlight:hover {
    background: linear-gradient(120deg, #92400e 0%, #b45309 100%);
  }
}

/* ============================================================================
   AUTOCOMPLETE DROPDOWN
   ============================================================================ */

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  margin-top: 0.5rem;
  box-shadow: 
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  display: none;
  animation: autocomplete-fade-in 0.2s ease;
}

@keyframes autocomplete-fade-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollbar customizado */
.autocomplete-dropdown::-webkit-scrollbar {
  width: 8px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ============================================================================
   AUTOCOMPLETE ITEMS
   ============================================================================ */

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border-bottom: 1px solid #f3f4f6;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: linear-gradient(to right, #f0f9ff, #e0f2fe);
  border-color: #bae6fd;
}

.autocomplete-item:active {
  background: #dbeafe;
  transform: scale(0.98);
}

/* Ícone do autocomplete */
.autocomplete-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Texto principal */
.autocomplete-text {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-item:hover .autocomplete-text,
.autocomplete-item.active .autocomplete-text {
  color: #0369a1;
}

/* Campo de origem */
.autocomplete-field {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: capitalize;
  padding: 0.125rem 0.5rem;
  background: #f3f4f6;
  border-radius: 0.25rem;
  font-weight: 500;
  flex-shrink: 0;
}

.autocomplete-item:hover .autocomplete-field,
.autocomplete-item.active .autocomplete-field {
  background: #e0f2fe;
  color: #0369a1;
}

/* Highlight dentro do autocomplete */
.autocomplete-text .search-highlight {
  background: #fef3c7;
  color: #92400e;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-weight: 700;
}

.autocomplete-item:hover .autocomplete-text .search-highlight,
.autocomplete-item.active .autocomplete-text .search-highlight {
  background: #fcd34d;
  color: #78350f;
}

/* ============================================================================
   EMPTY STATE
   ============================================================================ */

.autocomplete-empty {
  padding: 1.5rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.875rem;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.autocomplete-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  gap: 0.5rem;
  color: #6b7280;
  font-size: 0.875rem;
}

.autocomplete-loading::before {
  content: "";
  width: 1rem;
  height: 1rem;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: autocomplete-spin 0.6s linear infinite;
}

@keyframes autocomplete-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================================
   DARK MODE
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  .autocomplete-dropdown {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 
      0 10px 15px -3px rgba(0, 0, 0, 0.3),
      0 4px 6px -2px rgba(0, 0, 0, 0.2),
      0 0 0 1px rgba(255, 255, 255, 0.05);
  }
  
  .autocomplete-item {
    border-color: #374151;
  }
  
  .autocomplete-item:hover,
  .autocomplete-item.active {
    background: linear-gradient(to right, #1e3a8a, #1e40af);
    border-color: #3b82f6;
  }
  
  .autocomplete-text {
    color: #f3f4f6;
  }
  
  .autocomplete-item:hover .autocomplete-text,
  .autocomplete-item.active .autocomplete-text {
    color: #93c5fd;
  }
  
  .autocomplete-field {
    background: #374151;
    color: #9ca3af;
  }
  
  .autocomplete-item:hover .autocomplete-field,
  .autocomplete-item.active .autocomplete-field {
    background: #1e40af;
    color: #93c5fd;
  }
  
  .autocomplete-empty {
    color: #6b7280;
  }
  
  .autocomplete-dropdown::-webkit-scrollbar-track {
    background: #374151;
  }
  
  .autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #4b5563;
  }
  
  .autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
  }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
  .autocomplete-dropdown {
    max-height: 200px;
    margin-top: 0.25rem;
  }
  
  .autocomplete-item {
    padding: 0.625rem 0.75rem;
    gap: 0.5rem;
  }
  
  .autocomplete-icon {
    font-size: 1rem;
    width: 1.25rem;
    height: 1.25rem;
  }
  
  .autocomplete-text {
    font-size: 0.8125rem;
  }
  
  .autocomplete-field {
    font-size: 0.6875rem;
    padding: 0.1rem 0.375rem;
  }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

.autocomplete-item:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
  background: linear-gradient(to right, #dbeafe, #bfdbfe);
}

/* Alto contraste */
@media (prefers-contrast: high) {
  .search-highlight {
    outline: 2px solid currentColor;
  }
  
  .autocomplete-item:hover,
  .autocomplete-item.active {
    outline: 2px solid #3b82f6;
  }
}

/* Redução de movimento */
@media (prefers-reduced-motion: reduce) {
  .autocomplete-dropdown {
    animation: none;
  }
  
  .autocomplete-item,
  .search-highlight {
    transition: none;
  }
}
