/* Поиск, фильтры, теги и результаты. */

/* Строка поиска и её расположение на разных экранах. */
.searchwrap {
  border-radius: 11px;
  background: var(--soft);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 7px;

  @media (max-width: 760px) {
    padding-right: 3px;
  }

  @media (min-width: 761px) {
    padding: 0 14px;
    padding-right: 4px;
    gap: 5px;
  }

  &:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    border-radius: 14px;

    :where([data-layout="mobile"]) & {
      outline: 2px solid var(--accent);
      outline-offset: 0;
      border-radius: 14px !important;
    }
  }

  :where(body.dark) & {
    background: #262626;
  }

  :where([data-layout="mobile"]) & {
    margin-right: 0 !important;
    padding: 4px !important;
    border-radius: 14px !important;
    background: var(--soft) !important;
    box-shadow: none !important;
    border: 0 !important;
    min-height: 44px;
    display: flex !important;
    align-items: center !important;
    gap: 4px;
  }

  :where(body.mobile-search-active) & {
    :where([data-layout="mobile"]) & {
      margin-right: 48px !important;
      flex-shrink: 0;
    }
  }
}

.searchwrap span {
  font-size: 22px;
  color: var(--muted);

  @media (max-width: 760px) {
    font-size: 18px;
  }
}

#search {
  width: 100%;
  padding: 12px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 12px;

  @media (max-width: 760px) {
    padding: 8px 0;
    min-height: 44px;
  }

  @media (min-width: 761px) {
    min-height: 48px;
    font-size: 15px;
    min-width: 0;
    flex: 1;
  }

  &:focus {
    outline: none;

    :where([data-layout="mobile"]) & {
      outline: none !important;
      border-radius: 10px;
    }
  }

  :where([data-layout="mobile"]) & {
    font-size: 16px !important;
    padding: 6px 0 !important;
    min-height: 36px !important;
    order: 1;
    flex: 1 1 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    text-overflow: ellipsis;
  }
}

/* Поля фильтрации мест. */
.filters {
  display: flex;
  gap: 6px;
  margin-top: 9px;

  @media (max-width: 760px) {
    gap: 7px;
    margin-top: 7px;
  }
}

.filters select {
  min-width: 0;
  width: 44%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  padding: 7px 5px;
  font-size: 10px;

  @media (max-width: 760px) {
    min-height: 40px;
    font-size: 11px;
    padding: 8px 5px;
  }

  @media (min-width: 761px) {
    font-size: 12px;
    min-height: 39px;
  }

  :where([data-layout="mobile"]) & {
    font-size: 14px;
    min-height: 44px;
  }
}

.filters button {
  font-size: 19px;
  color: var(--muted);

  @media (max-width: 760px) {
    width: 36px;
    min-height: 40px;
  }
}

/* Фильтр актуальности мест. */
.freshfilter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  margin: 13px 0 4px;
  min-height: 32px;
  cursor: pointer;

  @media (max-width: 760px) {
    min-height: 38px;
    margin: 3px 0 0;
  }

  @media (min-width: 761px) {
    font-size: 13px;
  }

  :where([data-layout="mobile"]) & {
    min-height: 44px;
  }
}

.freshfilter input {
  appearance: none;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--muted);
  border-radius: 5px;
  margin: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: var(--panel);

  @media (max-width: 760px) {
    width: 20px;
    height: 20px;
  }
}

.freshfilter input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.freshfilter input:checked:after {
  content: "✓";
  color: #15250f;
  font-size: 12px;
  font-weight: bold;
}

.freshfilter small {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  background: var(--soft);
  padding: 3px 7px;
  border-radius: 5px;
}

