/**
 * Стили для интерактивной карты регионов РФ
 * GetPravo - Карта партнёров
 */

.rf-map,
.rf-map * {
    box-sizing: border-box;
}

.rf-map {
    position: relative;
    max-width: 1020px;
    margin: auto;
    padding: 20px;
}

/* Блок с названием региона */
.rf-map .district b {
    position: absolute;
    z-index: 5;
    width: 18px;
    height: 18px;
    background: rgba(51, 122, 183, 0.9);
    border-radius: 50%;
    left: 6px;
    top: 18px;
    transition: all 0.3s;
}

.rf-map .district span {
    position: absolute;
    z-index: 5;
    top: 20px;
    left: 30px;
    font-size: 13px;
    font-weight: bold;
    font-family: 'Montserrat', Tahoma, sans-serif;
    line-height: 1;
    color: #337AB7;
}

.rf-map .district {
    display: none;
}

.rf-map.open .district b {
    top: 0;
    left: 0;
    border-radius: 0;
    width: 100%;
    height: 100%;
}

.rf-map.open .district span {
    display: none;
}

/* SVG карта */
.rf-map svg {
    width: 100%;
    height: 100%;
}

.rf-map path {
    stroke: #FFFFFF;
    stroke-width: 1;
    stroke-linejoin: round;
    transition: stroke .3s ease, filter .3s ease, transform .3s ease;
}

/* Стили по умолчанию для регионов без партнёров */
.rf-map [data-code] {
    fill: #337AB7;
    transition: fill 0.2s;
}

.rf-map [data-code]:hover {
    fill: #0180ef;
}

/* Регион с партнёрами - активный */
.rf-map [data-code].region-active {
    cursor: pointer;
    transition: fill .4s ease, stroke .3s ease;
}

/* Выделение границ региона при наведении на легенду — реализовано через inline style в JS */

/* Подсветка элемента легенды при наведении на регион карты */
.rf-map .district-links div.legend-item-hover {
    color: #fff !important;
    background: linear-gradient(135deg, #1a3a5c, #2c5282) !important;
    border-color: #2c5282 !important;
    box-shadow: 0 4px 12px rgba(44, 82, 130, .35);
    transition: all .3s ease;
}

/* Регион без партнёров - неактивный */
.rf-map [data-code].region-inactive {
    fill: #94a3b8 !important;
    cursor: default;
    opacity: 0.6;
}

.rf-map [data-code].region-inactive:hover {
    fill: #94a3b8 !important;
}

/* Текст информации о регионе */
.rf-map .district-text {
    display: none;
    position: absolute;
    z-index: 6;
    left: 0;
    top: 15px;
    width: calc(100% - 20px);
    height: calc(100% - 45px);
    padding: 0 20px;
    overflow: auto;
    color: #FFF;
    font-size: 13px;
    font-family: 'Montserrat', Verdana, sans-serif;
}

/* Кнопка закрытия */
.rf-map .close-district {
    opacity: 0;
    z-index: 10;
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    line-height: 1;
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    transition: opacity 1s;
    pointer-events: none;
}

.rf-map.open .close-district {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

.rf-map .close-district:hover {
    color: #ffd700;
    transform: scale(1.15);
    transition: opacity 0.3s, color 0.2s, transform 0.2s;
}

/* Ссылки на регионы (легенда) */
.rf-map .district-links {
    margin-top: 12px;
    padding: 0 12px 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    position: relative;
    z-index: 10;
}

.rf-map .district-links div {
    font-size: .78rem;
    font-weight: 600;
    font-family: 'Open Sans', Verdana, sans-serif;
    padding: 6px 14px;
    cursor: pointer;
    transition: all .2s ease;
    background: linear-gradient(135deg, rgba(26,58,92,.08), rgba(44,82,130,.08));
    border-radius: 20px;
    border: 1px solid rgba(26,58,92,.2);
    color: #1a3a5c;
    position: relative;
    z-index: 1;
    letter-spacing: .01em;
}

.rf-map .district-links div:hover {
    color: #fff !important;
    background: linear-gradient(135deg, #1a3a5c, #2c5282) !important;
    border-color: #1a3a5c !important;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(26,58,92,.3);
    transform: translateY(-1px);
}

.rf-map .district-links div:after {
    content: "";
}

/* Скрываем ссылки на города когда панель региона открыта */
.rf-map.open .district-links {
    display: none !important;
}



/* Состояния при открытии региона */
.dropfill {
    fill: #337AB7 !important;
}

.mainfill {
    fill: #1d4567 !important;
}

/* Адаптивность для мобильных — увеличение карты при выборе региона */
@media (max-width: 767.98px) {
    .rf-map.open {
        min-height: 600px;
    }

    .rf-map.open svg {
        display: none;
    }

    .rf-map.open .district b {
        min-height: 600px;
    }

    .rf-map.open .district-text {
        top: 15px;
        height: calc(100% - 40px);
        max-height: calc(100% - 40px);
        width: calc(100% - 20px);
        font-size: 14px;
        padding: 0 15px 15px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Видимая полоса прокрутки на мобильных */
    .rf-map.open .district-text::-webkit-scrollbar {
        width: 5px;
    }
    .rf-map.open .district-text::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 3px;
    }
    .rf-map.open .district-text::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.35);
        border-radius: 3px;
    }
    .rf-map.open .district-text::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.55);
    }

    .rf-map.open .close-district {
        width: 36px;
        height: 36px;
        font-size: 32px;
        top: 8px;
        right: 8px;
    }

    .rf-map.open .district span {
        display: none;
    }

    .partner-card {
        padding: 7px 8px;
    }

    .partner-card .partner-avatar {
        width: 32px;
        height: 32px;
    }

    .partner-card .partner-name {
        font-size: 0.84rem;
    }

    .partner-card .partner-position {
        font-size: 0.72rem;
    }

    .region-header h4 {
        font-size: 1rem;
    }
}

