/* Overlay tìm kiếm — gọn, ô tìm giữa, kết quả khi gõ */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.search-overlay[hidden] {
  display: none !important;
}

body.search-open {
  overflow: hidden;
}

.search-overlay__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.search-overlay__panel {
  position: relative;
  width: min(480px, 100%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.search-overlay__close {
  position: absolute;
  top: -2.75rem;
  right: 0;
  color: #fff;
  font-size: 1.35rem;
  opacity: 0.85;
}

.search-overlay__close:hover {
  opacity: 1;
}

.search-overlay__form {
  margin: 0;
  width: 100%;
}

.search-overlay__input {
  width: 100%;
  padding: 1rem 1.15rem;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.18);
  text-align: center;
}

.search-overlay__input::placeholder {
  color: #9a9a9a;
}

.search-overlay__input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
  text-align: left;
}

.search-results {
  width: 100%;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.search-results[hidden] {
  display: none !important;
}

.search-results__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}

.search-results__item:last-of-type {
  border-bottom: none;
}

.search-results__item:hover {
  background: var(--accent-soft);
}

.search-results__thumb {
  flex-shrink: 0;
  width: 3.5rem;
  height: 4.375rem;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

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

.search-results__thumb-ph {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #f5f5f5, #ececec);
}

.search-results__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.search-results__name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-results__sku {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.search-results__price {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bem-orange);
}

.search-results__empty {
  margin: 0;
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.search-results__more {
  display: block;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bem-orange);
  text-decoration: none;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  border-radius: 0 0 12px 12px;
}

.search-results__more:hover {
  background: var(--accent-soft);
}

@media (max-width: 900px) {
  .search-overlay {
    padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
    align-items: center;
  }

  .search-overlay__panel {
    width: 100%;
    max-width: 480px;
  }

  .search-overlay__close {
    position: fixed;
    top: max(0.65rem, env(safe-area-inset-top));
    right: 0.85rem;
    z-index: 2;
  }

  .search-overlay__input {
    font-size: 1rem;
    padding: 0.9rem 1rem;
  }

  .search-results {
    max-height: min(46vh, 360px);
  }

  .header-actions .btn-outline {
    display: none;
  }
}
