/* Search Bar Component Styles */
.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  font-family: inherit;
}

/* Header Search Bar Styles (optimized for light header) */
.header-search .search-container {
  max-width: 420px;
  margin: 0;
  min-height: 40px;
  display: block;
}

.header-search .search-wrapper {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.header-search .search-wrapper:focus-within {
  border-color: #654BEB;
  box-shadow: 0 4px 16px rgba(101, 75, 235, 0.12);
}

.header-search .search-input {
  color: #1f2937;
  font-size: 14px;
  padding: 8px 12px;
}

.header-search .search-input::placeholder {
  color: #9ca3af;
}

.header-search .search-button {
  width: 36px;
  height: 36px;
  background: #654BEB;
  border-radius: 6px;
  margin: 4px;
}

.header-search .search-button:hover {
  background: #5a3fd8;
}

.header-search .search-button svg {
  width: 16px;
  height: 16px;
}

.header-search .search-clear {
  width: 28px;
  height: 28px;
  background: #f3f4f6;
  color: #6b7280;
  margin-right: 4px;
}

.header-search .search-clear:hover {
  background: #e5e7eb;
  color: #374151;
}

.header-search .search-clear svg {
  width: 14px;
  height: 14px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.search-wrapper:focus-within {
  border-color: #654BEB;
  box-shadow: 0 4px 16px rgba(101, 75, 235, 0.15);
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  outline: none;
  font-size: 16px;
  font-weight: 400;
  color: #1f2937;
  background: transparent;
  direction: rtl;
}

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

.search-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  background: #654BEB;
  color: white;
  border-radius: 8px;
  margin: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.search-button:hover {
  background: #5a3fd8;
  transform: translateY(-1px);
}

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

.search-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: #f3f4f6;
  color: #6b7280;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 8px;
}

.search-clear:hover {
  background: #e5e7eb;
  color: #374151;
}

.search-clear.visible {
  display: flex;
}

.search-clear svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Search Results Dropdown */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}

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

.search-result-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #f3f4f6;
}

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

.search-result-item:hover {
  background: #f9fafb;
}

.search-result-item.selected {
  background: #f0f4ff;
}

.search-result-icon {
  width: 24px;
  height: 24px;
  margin-left: 12px;
  color: #654BEB;
  flex-shrink: 0;
}

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

.search-result-title {
  font-weight: 500;
  color: #1f2937;
  margin-bottom: 2px;
  font-size: 14px;
}

.search-result-category {
  font-size: 12px;
  color: #6b7280;
}

.search-result-price {
  font-weight: 600;
  color: #059669;
  font-size: 14px;
  margin-right: auto;
}

.search-section-title {
  padding: 10px 16px;
  font-size: 12px;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
}

/* Recent chips (mobile-friendly) */
.search-recent { padding: 8px 12px; }
.search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.search-chip {
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.search-chip:hover { background: #eef2ff; border-color: #c7d2fe; }

@media (max-width: 700px) {
  .search-results { max-height: 70vh; }
  .search-chip { font-size: 13px; padding: 8px 12px; }
}

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

.search-loading svg {
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
  margin-left: 8px;
}

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

/* Empty State */
.search-empty {
  padding: 20px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .search-container {
    max-width: 100%;
  }
  
  .search-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .search-results {
    max-height: 300px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .search-wrapper {
    background: #1f2937;
    border-color: #374151;
  }
  
  .search-input {
    color: #f9fafb;
  }
  
  .search-input::placeholder {
    color: #9ca3af;
  }
  
  .search-results {
    background: #1f2937;
    border-color: #374151;
  }
  
  .search-result-item {
    border-bottom-color: #374151;
  }
  
  .search-result-item:hover {
    background: #374151;
  }
  
  .search-result-item.selected {
    background: #1e3a8a;
  }
  
  .search-result-title {
    color: #f9fafb;
  }
  
  .search-clear {
    background: #374151;
    color: #9ca3af;
  }
  
  .search-clear:hover {
    background: #4b5563;
    color: #d1d5db;
  }
}
