/* =========================
   ≤1300px
   ========================= */
@media (max-width: 1300px) {
  .section-map .container {
    padding: 24px !important;
  }
  .section-map__wrapp {
    gap: 24px !important;
  }
  .details-row {
    gap: 24px !important;
  }
}

/* =========================
   ≤1024px (планшети)
   ========================= */
@media (max-width: 1024px) {
  .section-map__wrapp {
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
    width: 100% !important;
  }

  /* Першим іде aside (контент) */
  .section-map__aside {
    order: 1 !important;
    width: 100% !important;
    height: auto !important;
  }

  /* Другим — карта */
  .section-map__frame,
  .section-map__map,
  .section-map .map,
  .section-map [data-role='map'] {
    order: 2 !important;
    width: 100% !important;
  }
}

/* =========================
   ≤768px (маленькі планшети / великі телефони)
   ========================= */
@media (max-width: 768px) {
  .section-map__aside {
    order: 1 !important;
  }

  .section-map__frame,
  .section-map__map,
  .section-map .map,
  .section-map [data-role='map'] {
    order: 2 !important;
  }

  .section-map__frame {
    max-height: 565px;
    border-radius: 8px;
    width: 100%;
    transition: margin-top 0.3s ease;
  }
}

@media (max-width: 1200px) {
  .services-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 12px;
    right: 12px;
    max-width: calc(100vw - 24px);
    height: auto;
    padding: 12px;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid #505050;
    background: #262626;
    display: none;
    z-index: 2500;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.18s, transform 0.18s, visibility 0s linear 0.18s;
    visibility: hidden;
    overflow: hidden;
    pointer-events: none;
  }

  .services-menu.is-open {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.18s, transform 0.18s;
    visibility: visible;
  }

  .services-menu__inner {
    height: 100%;
    width: 100%;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .services-menu__inner::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
}

/* =========================
   ≤600px (телефони)
   ========================= */
