/**
 * Стили для умного поиска с подсказками
 */

/* Контейнер для поля поиска */
.search-container {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 12px 50px 12px 20px;
  font-size: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  outline: none;
  transition: all 0.3s ease;
}

.search-input:focus {
  border-color: #2196f3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Выпадающий список подсказок */
.search-suggest-dropdown {
  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;
  transform: translateY(-10px);
  transition: opacity 0.2s, transform 0.2s;
}

.search-suggest-dropdown--visible {
  opacity: 1;
  transform: translateY(0);
}

/* Секции */
.search-suggest-section {
  padding: 16px 0;
  border-bottom: 1px solid #f0f0f0;
}

.search-suggest-section:last-child {
  border-bottom: none;
}

.search-suggest-title {
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #999;
  letter-spacing: 0.5px;
}

/* Элемент подсказки */
.search-suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s;
}

.search-suggest-item:hover,
.search-suggest-item--active {
  background-color: #f5f5f5;
}

/* Изображение товара */
.search-suggest-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: #f0f0f0;
}

.search-suggest-img-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
  flex-shrink: 0;
}

/* Контент элемента */
.search-suggest-content {
  flex: 1;
  min-width: 0;
}

.search-suggest-name {
  font-size: 15px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-suggest-name mark {
  background-color: #fff59d;
  color: inherit;
  font-weight: 600;
}

.search-suggest-article {
  font-size: 13px;
  color: #999;
  margin-bottom: 4px;
}

.search-suggest-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.search-suggest-price {
  font-size: 16px;
  font-weight: 600;
  color: #2196f3;
}

.search-suggest-badge {
  font-size: 11px;
  padding: 3px 8px;
  background-color: #4caf50;
  color: white;
  border-radius: 4px;
  font-weight: 500;
}

/* Категории и бренды */
.search-suggest-item--category {
  padding: 10px 20px;
}

.search-suggest-icon {
  color: #999;
  flex-shrink: 0;
}

/* Кнопка "Показать все" */
.search-suggest-show-all {
  display: block;
  padding: 14px 20px;
  text-align: center;
  color: #2196f3;
  font-weight: 500;
  text-decoration: none;
  border-top: 1px solid #f0f0f0;
  transition: background-color 0.15s;
}

.search-suggest-show-all:hover,
.search-suggest-show-all.search-suggest-item--active {
  background-color: #f5f5f5;
}

/* Пустой результат */
.search-suggest-empty {
  padding: 32px 20px;
  text-align: center;
}

.search-suggest-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.search-suggest-empty-text {
  font-size: 14px;
  color: #999;
  margin-bottom: 24px;
}

/* Популярные запросы */
.search-suggest-popular {
  margin-top: 24px;
  text-align: left;
}

.search-suggest-popular-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px;
}

.search-suggest-popular-item {
  display: inline-block;
  padding: 8px 16px;
  background-color: #f5f5f5;
  border-radius: 20px;
  font-size: 14px;
  color: #333;
  text-decoration: none;
  transition: all 0.2s;
}

.search-suggest-popular-item:hover {
  background-color: #2196f3;
  color: white;
}

/* Скроллбар */
.search-suggest-dropdown::-webkit-scrollbar {
  width: 8px;
}

.search-suggest-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.search-suggest-dropdown::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

.search-suggest-dropdown::-webkit-scrollbar-thumb:hover {
  background: #ccc;
}

/* Мобильные устройства */
@media (max-width: 768px) {
  .search-container {
    max-width: 100%;
  }

  .search-input {
    font-size: 16px; /* Предотвращает зум на iOS */
    padding: 14px 20px;
  }

  .search-suggest-dropdown {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid #e0e0e0;
  }

  .search-suggest-item {
    padding: 16px;
  }

  .search-suggest-img,
  .search-suggest-img-placeholder {
    width: 50px;
    height: 50px;
  }

  .search-suggest-name {
    font-size: 14px;
  }

  .search-suggest-price {
    font-size: 15px;
  }

  /* Overlay для закрытия */
  .search-suggest-dropdown::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    z-index: -1;
  }
}

/* Планшеты */
@media (min-width: 769px) and (max-width: 1024px) {
  .search-container {
    max-width: 600px;
  }
}

/* Анимация загрузки */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.search-suggest-loading {
  padding: 32px 20px;
  text-align: center;
  color: #999;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Адаптация для поиска в шапке - десктоп */
.search-container-header {
  position: relative;
}

.search-container-header .search-suggest-dropdown {
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 400px;
  z-index: 10000;
}

@media (max-width: 1024px) {
  .search-container-header .search-suggest-dropdown {
    min-width: 350px;
  }
}

/* Адаптация для мобильной формы поиска */
#mobile-search-input ~ .search-suggest-dropdown {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  min-width: auto;
  border-radius: 0;
  max-height: calc(100vh - 60px);
  z-index: 10000;
}

@media screen and (max-width: 1230px) {
  #mobile-search-input ~ .search-suggest-dropdown {
    top: 190px;
  }

  .search-suggest-dropdown > .search-suggest-section:nth-child(2) {
    display: none;
  }

  .search-suggest-show-all {
    font-size: 20px;
  }
}

@media screen and (max-width: 767px) {
  #mobile-search-input ~ .search-suggest-dropdown {
    top: 100px;
  }
}