/* Результаты поиска адреса при добавлении места. */
.addressResults {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.addressResults button {
  text-align: left;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 13px;
  background: var(--soft);
  min-height: 65px;
}

.addressResults button:hover {
  border-color: var(--accent);
}

.addressResults b {
  display: block;
  font-size: 13px;
}

.addressResults span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.addressResults small {
  display: block;
  font-size: 10px;
  margin-top: 7px;
}

.addressswitch {
  display: block;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--soft);
  border-radius: 8px;
  font-size: 11px;
  min-height: 40px;

  @media (max-width: 760px) {
    font-size: 12px;
    min-height: 44px;
  }
}

/* Кнопка открытия панели фильтров поиска. */
#filterToggle {
  position: relative;
  display: flex;
  place-items: center;
  flex: 0 0 auto;
  gap: 6px;
  width: auto;
  height: 44px;
  min-width: 0;
  min-height: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--onaccent);
  font-size: 13px;
  font-weight: 700;

  @media (min-width: 761px) {
    border: 1px solid var(--line);
  }

  :where([data-layout="mobile"]) & {
    order: 3;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 5px;
    width: 104px;
    padding: 8px;
    margin: 0;
    line-height: 1;
  }

  span {
    color: inherit;
    font-size: inherit;

    :where([data-layout="mobile"]) & {
      display: inline;
      position: static;
      margin: 0;
      padding: 0;
      font: inherit;
      line-height: 1;
    }
  }

  svg {
    display: block;
    pointer-events: none;

    :where([data-layout="mobile"]) & {
      flex: 0 0 16px;
      width: 16px;
      height: 16px;
    }
  }

  &.hasFilters::after {
    content: "";
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    position: absolute;
    top: 5px;
    right: 6px;
    margin: 0;
    vertical-align: baseline;
  }
}

/* Панель дополнительных фильтров. */
#filterPanel {
  display: none;
  position: absolute;
  top: 124px;
  left: 20px;
  right: 20px;
  padding: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  z-index: 24;
  box-shadow: 0 10px 35px #0003;

  @media (max-width: 760px) {
    top: 94px;
    left: 14px;
    right: 14px;
  }

  &.open {
    display: block;
  }

  @media (min-width: 761px) {
    top: calc(100% + 6px);
    left: auto;
    right: 0;
    width: 330px;
    max-width: calc(100vw - 30px);
  }

  :where([data-layout="mobile"]) & {
    top: auto !important;
    bottom: calc(100% + 10px) !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    z-index: 64;
  }

  :where(body.mobile-search-active) & {
    :where([data-layout="mobile"]) & {
      position: static !important;
      margin-top: 12px;
    }
  }
}

.filterPanel .filters {
  margin-top: 0;
}

.filterPanel .freshfilter {
  margin-top: 8px;

  @media (max-width: 760px) {
    min-height: 44px;
  }
}

.searchAddress {
  display: block;
  text-align: left;
  font-size: 11px;
  padding: 9px 7px;
  color: var(--ink);
  background: var(--accent-soft);
  border-radius: 8px;
  margin-top: 6px;
  min-height: 40px;
  width: 100%;

  @media (max-width: 760px) {
    min-height: 44px;
  }
}

/* Выбор тегов и отображение выбранных значений. */
.tagPicker {
  position: relative;
  margin-top: 14px;
}

.tagPicker > input {
  margin-top: 7px;

  @media (max-width: 760px) {
    font-size: 14px;
  }
}

.selectedTags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selectedTag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 5px 3px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12px;
  max-width: 100%;
  overflow-wrap: anywhere;

  @media (max-width: 760px) {
    font-size: 13px;
  }
}

.selectedTag button {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  min-width: 27px;
  min-height: 28px;
  font-size: 19px;
  border-radius: 6px;

  @media (max-width: 760px) {
    min-width: 36px;
    min-height: 36px;
  }
}

.selectedTag button:hover {
  background: var(--soft);
}

.tagCount {
  font-size: 10px;
  color: var(--muted);
  float: right;
}