@media (max-width: 767px) {
  .section-map__head > :not(.section-map__title):not(.segmented),
  .section-map__wrapp > :not(.section-map__aside):not(.section-map__frame) {
    display: none !important;
  }

  .section-map .container {
    padding: 12px !important;
  }

  .section-map .container > * {
    margin-top: 12px !important;
    margin-bottom: 12px !important;
  }
  .section-map .container > :first-child {
    margin-top: 0 !important;
  }
  .section-map .container > :last-child {
    margin-bottom: 0 !important;
  }

  .section-map__head {
    text-align: left;
    align-items: self-start;
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 20px;
  }

  .section-map__title {
    line-height: 1.2;
    letter-spacing: -0.01em;
  }

  .section-map__wrapp {
    display: flex !important;
    flex-direction: column;
    gap: 16px;
    width: 100%;
  }

  .aside__refresh,
  .chip,
  .location-input,
  .project__link,
  .project__title {
    font-size: 14px;
  }

  .segmented {
    width: 100% !important;
    box-sizing: border-box !important;
    height: 48px;
    margin-left: 0;
  }

  .segmented__btn {
    padding: 10px;
    font-size: 14px;
  }

  .segmented__btn-text {
    height: 20px;
  }

  .section-map__cities {
    display: none;
  }

  .chips {
    gap: 8px;
  }

  .chip {
    padding: 8px 10px;
  }

  .section-map__aside {
    order: 1;
    width: 100%;
    height: auto;
    padding: 12px 4px;
    border-radius: 8px;
    background: var(--aside-bg, #262626);
    overflow: visible;
    z-index: 1;
  }

  .section-map__frame {
    order: 2;
    width: 100%;
    max-height: 565px;
    border-radius: 8px;
  }

  .aside__inner {
    gap: 0;
  }

  .aside__top {
    padding: 0 12px;
    margin-bottom: 12px;
  }

  .aside__left svg {
    width: 18px;
    height: 18px;
  }

  .aside__promo {
    margin: 0 12px 12px;
  }

  .aside__promo-img {
    width: 100%;
    height: auto;
  }

  .aside__actions {
    position: relative;
    overflow: visible;
    z-index: 20;
  }

  .section-areas .tabs-nav__btn {
    width: 100%;
  }
  .section-areas .tabs-nav__btn span {
    font-size: 14px;
    min-width: 90px;
  }

  /* Кнопки в aside */
  .aside__actions .action-btn {
    display: inline-flex;
    min-width: 44px;
    height: 44px;
    padding: 10px;
    border-radius: 12px;
    justify-content: center;
    align-items: center;
    gap: 0;
  }

  .aside__actions .action-btn .ico--primary,
  .action-btn--menu {
    display: inline-flex !important;
  }

  .aside__actions .action-btn.is-open .ico--close {
    display: none !important;
  }

  .aside__actions .action-btn > span:not(.ico) {
    display: none !important;
  }

  .aside__actions .action-btn .ico svg {
    width: 20px;
    height: 20px;
  }

  .aside__cta,
  .cta-btn {
    width: auto;
    height: 48px;
    box-sizing: border-box;
    margin: 0;
    margin-bottom: 15px;
  }

  .location-menu__row,
  .services-item {
    width: 100%;
  }

  .services-item__head {
    width: calc(100% - 12px);
  }

  .separator {
    width: calc(100% - 24px);
    margin: 10px 12px;
  }

  .services-scrollbar {
    position: absolute;
    top: 12px;
    right: 6px;
    width: 6px;
    height: calc(100% - 24px);
    display: flex;
    align-items: flex-start;
    border-radius: 5px;
    border: 1px solid #505050;
    background: #262626;
    z-index: 1;
    pointer-events: none;
  }

  .services-scrollbar__active {
    width: 100%;
    border-radius: 5px;
    background: #2e7bb2;
  }

  /* Список проєктів */
  .aside__list {
    width: 100%;
    max-height: 340px;
    padding-right: 0;
  }

  .project {
    gap: 6px;
    margin-bottom: 12px;
  }

  .project__img {
    height: 160px;
    border-radius: 10px;
  }

  .project__title {
    line-height: 20px;
  }

  .scrollbar {
    height: 100%;
    box-sizing: border-box;
  }

  .location-menu {
    left: 12px;
    right: 12px;
    max-width: calc(100vw - 24px);
    max-height: none;
    border-radius: 10px;
  }

  .location-input {
    width: 100%;
    line-height: 22px;
    padding: 10px;
  }

  .location-submit {
    width: 44px;
    height: 44px;
    padding: 10px;
  }
}

@media (max-width: 560px) {
  /* Media tags layout for mobile */
  .media-tags {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    align-items: start;
    gap: 8px;
  }

  .media-chip {
    padding: 5px 7px;
  }

  .media-chip-wrapper:nth-child(1),
  .media-chip-wrapper:nth-child(2) {
    grid-column: 1;
  }

  .media-chip-wrapper--last {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    margin-left: 0;
  }
}

.action-btn--menu {
  display: inline-flex;
  align-items: center;
}

@media (min-width: 1024px) {
  .action-btn--menu {
    display: none;
  }
}
@media (max-width: 1024px) {
  .section-map__aside {
    background: transparent;
    box-shadow: none;
    padding: 0;
  }
  .aside__inner {
    padding: 0;
  }
  .aside-card {
    background: #262626;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  }

  /* --- 💡 ОСЬ ВИПРАВЛЕННЯ 💡 --- */

  .aside-card--bottom {
    /* 1. ВСТАНОВЛЮЄМО ВІДСТУП В 0, КОЛИ БЛОК ЗАКРИТИЙ */
    margin-top: 0; /* Було 12px */

    background: transparent;
    box-shadow: none;
    padding: 0;

    opacity: 0;
    visibility: hidden;
    max-height: 0;
    overflow: hidden;

    /* 'margin-top' тепер теж буде плавно анімуватись */
    transition: opacity 0.3s ease, visibility 0.3s ease, max-height 0.3s ease, margin-top 0.3s ease;
  }

  .aside-card--bottom.is-open {
    opacity: 1;
    visibility: visible;
    max-height: 400px; /* Або можна 'max-content', якщо не потрібна анімація висоти */
    background: #262626;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    padding: 16px;

    /* 2. ДОДАЄМО ВІДСТУП ТІЛЬКИ У ВІДКРИТОМУ СТАНІ */
    margin-top: 20px;
  }
  #asideScroll.is-open {
    max-height: 370px;
  }

  /* 3. Цей дублюючий блок більше не потрібен
  .aside-card--bottom {
    margin-top: 12px;
  }
  */
}
/* Desktop */
@media (min-width: 1024px) {
  .aside-card--bottom {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease, max-height 0.3s ease;
  }

  .panel-is-open .aside-card--bottom {
    opacity: 1;
    visibility: visible;
    max-height: 100%; /* достатньо велике значення */
  }
}
