/* Search Container Styles */
.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  z-index: 1001;
}

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

.search-form .input-group {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.search-form .input-group:focus-within {
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.15);
}

.search-input {
  width: 100%;
  padding: 14px 50px 14px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background-color: transparent;
}

.search-input:focus {
  outline: none;
  box-shadow: none;
}

.search-button {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  padding: 0 20px;
  border: none;
  background: transparent;
  color: #6c757d;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-button:hover {
  color: #0d6efd;
  background: transparent;
}

.search-button i {
  font-size: 1.1rem;
}

/* Search Results Styles */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  margin-top: 8px;
  z-index: 1002;
  animation: fadeIn 0.2s ease-out;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #f8f9fa;
  text-decoration: none;
  color: #212529;
  transition: all 0.2s ease;
}

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

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

.search-result-image {
  width: 60px;
  height: 60px;
  margin-right: 15px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

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

.search-result-info {
  flex-grow: 1;
}

.search-result-name {
  font-weight: 500;
  margin-bottom: 4px;
  color: #212529;
}

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

/* Hide "Request Quote" text when it should be hidden */
.product-card__request-quote:empty,
.search-result-price:empty {
    display: none;
}

/* Hide "QAR undefined" text in search results */
.search-result-price:has(:-webkit-any(:contains('undefined'))),
.search-result-price:has(*:contains('undefined')) {
    display: none !important;
}

/* For browsers that don't support :has */
.search-result-price[data-undefined="true"] {
    display: none !important;
}

.search-result-category {
  font-size: 0.8rem;
  color: #6c757d;
}

/* Loading and No Results States */
.loading, .no-results {
  padding: 20px;
  text-align: center;
  color: #6c757d;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid #6c757d;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
  margin-left: 0.5rem;
}

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

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

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

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

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

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

/* Mobile styles */
@media (max-width: 767.98px) {
  .mobile-search {
    position: relative;
    width: 100%;
    padding: 0.25rem 0.5rem;
    padding-bottom: 0.2rem;
    background: #f2f7fd;
    z-index: 9999;
  }

  .mobile-search__icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    z-index: 9999;
  }

  .mobile-search__input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: #f8f9fa;
    position: relative;
    z-index: 9999;
  }

  .search-results {
    
    margin: 0;
    border-radius: 0; /* Full width, no radius */
    max-height: calc(100vh - 101px - 60px); /* Adjust top and bottom nav height */
    border: none;
    border-top: 1px solid #eee; /* Add a top border */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    overflow-y: auto;
    background: #fff;
    display: none; /* Ensure it's visible when populated */
    padding: 5px; /* Add padding around the results */
    max-height: 280px; /* Limit height (adjust as needed, e.g., 250px-300px) */
  }

  /* --- Mockup 4 Styles Applied for Mobile --- */
  .search-result {
    /* No border needed between items */
    margin-bottom: 0; /* Reset margin if any */
    /* Remove border-bottom if previously applied globally or in mobile */
    border-bottom: none;
  }

  .search-result-link {
    display: flex; /* Ensure flex is applied */
    align-items: center; /* Vertically align items */
    padding: 10px 5px; /* Vertical and horizontal padding */
    gap: 10px; /* Space between image and text */
    border-radius: 4px; /* Slightly rounded corners for hover effect */
    transition: background-color 0.15s ease;
    text-decoration: none; /* Remove underline */
    color: #212529; /* Default text color */
  }

  .search-result-link:hover {
    background-color: #f1f3f5; /* Subtle hover background */
  }

  .search-result-image {
    width: 35px; /* Slightly larger image for mobile */
    height: 35px;
    flex-shrink: 0; /* Prevent image shrinking */
    border-radius: 3px; /* Optional: slightly rounded image corners */
    overflow: hidden;
    margin-right: 0; /* Reset margin if previously applied */
  }

  .search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Show the whole image */
  }

  .search-result-details {
    flex-grow: 1; /* Take remaining space */
    min-width: 0; /* Prevent text overflow issues */
  }

  .search-result-title {
    font-size: 0.9rem; /* Mobile-friendly font size */
    font-weight: 500; /* Make title slightly bolder */
    color: #343a40;
    margin: 0; /* Reset margin */
    white-space: nowrap; /* Keep ellipsis */
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .search-result-brand {
    display: none; /* Hide brand as per Mockup 4 */
  }

  .search-result-price {
    font-size: 0.8rem;
    color: #0d6efd; /* Example price color */
    margin-top: 2px;
    font-weight: normal; /* Reset weight if previously applied */
    margin-bottom: 0; /* Reset margin */
  }
  .search-result-price:empty {
    display: none;
  }
  .search-result-quote { /* Style for 'Request Quote' if needed */
      font-size: 0.8rem;
      color: #6c757d;
      font-style: italic;
      margin-top: 2px;
  }
  /* --- End Mockup 4 Styles for Mobile --- */

  /* Remove or comment out conflicting old mobile styles if they exist */
  /* .search-result-item { ... } */
  /* .search-result-info { ... } */
  /* .search-result-name { ... } */
  /* .search-result-category { ... } */

  /* Keep loading/no-results styles */
  .loading, .no-results {
    padding: 20px;
    text-align: center;
    color: #6c757d;
  }
  /* ... keep loading animation ... */

}

/* Desktop styles */
@media (min-width: 768px) {
  .search-container {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    z-index: 9999;
  }

  .search-form {
    position: relative;
    z-index: 9999;
  }

  .search-form .input-group {
    position: relative;
    z-index: 9999;
  }

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

  .search-button {
    position: relative;
    z-index: 9999;
  }

  .search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    background: #fff;
    display: block;
  }
}

/* Brand detail page specific search results */
.brand-search .search-results {
  top: 45px !important;
}

.search-result-item {
  padding: 12px 20px;
}

/* New Search Results Structure Styles */
.search-result {
  border-bottom: 1px solid #f8f9fa;
  margin-bottom: 0;
}

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

.search-result-link {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  text-decoration: none;
  color: #212529;
  transition: all 0.2s ease;
}

.search-result-link:hover {
  background-color: #f8f9fa;
}

.search-result-details {
  flex-grow: 1;
}

.search-result-title {
  font-weight: 500;
  margin-bottom: 4px;
  color: #212529;
}

.search-result-brand {
  font-size: 0.8rem;
  color: #6c757d;
}

/* Hide undefined prices in new structure */
.search-result-details .search-result-price:empty,
.search-result-details .search-result-price:contains("undefined") {
  display: none !important;
}