.tagOptions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  background: var(--panel);
  box-shadow: 0 8px 24px #0003;
  max-height: 230px;
  overflow: auto;
  margin-top: 4px;

  @media (max-width: 760px) {
    max-height: 220px;
  }
}

.tagOptions button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  min-height: 50px;
  font-size: 12px;
  overflow-wrap: anywhere;

  @media (max-width: 760px) {
    min-height: 56px;
    font-size: 14px;
  }
}

.tagOptions button small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 2px;
}

.tagOptions button.highlighted {
  background: var(--accent-soft);
}

.tagOptions button:hover {
  background: var(--accent-soft);
}

.tagOptions button b {
  font-weight: 650;
}

.tagEmpty {
  padding: 13px 10px;
  font-size: 11px;
  color: var(--muted);
}

#tagHint {
  display: block;
  margin-top: 6px;
  font-size: 10px;
}

/* Выпадающий список результатов общего поиска. */
#globalResults {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 124px;
  z-index: 25;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 12px 36px #0004;
  border-radius: 13px;
  padding: 5px;
  max-height: 420px;
  overflow: auto;

  @media (max-width: 760px) {
    left: 14px;
    right: 14px;
    max-height: 290px;
    top: 94px;
  }

  &[aria-busy="true"] {
    opacity: 0.7;
  }

  @media (min-width: 761px) {
    left: 0;
    right: 0;
    max-height: 490px;
    top: calc(100% + 6px);
  }

  :where([data-layout="mobile"]) & {
    top: auto !important;
    bottom: calc(100% + 10px) !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 46dvh !important;
    z-index: 65;
  }

  :where(body.mobile-search-active) & {
    :where([data-layout="mobile"]) & {
      position: static !important;
      flex: 1;
      min-height: 0;
      max-height: none !important;
      margin-top: 12px;
      overflow: auto;
      border: 0;
      box-shadow: none;
      border-radius: 0;
    }
  }
}

.globalResults button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px;
  border-radius: 9px;
  min-height: 65px;

  @media (max-width: 760px) {
    min-height: 72px;
    padding: 12px;
  }

  @media (min-width: 761px) {
    min-height: 77px;
  }
}

.globalResults button b {
  display: block;
  font-size: 12px;

  @media (max-width: 760px) {
    font-size: 13px;
  }
}

.globalResults button span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;

  @media (max-width: 760px) {
    font-size: 11px;
  }
}

.globalResults button small {
  display: block;
  font-size: 10px;
  margin-top: 5px;
}

.globalResults button.highlighted {
  background: var(--accent-soft);
}

.globalResults button:hover {
  background: var(--accent-soft);
}

.globalSearchMessage {
  padding: 15px 11px;
  color: var(--muted);
  font-size: 12px;
}

.globalSearchCredit {
  padding: 8px 10px;
  font-size: 9px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* Область поиска в шапке на компьютере. */
#desktopSearchSlot {
  @media (min-width: 761px) {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 270px;
    max-width: none;
    gap: 0;
    margin: 0 20px;
  }

  @media (min-width: 761px) and (max-width: 1320px) {
    order: 1;
    flex: 1;
    max-width: none;
    min-width: 260px;
  }

  :where([data-layout="mobile"]) & {
    order: 3 !important;
    display: flex !important;
    flex-direction: column;
    gap: 0;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    flex: none !important;
    margin: 0 !important;
    position: relative;
  }

  :where(body.mobile-search-active) & {
    :where([data-layout="mobile"]) & {
      height: 100%;
      min-height: 0;
      display: flex !important;
      padding-right: 0;
    }
  }
}

.desktopSearchSlot .globalResults button b {

  @media (min-width: 761px) {
    font-size: 14px;
  }
}

.desktopSearchSlot .globalResults button span {

  @media (min-width: 761px) {
    font-size: 12px;
  }
}

.desktopSearchSlot .globalResults button small {

  @media (min-width: 761px) {
    font-size: 11px;
  }
}

