/**
 * @file
 * Smart Search dropdown styles.
 */

/* Container */
[data-smart-search] {
  position: relative;
}

/* Dropdown */
.smart-search__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  margin-top: 4px;
  max-height: 480px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 200ms ease, transform 200ms ease, visibility 200ms ease;
}

.smart-search__dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Content container */
.smart-search__content {
  padding: 8px 0;
}

/* Loader */
.smart-search__loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: #6b7280;
  font-size: 14px;
}

.smart-search__spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #DA6630;
  border-radius: 50%;
  animation: smart-search-spin 0.8s linear infinite;
}

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

/* Section header */
.smart-search__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
}

/* Clear history button */
.smart-search__clear-history {
  background: none;
  border: none;
  padding: 0;
  font-size: 11px;
  font-weight: 500;
  color: #DA6630;
  cursor: pointer;
  transition: color 200ms ease;
}

.smart-search__clear-history:hover {
  color: #c55828;
}

/* List */
.smart-search__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Item */
.smart-search__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.smart-search__item:hover,
.smart-search__item.is-highlighted {
  background-color: #f9fafb;
}

.smart-search__item[aria-selected="true"] {
  background-color: #fef3ee;
}

/* Icons */
.smart-search__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  font-size: 14px;
}

.smart-search__icon--category {
  background-color: #f5f3f7;
  color: #68468F;
}

.smart-search__icon--brand {
  background-color: #fef3ee;
  color: #DA6630;
}

.smart-search__icon--deal {
  background-color: #d1fae5;
  color: #10b981;
}

.smart-search__icon--recent {
  background-color: #f3f4f6;
  color: #6b7280;
}

/* Logo and images */
.smart-search__logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.smart-search__deal-image {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

/* Item content */
.smart-search__item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.smart-search__title {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.smart-search__title mark {
  background-color: #fef3ee;
  color: #DA6630;
  font-weight: 600;
  padding: 0 2px;
  border-radius: 2px;
}

.smart-search__subtitle {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badge (discount) */
.smart-search__badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background-color: #DA6630;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
}

/* Deal count */
.smart-search__count {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
}

/* Remove button (for recent) */
.smart-search__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  border-radius: 4px;
  color: #9ca3af;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease, background-color 150ms ease;
}

.smart-search__item:hover .smart-search__remove,
.smart-search__item.is-highlighted .smart-search__remove {
  opacity: 1;
}

.smart-search__remove:hover {
  background-color: #fee2e2;
  color: #ef4444;
}

/* Correction (Did you mean) */
.smart-search__correction {
  padding: 12px 16px;
  background-color: #fef3c7;
  font-size: 13px;
  color: #92400e;
}

.smart-search__correction-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: #DA6630;
  cursor: pointer;
  text-decoration: underline;
}

.smart-search__correction-link:hover {
  color: #c55828;
}

/* No results */
.smart-search__no-results {
  padding: 24px 16px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

.smart-search__no-results .smart-search__query {
  font-weight: 600;
  color: #1a1a2e;
}

/* Footer */
.smart-search__footer {
  padding: 8px 16px 12px;
  border-top: 1px solid #e5e7eb;
}

.smart-search__view-all {
  width: 100%;
  padding: 10px 16px;
  background-color: #DA6630;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 200ms ease, transform 200ms ease;
}

.smart-search__view-all:hover {
  background-color: #c55828;
  transform: translateY(-1px);
}

/* Clear button inside input */
.smart-search__clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  color: #6b7280;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.smart-search__clear:hover {
  background-color: #e5e7eb;
}

/* Responsive */
@media (max-width: 767px) {
  .smart-search__dropdown {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px 16px 0 0;
    max-height: 70vh;
    margin-top: 0;
  }

  .smart-search__item {
    padding: 12px 16px;
  }

  .smart-search__icon,
  .smart-search__logo {
    width: 40px;
    height: 40px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .smart-search__dropdown {
    background: #1f2937;
    border-color: #374151;
  }

  .smart-search__item:hover,
  .smart-search__item.is-highlighted {
    background-color: #374151;
  }

  .smart-search__title {
    color: #f9fafb;
  }

  .smart-search__subtitle,
  .smart-search__count {
    color: #9ca3af;
  }

  .smart-search__section-header {
    color: #6b7280;
  }

  .smart-search__footer {
    border-color: #374151;
  }

  .smart-search__no-results {
    color: #f9fafb;
  }

  .smart-search__no-results .smart-search__query {
    color: #DA6630;
  }

  .smart-search__correction {
    background-color: #78350f;
    color: #fef3c7;
  }
}
