:root {
  --search-primary: var(--color-primary, #8b7355);
  --search-secondary: var(--color-secondary, #c19970);
  --search-overlay-bg: rgba(32, 24, 18, 0.82);
  --search-panel-bg: var(--catalog-bg, #f7f4ef);
  --search-panel-gradient: linear-gradient(135deg, rgba(139, 115, 85, 0.12), rgba(193, 153, 112, 0.08));
  --search-border: rgba(139, 115, 85, 0.28);
  --search-shadow: 0 35px 120px rgba(23, 18, 13, 0.27);
}

body.dark {
  --search-overlay-bg: rgba(12, 9, 6, 0.92);
  --search-panel-bg: #201914;
  --search-panel-gradient: linear-gradient(135deg, rgba(193, 153, 112, 0.06), rgba(139, 115, 85, 0.03));
  --search-border: rgba(255, 244, 232, 0.08);
  --search-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.global-search {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 12% 10%, rgba(247, 241, 234, 0.12), transparent 50%), var(--search-overlay-bg);
  display: none;
  padding: clamp(0.75rem, 2vw, 2rem);
  padding-top: calc(clamp(0.75rem, 2vw, 2rem) + env(safe-area-inset-top, 0px));
  padding-bottom: calc(clamp(0.75rem, 2vw, 2rem) + env(safe-area-inset-bottom, 0px));
  backdrop-filter: blur(12px);
  z-index: 4000;
  overflow-y: auto;
}

.global-search.active {
  display: block;
}

.global-search__panel {
  width: 100%;
  min-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - clamp(1.5rem, 4vw, 3rem));
  background: var(--search-panel-bg);
  background-image: var(--search-panel-gradient);
  border-radius: 24px;
  box-shadow: var(--search-shadow);
  padding: clamp(1rem, 2.5vw, 2.25rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  border: 1px solid var(--search-border);
}

.global-search__header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.global-search__autocomplete {
  position: relative;
}

.autocomplete-panel {
  margin-top: -0.3rem;
  border: 1px solid var(--search-border);
  border-radius: 16px;
  background: var(--search-panel-bg);
  box-shadow: var(--search-shadow);
  max-height: 220px;
  overflow-y: auto;
  padding: 0.35rem 0;
}

body.dark .autocomplete-panel {
  background: rgba(36, 31, 29, 0.98);
}

.autocomplete-panel.is-hidden {
  display: none;
}

.autocomplete-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.autocomplete-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s ease;
}

.autocomplete-list li i {
  color: var(--primary-color, #a1683a);
  font-size: 0.85rem;
}

.autocomplete-list li:hover {
  background: rgba(0, 0, 0, 0.04);
}

.global-search__input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--search-border);
  border-radius: 16px;
  padding: 0.9rem 1.2rem;
  background: rgba(247, 241, 234, 0.85);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

body.dark .global-search__input-wrapper {
  background: rgba(32, 25, 20, 0.65);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.global-search__input-wrapper input {
  border: none;
  background: transparent;
  font-size: 1rem;
  width: 100%;
  color: inherit;
}

.global-search__input-wrapper input:focus {
  outline: none;
}

.ghost-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font-size: 1.05rem;
  padding: 0.4rem;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.ghost-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.dark .ghost-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.global-search__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.global-search__meta select {
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--search-border);
  background: transparent;
  min-width: 210px;
}

.global-search__body {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1.5rem;
  min-height: 520px;
}

.global-search__filters {
  border-right: 1px solid var(--search-border);
  padding-right: 1.5rem;
  max-height: min(520px, calc(100vh - 240px));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.filters-section {
  margin-bottom: 1.5rem;
}

.filters-section h4 {
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
  color: var(--search-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  margin-bottom: 0.7rem;
  gap: 0.35rem;
}

.filter-label select,
.filter-price input {
  border-radius: 0.6rem;
  border: 1px solid var(--search-border);
  padding: 0.45rem 0.6rem;
  background: transparent;
}

.filter-price {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.filter-price input {
  flex: 1 1 130px;
  min-width: 120px;
  width: auto;
}

.filter-price span {
  flex: 0 0 auto;
  font-weight: 600;
  font-size: 0.8rem;
  color: #b8a899;
  padding: 0 0.25rem;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.btn-reset {
  width: 100%;
  padding: 0.6rem 1rem;
  border-radius: 0.8rem;
  border: 1px dashed var(--search-border);
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease;
}

.btn-reset:hover {
  background: rgba(0, 0, 0, 0.04);
}

.global-search__results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 420px;
}

.suggestions-panel {
  background: rgba(247, 241, 234, 0.6);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--search-border);
  box-shadow: 0 10px 40px rgba(23, 18, 13, 0.08);
}

body.dark .suggestions-panel {
  background: rgba(18, 14, 11, 0.45);
}

.suggestions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.suggestions-list li {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--search-border);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.suggestions-list li:hover {
  background: var(--search-border);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  padding-right: 0.5rem;
}

.results-grid.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  color: #7a6758;
  font-weight: 600;
}

.result-card {
  border: 1px solid var(--search-border);
  border-radius: 1.2rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  background: #fffdfa;
  background-image: linear-gradient(160deg, rgba(139, 115, 85, 0.05), transparent);
}

body.dark .result-card {
  background: #1b1510;
  background-image: linear-gradient(160deg, rgba(193, 153, 112, 0.08), transparent);
}

.result-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

.result-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 0.8rem;
}

.result-card .price {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--search-primary);
}

.result-card .meta {
  font-size: 0.9rem;
  color: #7b6b5b;
}

body.dark .result-card .meta {
  color: #d0c2b7;
}

.result-card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.result-card .tag {
  padding: 0.2rem 0.5rem;
  border-radius: 0.6rem;
  background: rgba(139, 115, 85, 0.12);
  font-size: 0.75rem;
}

.result-card .cta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.result-card .cta a {
  text-decoration: none;
  font-weight: 600;
  color: var(--search-primary);
}

.search-empty {
  border: 1px dashed var(--search-border);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  color: #7a6758;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.search-empty.hidden {
  display: none;
}

.global-search__panel::-webkit-scrollbar,
.results-grid::-webkit-scrollbar {
  width: 6px;
}

.global-search__filters::-webkit-scrollbar {
  width: 4px;
}

.global-search__panel::-webkit-scrollbar-thumb,
.results-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.global-search__filters::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

@media (max-width: 1200px) {
  .global-search {
    padding: 0;
  }

  .global-search__panel {
    border-radius: 0;
    min-height: 100vh;
  }

  .results-grid {
    padding-right: 0;
  }
}

@media (max-width: 992px) {
  .global-search__body {
    grid-template-columns: 1fr;
  }

  .global-search__filters {
    border-right: none;
    border-bottom: 1px solid var(--search-border);
    padding-right: 0;
    padding-bottom: 1rem;
    margin-bottom: 1.2rem;
    max-height: none;
  }

  .global-search__meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .suggestions-panel {
    overflow-x: auto;
  }

  .suggestions-list {
    flex-wrap: nowrap;
  }
}

@media (max-width: 768px) {
  .global-search__panel {
    padding: 1rem;
    gap: 1.25rem;
  }

  .global-search__meta select {
    width: 100%;
  }

  .results-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

@media (max-width: 480px) {
  .global-search__input-wrapper {
    flex-direction: column;
    align-items: flex-start;
  }

  .global-search__input-wrapper input {
    width: 100%;
  }

  .global-search__meta {
    gap: 0.5rem;
  }

  .suggestions-list {
    flex-direction: column;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }
}