.addressLoadStatus {
  font-size: 12px !important;
  min-height: 18px;
  color: var(--muted);
  margin: 7px 0 5px !important;
}

body.dark .selectedTag {
  border-color: #555555;
  background: #303030;
}

/* Панель фильтрации по тегам. */
.tagFilterBar {
  min-height: 54px;
  padding: 7px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 19;
  flex-wrap: wrap;

  @media (max-width: 760px) {
    padding: 7px 14px;
    gap: 7px;
  }

  @media (min-width: 761px) {
    flex-shrink: 0;
  }

  :where([data-layout="mobile"]) & {
    padding: 6px 0 0 !important;
    min-height: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }
}

.tagFilterTitle {
  font-size: 13px;
  font-weight: 650;

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

.tagFilterSearch {
  position: relative;
  width: 230px;
  min-width: 160px;

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

.tagFilterSearch > input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--soft);
  color: var(--ink);
  padding: 9px 12px;
  font-size: 13px;
  min-height: 38px;
}

.tagFilterOptions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 8px 30px #0004;
  max-height: 330px;
  overflow: auto;
}

.tagFilterOptions button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  width: 100%;
  text-align: left;
  min-height: 42px;
  padding: 9px;
  border-radius: 8px;
  font-size: 13px;
}

.tagFilterOptions button small {
  color: var(--muted);
  font-size: 10px;
}

.tagFilterOptions button.highlighted {
  background: var(--accent-soft);
}

.tagFilterOptions button:hover {
  background: var(--accent-soft);
}

.tagFilterChips {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;

  :where([data-layout="mobile"]) & {
    flex-wrap: nowrap;
    overflow: auto;
    max-width: 100%;
  }
}

.tagFilterChips button {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 12px;
  min-height: 35px;

  :where([data-layout="mobile"]) & {
    white-space: nowrap;
    flex-shrink: 0;
  }
}

.tagFilterChips button span {
  margin-left: 8px;
  font-size: 17px;
}

.tagFilterBar > small {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;

  @media (min-width: 761px) and (max-width: 1320px) {
    display: none;
  }

  @media (max-width: 760px) {
    display: none;
  }
}

.tagFilterBar > button {
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  min-height: 38px;
}

.addressAutocompleteLabel {
  position: relative;
}

/* Подсказки при вводе адреса. */
.addressAutocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  z-index: 8;
  background: var(--panel);
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 8px 24px #0004;
  max-height: 270px;
  overflow: auto;
}

.addressAutocomplete button {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 59px;
  padding: 10px;
  border-radius: 7px;
  font-size: 13px;
}

.addressAutocomplete button b {
  display: block;
  font-weight: 650;
}

.addressAutocomplete button span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.addressAutocomplete button.highlighted {
  background: var(--accent-soft);
}

.addressAutocomplete button:hover {
  background: var(--accent-soft);
}

body.dark .tagFilterChips button {
  background: #303030;
}

body.dark .globalResults button.highlighted {
  background: #303030;
}

body.dark .globalResults button:hover {
  background: #303030;
}

body.dark .tagFilterOptions button.highlighted {
  background: #303030;
}

body.dark .addressAutocomplete button.highlighted {
  background: #303030;
}

body.dark .tagOptions button.highlighted {
  background: #303030;
}

.desktopSearchSlot .tagFilterBar {

  @media (min-width: 761px) {
    min-height: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    border: 0;
    padding: 7px 0 0;
    background: transparent;
    z-index: auto;
  }
}

.desktopSearchSlot .tagFilterTitle {

  @media (min-width: 761px) {
    display: none;
  }
}

.desktopSearchSlot .tagFilterSearch {

  @media (min-width: 761px) {
    display: none;
  }
}

.desktopSearchSlot #tagFilterSummary {

  @media (min-width: 761px) {
    display: none;
  }
}

