/* =========================================================
   СТИЛИ ДЛЯ КАРТЫ (адаптированы под дизайн УЦИТ)
   ========================================================= */
.map-container-wrapper {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  height: 550px;
  min-height: 550px;
  background: #e5e7eb;
}
#yandexMapContainer { width: 100%; height: 100%; min-height: 550px; }

.branches-list-card {
  padding: 1rem;
  height: 100%;
  max-height: 550px;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
  border: 1px solid #f1f3f5;
}
.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: #e0ebf5; border-radius: 10px; }

/* Кнопка филиала в сайдбаре (адаптация под alert-secondary УЦИТ) */
.branch-item {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.branch-item:hover {
  background: #e9ecef;
  transform: translateX(3px);
  border-color: #ced4da;
}
.branch-item.active {
  background: #e0ebf5;
  border-color: #4080bf;
  box-shadow: 0 2px 8px rgba(64, 128, 191, 0.15);
}
.branch-item.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 10%;
  bottom: 10%;
  width: 3px;
  background: #4080bf;
  border-radius: 0 3px 3px 0;
}

.branch-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: white;
  color: #4080bf;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.branch-item.active .branch-item-icon {
  background: #4080bf;
  color: white;
}
.branch-item-content { flex: 1; min-width: 0; }
.branch-item-name {
  font-weight: 600;
  color: #212529;
  font-size: 0.95rem;
  margin-bottom: 0.1rem;
  line-height: 1.2;
}
.branch-item-address {
  font-size: 0.78rem;
  color: #6c757d;
  line-height: 1.3;
  margin: 0;
}

/* Кастомный балун */
.custom-balloon {
  font-family: inherit;
  max-width: 300px;
  pointer-events: auto;
}
.balloon-header {
  background: linear-gradient(135deg, #4080bf 0%, #2f6a9e 100%);
  color: white;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border-radius: 12px 12px 0 0;
  position: relative;
}
.balloon-title {
  font-weight: 700;
  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: #4080bf; }

.balloon-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.balloon-links { display: contents; }
.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: #4080bf;
  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: #2f6a9e; color: white; }
.balloon-btn--route { background: #6c757d; }
.balloon-btn--route:hover { background: #4080bf; }

.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); }

/* Легенда */
.map-legend {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 0.5rem 0.85rem;
  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: #4080bf; }
.map-legend-dot.green { background: #10b981; }

/* Заголовок сайдбара */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.85rem;
  border-bottom: 2px dashed #e0ebf5;
}
.sidebar-back-btn {
  background: #f1f3f5;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #4080bf;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.sidebar-back-btn:hover {
  background: #e0ebf5;
  color: #2f6a9e;
  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: #e0ebf5;
  color: #2f6a9e;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 800;
}

/* Карточка города */
.city-list-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.25s ease;
}
.city-list-item:hover {
  background: #e9ecef;
  border-color: #4080bf;
  transform: translateX(3px);
}
.city-list-item-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4080bf 0%, #2f6a9e 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(64, 128, 191, 0.25);
}
.city-list-item-content { flex: 1; min-width: 0; }
.city-list-item-name {
  font-weight: 700;
  color: #212529;
  font-size: 1rem;
  margin-bottom: 0.1rem;
}
.city-list-item-meta {
  font-size: 0.78rem;
  color: #6c757d;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.city-list-item-arrow {
  color: #adb5bd;
  font-size: 0.9rem;
  transition: transform 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}
.city-list-item:hover .city-list-item-arrow {
  color: #4080bf;
  transform: translateX(3px);
}

@keyframes resultPop {
  0% { opacity: 0; transform: scale(0.85) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Кнопка "Назад" на карте */
.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: #4080bf;
  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: #2f6a9e; }

@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; margin-top: 1.5rem; }
  .city-list-item { padding: 0.8rem 0.75rem; }
  .city-list-item-icon { width: 40px; height: 40px; font-size: 1rem; }
  .city-list-item-name { font-size: 0.95rem; }
}
@media (max-width: 575.98px) {
  .map-container-wrapper { height: 380px; min-height: 380px; }
  #yandexMapContainer { height: 380px; min-height: 380px; }
  .map-back-btn { padding: 0.6rem; }
  .map-back-text { display: none; }
  .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: static; margin-top: 1rem; justify-content: center; }
}
@media (max-width: 767.98px) {
  .map-legend { position: static; margin-top: 1rem; justify-content: center; }
}
