/* =========================================================
   СЕКЦИЯ «ГДЕ МЫ НАХОДИМСЯ» (Яндекс.Карта)
   ========================================================= */
.map-container-wrapper {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  height: 500px;
  min-height: 500px;
  background: #e5e7eb;
}

#yandexMapContainer {
  width: 100%;
  height: 100%;
  min-height: 500px;
}

/* ---------- Карточка бокового меню ---------- */
.branches-list-card {
  padding: 1.5rem;
  height: 100%;
  max-height: 500px;
  overflow-y: auto;
}

.branches-list-card::-webkit-scrollbar { width: 6px; }
.branches-list-card::-webkit-scrollbar-track { background: #f1f3f5; border-radius: 10px; }
.branches-list-card::-webkit-scrollbar-thumb { background: #dbeafe; border-radius: 10px; }

/* ---------- Список филиалов ---------- */
.branch-item {
  display: flex;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: 12px;
  background: #f8f9fa;
  border: 2px solid transparent;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.branch-item:hover {
  background: #e9ecef;
  transform: translateX(4px);
}

.branch-item.active {
  background: #dbeafe;
  border-color: #1e3a8a;
  box-shadow: 0 4px 14px rgba(30, 58, 138, 0.15);
}

.branch-item.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 10%;
  bottom: 10%;
  width: 4px;
  background: #dc3545;
  border-radius: 0 4px 4px 0;
}

.branch-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: white;
  color: #dc3545;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.branch-item.active .branch-item-icon {
  background: #dc3545;
  color: white;
}

.branch-item-content {
  flex: 1;
  min-width: 0;
}

.branch-item-name {
  font-weight: 700;
  color: #212529;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.branch-item-address {
  font-size: 0.85rem;
  color: #6c757d;
  line-height: 1.3;
  margin: 0;
}

/* ---------- Кастомный балун ---------- */
.custom-balloon {
  font-family: inherit;
  max-width: 300px;
}

.balloon-header {
  background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%);
  color: white;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border-radius: 12px 12px 0 0;
  position: relative;
}

.balloon-title {
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 0.15rem;
  line-height: 1.2;
}

.balloon-address {
  font-size: 0.78rem;
  opacity: 0.9;
  line-height: 1.3;
}

.balloon-body {
  padding: 0.85rem 1rem;
  background: white;
  border: 1px solid #e9ecef;
  border-top: none;
  border-radius: 0 0 12px 12px;
  position: relative;
}

.balloon-desc {
  font-size: 0.82rem;
  color: #495057;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.balloon-desc b { color: #dc3545; }

/* Новая сетка для кнопок 2х2 */
.balloon-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.balloon-links {
  display: contents; /* Позволяет детям напрямую участвовать в grid родителя */
}

/* Кнопка загрузки и "пусто" на всю ширину */
.balloon-loading,
.balloon-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #6c757d;
  padding: 0.4rem 0;
}

.balloon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: #1e3a8a;
  color: white;
  padding: 0.55rem 0.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  cursor: pointer;
}

.balloon-btn:hover {
  background: #dc3545;
  color: white;
}

.balloon-btn--route { background: #6c757d; }
.balloon-btn--route:hover { background: #dc3545; }

/* Кнопка закрытия (крестик) */
.balloon-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.3);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.2s;
}
.balloon-close-btn:hover {
  background: rgba(255,255,255,0.5);
}

/* Мобильная адаптация балуна */
@media (max-width: 575.98px) {
  .custom-balloon {
    max-width: 260px !important;
    top: 65px !important;
    right: 10px !important;
  }

  .balloon-actions {
    gap: 0.3rem;
  }

  .balloon-btn {
    font-size: 0.72rem;
    padding: 0.5rem 0.3rem;
    gap: 0.25rem;
  }

  .balloon-btn i {
    font-size: 0.8rem;
  }
}

/* ---------- Легенда маркеров ---------- */
.map-legend {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  font-size: 0.75rem;
  z-index: 10;
  display: flex;
  gap: 0.85rem;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #495057;
  font-weight: 600;
}

.map-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.map-legend-dot.red { background: #dc3545; }
.map-legend-dot.blue { background: #1e3a8a; }
.map-legend-dot.green { background: #10b981; }

/* =========================================================
   БОКОВОЕ МЕНЮ: ГОРОДА → ФИЛИАЛЫ
   ========================================================= */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
  border-bottom: 2px dashed #dbeafe;
}

.sidebar-back-btn {
  background: #f1f3f5;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-back-btn:hover {
  background: #dbeafe;
  color: #dc3545;
  transform: translateX(-2px);
}

.sidebar-title {
  flex: 1;
  font-size: 0.85rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-title .count-badge {
  background: #dbeafe;
  color: #1e3a8a;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 800;
}

/* ---------- Список городов ---------- */
.city-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1rem;
  border-radius: 14px;
  background: #f8f9fa;
  border: 2px solid transparent;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.city-list-item:hover {
  background: #e9ecef;
  border-color: #dbeafe;
  transform: translateX(4px);
}

.city-list-item-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.25);
}

.city-list-item-content {
  flex: 1;
  min-width: 0;
}

.city-list-item-name {
  font-weight: 700;
  color: #212529;
  font-size: 1.1rem;
  margin-bottom: 0.15rem;
}

.city-list-item-meta {
  font-size: 0.82rem;
  color: #6c757d;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.city-list-item-arrow {
  color: #adb5bd;
  font-size: 0.95rem;
  transition: transform 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.city-list-item:hover .city-list-item-arrow {
  color: #dc3545;
  transform: translateX(4px);
}

/* =========================================================
   Анимация появления popup (дубликат из league_form.css —
   нужна балуну карты независимо от файла формы)
   ========================================================= */
@keyframes resultPop {
  0% { opacity: 0; transform: scale(0.85) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* =========================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ КАРТЫ
   ========================================================= */
@media (max-width: 991.98px) {
  .map-container-wrapper { height: 450px; min-height: 450px; }
  #yandexMapContainer { height: 450px; min-height: 450px; }
  .branches-list-card { max-height: none; }
  .city-list-item { padding: 0.95rem 0.85rem; }
  .city-list-item-icon { width: 42px; height: 42px; font-size: 1.1rem; }
  .city-list-item-name { font-size: 1rem; }
}

@media (max-width: 575.98px) {
  .map-container-wrapper { height: 380px; min-height: 380px; }
  #yandexMapContainer { height: 380px; min-height: 380px; }
}

@media (max-width: 767.98px) {
  .map-legend {
    position: static;
    margin-top: 1rem;
    justify-content: center;
  }
}

/* ---------- Кнопка "Назад" на карте ---------- */
.map-back-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 20; /* Поверх карты и маркеров */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: none;
  border-radius: 10px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #1e3a8a;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  cursor: pointer;

  /* Состояние по умолчанию (скрыта) */
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease, color 0.2s ease;
}

.map-back-btn.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.map-back-btn:hover {
  background: white;
  color: #dc3545;
}

/* На мобильных скрываем текст, оставляем только иконку стрелки */
@media (max-width: 575.98px) {
  .map-back-btn {
    padding: 0.6rem;
  }
  .map-back-text {
    display: none;
  }
}
