/* ============================================================
   Карта партнеров — стили
   ============================================================ */

/* ---- Обёртка карты и фильтров ---- */
.partners-map-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 30px 0;
  font-family: inherit;
  position: relative;
  z-index: 1;
}

/* ---- Панель фильтров ---- */
.partners-filters {
  position: relative;
  z-index: 10;                /* выше, чем у карты */
  flex: 0 0 280px;
  background: #f7f8fa;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  align-self: flex-start;
}

.partners-filters h3 {
  margin: 0 0 15px;
  font-size: 18px;
  color: #1a1a1a;
}

.partners-filters label {
  display: block;
  margin-top: 14px;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.partners-filters select,
.partners-filters input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.partners-filters select:focus,
.partners-filters input[type="text"]:focus {
  border-color: #0066cc;
  outline: none;
}

.partners-filters .reset-btn {
  margin-top: 18px;
  width: 100%;
  padding: 10px;
  background: #0066cc;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.partners-filters .reset-btn:hover {
  background: #0052a3;
}

/* ---- Контейнер карты ---- */
.partners-map-container {
  position: relative;
  z-index: 1;                 /* ниже, чем у фильтров */
  overflow: hidden;           /* не даёт карте "вылезать" */
  flex: 1;
  min-width: 300px;
  height: 600px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

#partners-map {
  width: 100%;
  height: 100%;
  background: #e8e8e8;
  /* ✅ Критично для мобильных: разрешаем pan и pinch-zoom внутри карты,
     даже если meta viewport ограничивает масштабирование страницы */
  touch-action: pan-x pan-y pinch-zoom;
}

/* ---- Скрываем только префикс "Leaflet" (OSM-атрибуция остается по лицензии) ---- */
.leaflet-control-attribution a[href*="leafletjs.com"] {
  display: none;
}
.leaflet-control-attribution::before {
  content: "";
}

/* ---- Кастомный маркер: красная лошадка ---- */
.horse-marker {
  background: transparent !important;
  border: none !important;
}

/* ============================================================
   КЛАСТЕРЫ МАРКЕРОВ
   Красный круг с числом внутри (в стиле Яндекс.Карт)
   ============================================================ */

/* Обёртка кластера, которую создаёт MarkerCluster по умолчанию.
   Мы перекрываем её фоновые стили своими. */
.custom-cluster-icon {
  background: transparent !important;
  border: none !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

/* Внутренний круг с числом */
.custom-cluster-icon .cluster-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(220, 20, 60, 0.9); /* насыщенный красный */
  color: #fff;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  transition: background 0.2s ease, transform 0.15s ease;
  box-sizing: border-box;
}

.custom-cluster-icon:hover .cluster-inner {
  background: rgba(180, 12, 46, 1);
  transform: scale(1.06);
}

/* Размеры шрифта под размер кластера */
.custom-cluster-icon.cluster-small .cluster-inner {
  font-size: 14px;
}
.custom-cluster-icon.cluster-medium .cluster-inner {
  font-size: 16px;
}
.custom-cluster-icon.cluster-large .cluster-inner {
  font-size: 18px;
}

/* Плавное появление кластеров */
.leaflet-marker-icon.custom-cluster-icon {
  animation: clusterFadeIn 0.25s ease-out;
}
@keyframes clusterFadeIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* Скрываем стандартное оформление MarkerCluster.Default.css,
   чтобы не было "синих" кластеров */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: transparent !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: transparent !important;
}

/* ---- Попап ---- */
.leaflet-popup-content {
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  min-width: 220px;
}

.leaflet-popup-content strong {
  display: block;
  margin-bottom: 6px;
  color: #1a1a1a;
  font-size: 15px;
}

.leaflet-popup-content .partner-meta {
  color: #666;
  font-size: 13px;
  margin-bottom: 6px;
}

.leaflet-popup-content .partner-phone {
  color: #0066cc;
  font-weight: 600;
  margin-bottom: 6px;
}

/* ---- Кнопка "Перейти на сайт" ---- */
.leaflet-popup-content .partner-website {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 12px;
  background: #cc0000;
  color: #fff !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.2s;
}

.leaflet-popup-content .partner-website:hover {
  background: #a30000;
  color: #fff !important;
}

/* ============================================================
   АДАПТИВ
   ============================================================ */

@media (max-width: 768px) {
  .partners-map-wrapper {
    flex-direction: column;
  }

  .partners-filters {
    flex: none;
    width: 100%;
  }

  /* ✅ КЛЮЧЕВОЕ ИСПРАВЛЕНИЕ:
     В column-режиме `flex: 1` = `flex-basis: 0%`, что ОБНУЛЯЕТ высоту
     контейнера, несмотря на `height: 450px`.
     Поэтому сбрасываем flex и явно возвращаем flex-basis: auto. */
  .partners-map-container {
    flex: none;
    flex-basis: auto;
    width: 100%;
    min-width: 0;
    height: 450px;
  }

  /* Уменьшаем новогодний баннер на мобильных, чтобы он не перекрывал карту */
  .a_newyear {
    height: 60px;
    background-size: contain;
    background-position: center bottom;
  }
}

/* Очень узкие экраны (айфоны в портретной ориентации) */
@media (max-width: 480px) {
  .partners-map-container {
    height: 380px;
  }
}

/* ===== Кнопка-баннер с изображением ===== */
.promo-button {
  display: block;
  margin-top: 18px;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  cursor: pointer;
  line-height: 0;
}

.promo-button img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  object-fit: cover;
}

.promo-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.promo-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .promo-button {
    margin-top: 14px;
  }
}

/* ✅ Правильное отображение векторного слоя MapLibre внутри Leaflet */
.leaflet-maplibre-gl {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
}

.leaflet-maplibre-gl .maplibregl-canvas {
    outline: none;
}

.leaflet-marker-pane,
.leaflet-popup-pane {
    z-index: 600;
}

.leaflet-control-container {
    z-index: 800;
}