/* Адаптивность для планшетов и десктопов */
@media (min-width: 768px) {
    .rf-map .district b {
        width: 28px;
        height: 28px;
        left: 6px;
        top: 28px;
    }

    .rf-map .district span {
        top: 30px;
        left: 46px;
        font-size: 20px;
        font-weight: normal;
    }

    .rf-map .district-text {
        left: 30px;
        top: 20px;
        width: calc(100% - 60px);
        height: calc(100% - 50px);
        font-size: 16px;
    }

    .rf-map .close-district {
        width: 60px;
        height: 60px;
        font-size: 60px;
    }

    .rf-map .district-links {
        display: flex;
        margin-top: 15px;
        justify-content: center;
        flex-wrap: wrap;
        gap: 5px;
    }
}

/* ===== Карточка партнёра внутри региона ===== */
.partner-card {
    background: rgba(255, 255, 255, 0.10);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    transition: background .25s ease, transform .32s cubic-bezier(0.22, 1, 0.36, 1), box-shadow .32s cubic-bezier(0.22, 1, 0.36, 1), border-color .25s ease;
    overflow: hidden;
    animation: partnerCardIn .35s ease both;
}

@keyframes partnerCardIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.partner-card:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(26, 58, 92, 0.16);
    border-color: rgba(255, 255, 255, 0.22);
}

.partner-card .partner-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
    transform: none !important;
    transition: box-shadow .25s ease, border-color .25s ease;
}

.partner-card:hover .partner-avatar {
    transform: none !important;
    box-shadow: none;
}

.partner-card .partner-name {
    font-weight: 700;
    font-size: .88rem;
    margin-bottom: 1px;
    line-height: 1.25;
    color: #fff;
}

.partner-card .partner-name a {
    color: #fff;
    text-decoration: none;
    transition: color .2s;
}

.partner-card .partner-name a:hover {
    color: #fde68a;
}

.partner-card .partner-position {
    font-size: .75rem;
    font-weight: 600;
    color: #fde68a;
    margin-bottom: 4px;
    letter-spacing: .01em;
}

.partner-card .partner-contacts {
    font-size: .76rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.partner-card .partner-contacts a {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    display: flex;
    align-items: flex-start;
    gap: 5px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    transition: color .2s;
    padding: 1px 0;
}

.partner-card .partner-contacts a:hover {
    color: #fff;
}

.partner-card .partner-contacts i {
    flex-shrink: 0;
    width: 13px;
    text-align: center;
    font-size: .76rem;
    margin-top: 1px;
    opacity: .85;
}

/* Ссылка «Открыть профиль» */
.partner-profile-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: .73rem;
    font-weight: 700;
    color: #fde68a;
    text-decoration: none;
    letter-spacing: .03em;
    transition: color .2s, gap .2s;
}
.partner-profile-link:hover {
    color: #fff;
    gap: 7px;
}

/* Заголовок региона */
.region-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.region-header h4 {
    margin: 0;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    letter-spacing: -.01em;
}

.region-header .partner-count {
    font-size: .76rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    margin-top: 2px;
    display: block;
}

/* ===== Цвета регионов ===== */
.rf-map [data-code="RU-SAR"] {
    fill: #116f21;
    cursor: pointer;
}

.rf-map [data-code="RU-SA"] {
    fill: #d17520;
    cursor: pointer;
}

.rf-map [data-code="RU-KO"] {
    fill: #901aad;
}

.rf-map [data-code="RU-SAR"]:hover {
    fill: #1bad33;
}

.rf-map [data-code="RU-SA"]:hover {
    fill: #e3954b;
}

.rf-map [data-code="RU-KO"]:hover {
    fill: #bf37e1;
}

/* Золотой цвет должности партнёра на карте */
.rf-map .district-text .partner-card .partner-position {
    color: #fde68a !important;
}

.map-phone-text::before {
    content: attr(data-phone-display);
}
