/* Search Autocomplete Styles */

.search-autocomplete {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .15);
  max-height: 500px;
  overflow-y: auto;
  z-index: 9999;
  animation: slideDown 0.3s ease;
}

/* Fix stacking context - TARGET PARENT CONTAINERS */
.unified-search-container {
  position: relative !important;
  z-index: 50 !important;
  /* Must be higher than hero-features */
}

.hero-features {
  position: relative !important;
  z-index: 10 !important;
}

.search-input-wrapper {
  position: relative;
  z-index: 100;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollbar */
.search-autocomplete::-webkit-scrollbar {
  width: 6px;
}

.search-autocomplete::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.search-autocomplete::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.search-autocomplete::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Section */
.autocomplete-section {
  padding: 16px 0;
  border-bottom: 1px solid #e2e8f0;
}

.autocomplete-section:last-child {
  border-bottom: none;
}

.autocomplete-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 12px;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.autocomplete-header i {
  color: #2563eb;
}

.clear-recent {
  margin-right: auto;
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.clear-recent:hover {
  background: #f1f5f9;
  color: #ef4444;
}

/* Items */
.autocomplete-items {
  display: flex;
  flex-direction: column;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: #0f172a;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: #f8fafc;
}

.autocomplete-item i:first-child {
  color: #64748b;
  font-size: 14px;
  flex-shrink: 0;
}

.autocomplete-item i:last-child {
  margin-right: auto;
  color: #cbd5e1;
  font-size: 12px;
}

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

.recent-item span {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.remove-recent {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  margin-right: auto;
}

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

/* Popular Item */
.popular-item span {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.popular-item i:first-child {
  color: #f59e0b;
}

/* Suggestion Item */
.suggestion-item span {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.suggestion-item mark {
  background: #dbeafe;
  color: #2563eb;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 700;
}

/* Product Item */
.product-item {
  gap: 12px;
  padding: 12px 16px;
  align-items: center;
}

.product-item img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #e2e8f0;
}

.product-info {
  flex: 1;
  display: flex;
  flex-direction: row;
  /* Horizontal layout */
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  /* Crucial for text truncate to work inside flex child */
}

.product-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  /* Take available space */
}

.product-name mark {
  background: #dbeafe;
  color: #2563eb;
  padding: 0 2px;
  border-radius: 4px;
  font-weight: 800;
}

.product-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  white-space: nowrap;
  /* Prevent wrapping */
  flex-shrink: 0;
}

.product-meta .category {
  color: #64748b;
  font-weight: 600;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
}

.product-meta .price {
  color: #2563eb;
  font-weight: 700;
  direction: ltr;
  /* Force LTR for numbers if needed, or keep inherited */
}

/* No Results */
.no-results {
  text-align: center;
  padding: 32px 16px;
}

.no-results i {
  font-size: 48px;
  color: #cbd5e1;
  margin-bottom: 16px;
}

.no-results p {
  color: #64748b;
  font-size: 14px;
  margin: 0 0 16px 0;
}

.btn-search-anyway {
  padding: 10px 20px;
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-search-anyway:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
}

/* Loading State */
.autocomplete-loading {
  text-align: center;
  padding: 24px 16px;
  color: #64748b;
}

.autocomplete-loading i {
  font-size: 24px;
  margin-bottom: 8px;
  color: #2563eb;
}

.autocomplete-loading span {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

/* Category Item */
.category-item {
  gap: 12px;
}

.category-item i:first-child {
  font-size: 18px;
  color: #2563eb;
}

.category-item span {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.category-item mark {
  background: #dbeafe;
  color: #2563eb;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 700;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .search-autocomplete {
    max-height: 400px;
    border-radius: 0 0 12px 12px;
  }

  .product-item img {
    width: 40px;
    height: 40px;
  }

  .product-name {
    font-size: 13px;
  }

  .product-meta {
    font-size: 11px;
  }
}