.desktopSearchSlot .tagFilterChips {

  @media (min-width: 761px) {
    gap: 5px;
  }
}

.desktopSearchSlot .tagFilterChips button {

  @media (min-width: 761px) {
    font-size: 11px;
    padding: 3px 8px;
    min-height: 28px;
  }
}

.desktopSearchSlot #clearTagFilter {

  @media (min-width: 761px) {
    font-size: 10px;
    min-height: 28px;
    padding: 3px 5px;
  }
}

.desktopSearchSlot .tagFilterChips button span {

  @media (min-width: 761px) {
    font-size: 15px;
    margin-left: 6px;
  }
}

.tagPicker .tagOptions {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  width: 100%;
  box-sizing: border-box;
  max-height: 230px;
  margin-top: 6px;
}

/* Область поиска на телефоне. */
#mobileSearchDock {
  display: none;

  :where([data-layout="mobile"]) & {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--m-nav);
    z-index: 56;
    background: var(--panel) !important;
    border: 0 !important;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -4px 20px #0001 !important;
    padding: 20px 12px 10px !important;
  }
}

.mobileSearchClose {
  display: none;
}

/* Кнопка очистки поискового запроса. */
#clearSearch {
  flex: 0 0 32px;
  width: 32px;
  height: 36px;
  min-height: 36px;
  min-width: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);

  &:hover {
    color: var(--ink);
    background: var(--soft);
  }

  &.hidden {
    display: none !important;
  }

  :where([data-layout="mobile"]) & {
    order: 2;
    display: grid;
    place-items: center;
    flex: 0 0 28px;
    min-width: 28px;
    width: 28px;
  }
}

/* Список мест, найденных по текущим фильтрам. */
.filteredPlaces {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
  margin-bottom: 12px;
}

.filteredPlaces .placeRow {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}

.filteredPlaces .placeRowAddress {
  display: block;
}

.globalResults .underEkatResultIcon {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 5px;
  vertical-align: -4px;
}

.underEkatResultIcon rect {
  fill: var(--accent);
}

.underEkatResultIcon path {
  fill: none;
  stroke: var(--onaccent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#tagFilterSummary {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

.tagFilterBar:has(.tagFilterChips:empty) {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

#mobileSearchDock .searchwrap > span {

  :where([data-layout="mobile"]) & {
    display: none;
  }
}

#mobileSearchDock .tagFilterBar {

  :where([data-layout="mobile"]) & {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    padding: 6px 8px !important;
    background: var(--panel);
    border: 1px solid var(--line) !important;
    border-radius: 12px;
    box-shadow: 0 6px 24px #0002;
    z-index: 1;
  }
}

#mobileSearchDock .tagFilterChips {

  :where([data-layout="mobile"]) & {
    flex-wrap: wrap;
  }
}

body:has(.selecting) #mobileSearchDock {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

#mobileSearchDock:before {

  :where([data-layout="mobile"]) & {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 4px;
    background: var(--line);
  }
}

body.mobile-search-active #mobileSearchDock {

  :where([data-layout="mobile"]) & {
    top: auto !important;
    bottom: var(--m-nav) !important;
    height: 62dvh;
    max-height: calc(100dvh - var(--m-nav) - 80px);
    display: flex !important;
    flex-direction: column;
    z-index: 80 !important;
    background: var(--panel) !important;
    padding: 20px 12px 12px !important;
  }
}

body.mobile-search-active .tagFilterBar {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

body.mobile-overlay-hidden-search #mobileSearchDock {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

body.mobile-search-active .mobileSearchClose {

  :where([data-layout="mobile"]) & {
    display: grid;
    place-items: center;
    position: absolute;
    right: 12px;
    top: 24px;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--soft);
    font-size: 28px;
    line-height: 1;
    z-index: 2;
  }
}

body.routing #mobileSearchDock {

  :where([data-layout="mobile"]) & {
    visibility: hidden;
  }
}
