/* ============================================
   SEARCH AUTOCOMPLETE STYLES
   ============================================ */

/* Search Container */
.search-container {
  position: relative;
  width: 100%;
  max-width: 600px;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 12px 45px 12px 20px;
  border: 2px solid #e0e0e0;
  border-radius: 25px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: white;
}

.search-input:focus {
  outline: none;
  border-color: #d4a574;
  box-shadow: 0 4px 12px rgba(212, 165, 116, 0.15);
}

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

.search-icon {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #666;
  pointer-events: none;
}

/* Results Container */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  max-height: 500px;
  overflow-y: auto;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.search-results.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

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

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

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

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

/* Search Groups */
.search-group {
  padding: 8px 0;
}

.search-group:not(:last-child) {
  border-bottom: 1px solid #f0f0f0;
}

.search-group-title {
  padding: 8px 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
}

/* Result Items */
.search-result-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  text-decoration: none;
  color: #333;
  transition: all 0.2s ease;
  cursor: pointer;
  gap: 15px;
}

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

.search-result-item.selected {
  border-left: 3px solid #d4a574;
}

/* Product Result */
.search-result-image {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f5f5;
}

.search-result-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Icon Results (Brand, Note, Family) */
.search-result-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
  border-radius: 50%;
  color: #d4a574;
  font-size: 1.2rem;
}

/* Result Content */
.search-result-content {
  flex: 1;
  min-width: 0;
}

.search-result-brand {
  font-size: 0.8rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.search-result-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-price {
  font-size: 0.9rem;
  font-weight: 600;
  color: #d4a574;
  margin-top: 2px;
}

.search-result-meta {
  font-size: 0.85rem;
  color: #666;
  margin-top: 2px;
}

.search-result-arrow {
  flex-shrink: 0;
  color: #ccc;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.search-result-item:hover .search-result-arrow,
.search-result-item.selected .search-result-arrow {
  color: #d4a574;
  transform: translateX(3px);
}

/* Highlight matched text */
.search-result-name mark,
.search-result-brand mark {
  background-color: #fff3cd;
  color: #333;
  font-weight: 600;
  padding: 0 2px;
  border-radius: 2px;
}

/* Loading State */
.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: #666;
}

.search-loading .spinner-border {
  width: 1.5rem;
  height: 1.5rem;
  border-width: 2px;
}

/* No Results */
.search-no-results {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

.search-no-results i {
  font-size: 2.5rem;
  color: #ddd;
  margin-bottom: 15px;
}

.search-no-results p {
  margin-bottom: 5px;
  font-size: 1rem;
}

.search-no-results small {
  color: #999;
  font-size: 0.85rem;
}

/* Error State */
.search-error {
  text-align: center;
  padding: 40px 20px;
  color: #dc3545;
}

.search-error i {
  font-size: 2rem;
  margin-bottom: 10px;
}

/* Mobile Adjustments */
@media (max-width: 767px) {
  .search-container {
    max-width: 100%;
  }
  
  .search-input {
    padding: 10px 40px 10px 15px;
    font-size: 0.95rem;
  }
  
  .search-icon {
    right: 15px;
  }
  
  .search-results {
    position: fixed;
    top: 60px;
    left: 10px;
    right: 10px;
    max-height: calc(100vh - 70px);
    border-radius: 12px;
  }
  
  .search-result-item {
    padding: 10px 15px;
  }
  
  .search-result-image {
    width: 45px;
    height: 45px;
  }
  
  .search-result-icon {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }
  
  .search-result-name {
    font-size: 0.9rem;
  }
  
  .search-result-brand,
  .search-result-meta {
    font-size: 0.75rem;
  }
  
  .search-group-title {
    padding: 6px 15px;
    font-size: 0.7rem;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .search-input {
    background: #2a2a2a;
    border-color: #444;
    color: #f5f5f5;
  }
  
  .search-input::placeholder {
    color: #777;
  }
  
  .search-results {
    background: #1a1a1a;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  }
  
  .search-group:not(:last-child) {
    border-bottom-color: #333;
  }
  
  .search-group-title {
    color: #888;
  }
  
  .search-result-item {
    color: #f5f5f5;
  }
  
  .search-result-item:hover,
  .search-result-item.selected {
    background: #2a2a2a;
  }
  
  .search-result-name {
    color: #f5f5f5;
  }
  
  .search-result-brand,
  .search-result-meta {
    color: #999;
  }
  
  .search-result-icon {
    background: linear-gradient(135deg, #2a2a2a 0%, #333 100%);
  }
  
  .search-no-results,
  .search-loading {
    color: #999;
  }
  
  .search-no-results i {
    color: #444;
  }
}

/* Animation */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-results.show {
  animation: fadeInDown 0.3s ease;
}

/* Accessibility */
.search-result-item:focus {
  outline: 2px solid #d4a574;
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  .search-results,
  .search-result-item,
  .search-result-arrow {
    transition: none;
    animation: none;
  }
}
