/* ===============================================
   ADVANCED SEARCH SYSTEM - AMAZON/FLIPKART STYLE
   =============================================== */

/* Search Container */
.advanced-search-wrapper {
  position: relative;
  flex: 1;
  max-width: 700px;
  margin: 0 auto;
}

/* Search Input Container */
.search-input-container {
  position: relative;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow: hidden;
}

.search-input-container:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
  transform: translateY(-2px);
}

.search-input {
  width: 100%;
  height: 48px;
  padding: 0 140px 0 20px;
  border: none;
  outline: none;
  font-size: 16px;
  font-weight: 500;
  background: transparent;
  color: #1f2937;
}

.search-input::placeholder {
  color: #9ca3af;
  font-weight: 400;
}

/* Voice Search Button */
.voice-search-btn {
  position: absolute;
  right: 60px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

.voice-search-btn:hover {
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.voice-search-btn.listening {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-50%) scale(1.1); }
}

/* Search Button */
.search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 16px;
}

.search-btn:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Search Loader */
.search-loader {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
}

.search-loader .spinner {
  width: 100%;
  height: 100%;
  border: 2px solid #e5e7eb;
  border-top: 2px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  max-height: 500px;
  overflow-y: auto;
  margin-top: 4px;
}

.autocomplete-dropdown.hidden {
  display: none;
}

/* Search Suggestions */
.search-suggestions {
  padding: 16px 0;
}

.suggestion-section {
  margin-bottom: 20px;
}

.suggestion-section:last-child {
  margin-bottom: 0;
}

.suggestion-section h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 12px;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #f3f4f6;
}

.suggestion-section h4 i {
  font-size: 12px;
  color: #9ca3af;
}

/* Suggestion Items */
.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid #f9fafb;
}

.suggestion-item:hover {
  background: #f8fafc;
  padding-left: 24px;
}

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

.suggestion-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.suggestion-icon {
  color: #9ca3af;
  font-size: 14px;
}

.suggestion-text {
  font-size: 14px;
  color: #374151;
  font-weight: 500;
}

.suggestion-text strong {
  color: #3b82f6;
  font-weight: 600;
}

.suggestion-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #9ca3af;
}

/* Recent Search Items */
.recent-item {
  position: relative;
}

.recent-item .remove-recent {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  opacity: 0;
}

.recent-item:hover .remove-recent {
  opacity: 1;
}

.recent-item .remove-recent:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* Popular Search Items */
.popular-item .fas.fa-fire {
  color: #f59e0b;
}

/* No Suggestions */
.no-suggestions {
  padding: 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  font-style: italic;
}

/* ===============================================
   ADVANCED FILTERS PANEL
   =============================================== */

.filters-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  z-index: 999;
  margin-top: 4px;
  max-height: 80vh;
  overflow-y: auto;
}

.filters-panel.hidden {
  display: none;
}

/* Filters Header */
.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #f3f4f6;
  background: #fafbfc;
}

.filters-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.close-filters {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.close-filters:hover {
  background: #f3f4f6;
  color: #374151;
}

/* Filters Content */
.filters-content {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 32px;
}

/* Filter Groups */
.filter-group {
  display: flex;
  flex-direction: column;
}

.filter-group h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: #374151;
  padding-bottom: 8px;
  border-bottom: 2px solid #f3f4f6;
}

/* Category Filters */
.category-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.category-filters label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 8px 0;
  transition: all 0.2s ease;
}

.category-filters label:hover {
  color: #3b82f6;
}

.category-filters input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  position: relative;
  appearance: none;
  transition: all 0.2s ease;
}

.category-filters input[type="checkbox"]:checked {
  background: #3b82f6;
  border-color: #3b82f6;
}

.category-filters input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.category-filters span {
  font-size: 14px;
  color: #374151;
  font-weight: 500;
}

/* Price Range Filter */
.price-range-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.price-inputs {
  display: flex;
  align-items: center;
  gap: 12px;
}

.price-inputs input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  text-align: center;
}

.price-inputs span {
  color: #6b7280;
  font-size: 14px;
  font-weight: 500;
}

.price-slider {
  position: relative;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
}

.price-slider input[type="range"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  appearance: none;
  pointer-events: none;
}

.price-slider input[type="range"]::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  appearance: none;
  pointer-events: auto;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.price-slider input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Rating Filters */
.rating-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rating-filters label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 8px 0;
  transition: all 0.2s ease;
}

.rating-filters label:hover {
  color: #3b82f6;
}

.rating-filters input[type="radio"] {
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  appearance: none;
  transition: all 0.2s ease;
}

.rating-filters input[type="radio"]:checked {
  background: #3b82f6;
  border-color: #3b82f6;
  box-shadow: inset 0 0 0 3px white;
}

.stars {
  color: #fbbf24;
  font-size: 16px;
  letter-spacing: 2px;
}

/* Delivery Filters */
.delivery-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.delivery-filters label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 8px 0;
  transition: all 0.2s ease;
}

.delivery-filters label:hover {
  color: #3b82f6;
}

.delivery-filters input[type="radio"] {
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  appearance: none;
  transition: all 0.2s ease;
}

.delivery-filters input[type="radio"]:checked {
  background: #3b82f6;
  border-color: #3b82f6;
  box-shadow: inset 0 0 0 3px white;
}

/* Availability Filters */
.availability-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.availability-filters label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 8px 0;
  transition: all 0.2s ease;
}

.availability-filters label:hover {
  color: #3b82f6;
}

.availability-filters input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  position: relative;
  appearance: none;
  transition: all 0.2s ease;
}

.availability-filters input[type="checkbox"]:checked {
  background: #3b82f6;
  border-color: #3b82f6;
}

.availability-filters input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

/* Filters Actions */
.filters-actions {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #f3f4f6;
  background: #fafbfc;
}

.apply-filters-btn {
  flex: 1;
  padding: 12px 24px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.apply-filters-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.clear-filters-btn {
  padding: 12px 24px;
  background: transparent;
  color: #6b7280;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.clear-filters-btn:hover {
  background: #f9fafb;
  color: #374151;
  border-color: #9ca3af;
}

/* ===============================================
   MOBILE RESPONSIVE DESIGN
   =============================================== */

@media (max-width: 768px) {
  .advanced-search-wrapper {
    max-width: 100%;
  }
  
  .search-input {
    height: 44px;
    padding: 0 120px 0 16px;
    font-size: 16px;
  }
  
  .voice-search-btn {
    right: 55px;
    width: 36px;
    height: 36px;
    font-size: 12px;
  }
  
  .search-btn {
    right: 6px;
    width: 44px;
    height: 32px;
    font-size: 14px;
  }
  
  .autocomplete-dropdown {
    max-height: 300px;
  }
  
  .filters-panel {
    max-height: 70vh;
  }
  
  .filters-content {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 20px;
  }
  
  .filters-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .search-input {
    padding: 0 100px 0 12px;
    font-size: 16px;
  }
  
  .voice-search-btn {
    right: 50px;
    width: 32px;
    height: 32px;
  }
  
  .search-btn {
    width: 40px;
    height: 30px;
  }
  
  .suggestion-item {
    padding: 10px 16px;
  }
  
  .filters-header,
  .filters-actions {
    padding: 16px 20px;
  }
  
  .filters-content {
    padding: 16px 20px;
    gap: 20px;
  }
}

/* ===============================================
   DARK MODE SUPPORT
   =============================================== */

@media (prefers-color-scheme: dark) {
  .search-input-container {
    background: #1f2937;
    border-color: #374151;
  }
  
  .search-input {
    color: #f9fafb;
  }
  
  .search-input::placeholder {
    color: #6b7280;
  }
  
  .autocomplete-dropdown,
  .filters-panel {
    background: #1f2937;
    border-color: #374151;
  }
  
  .suggestion-item:hover {
    background: #374151;
  }
  
  .suggestion-text {
    color: #f9fafb;
  }
  
  .filters-header,
  .filters-actions {
    background: #111827;
  }
  
  .filters-header h3 {
    color: #f9fafb;
  }
}

/* ===============================================
   ACCESSIBILITY IMPROVEMENTS
   =============================================== */

.search-input:focus,
.voice-search-btn:focus,
.search-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.suggestion-item:focus {
  background: #f3f4f6;
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
