/* info panel */
.rusnetim-info-panel {
    position: relative;
    box-sizing: border-box;
    overflow-y: auto;
}
.rusnetim-info-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.9);
    border: 1px solid #ccc;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2000;
    color: #333;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    padding: 0;
    box-sizing: border-box;
}
.rusnetim-gallery {
    margin-bottom: 15px;
}
.rusnetim-gallery-main {
    margin-bottom: 10px;
}
.rusnetim-gallery-main a {
    display: block;
    cursor: pointer;
}
.rusnetim-gallery-main img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}
.rusnetim-gallery-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.gallery-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}
.gallery-thumb.active-thumb {
    border-color: #1e98ff;
}

/* lightbox */
.rusnetim-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rusnetim-lightbox .rusnetim-lightbox-container {
    position: relative;
    width: 90vw;
    height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rusnetim-lightbox img {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
    display: block;
    object-fit: contain !important;
    border-radius: 4px;
}
.rusnetim-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 40px;
    cursor: pointer;
    line-height: 1;
}
.rusnetim-lightbox-prev,
.rusnetim-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 40px;
    cursor: pointer;
    user-select: none;
    background: rgba(0,0,0,0.5);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 100001;
    transition: background 0.2s;
}
.rusnetim-lightbox-prev:hover,
.rusnetim-lightbox-next:hover {
    background: rgba(0,0,0,0.8);
}
.rusnetim-lightbox-prev {
    left: 20px;
}
.rusnetim-lightbox-next {
    right: 20px;
}

/* cluster list */
.rusnetim-cluster-list h3 {
    margin: 0 0 10px;
}
.rusnetim-cluster-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.rusnetim-cluster-item {
    padding: 5px 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}
.rusnetim-cluster-item:hover {
    background: #f5f5f5;
}
.rusnetim-cluster-item-name {
    display: block;
}

/* category filter base styles (dynamic colors will be added inline) */
.rusnetim-category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}
.rusnetim-cat-btn {
    display: inline-block;
    cursor: pointer;
    border: none;
    background: none;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}
.rusnetim-cat-group {
    margin-bottom: 10px;
}
.rusnetim-cat-group-title {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 1.1em;
}
.rusnetim-cat-group .rusnetim-cat-btn {
    margin-right: 8px;
    margin-bottom: 5px;
}
/* Обычный select для фильтра категорий (если не используется nice-select) */
.rusnetim-native-select {
    display: block !important;
    width: 100%;
    max-width: 300px;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}
.rusnetim-native-select:hover {
    border-color: #888;
}
.rusnetim-native-select:focus {
    border-color: #1e98ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(30,152,255,0.2);
}
.rusnetim-cat-select {
    display: block !important;
    width: 100%;
    max-width: 300px;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
}
.rusnetim-cat-select:hover {
    border-color: #888;
}
.rusnetim-cat-select:focus {
    border-color: #1e98ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(30,152,255,0.2);
}
.rusnetim-category-filter .nice-select {
    display: none !important;
}
.rusnetim-category-filter select.rusnetim-cat-select {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ===== FIX: обёртка фильтра и кнопки избранного ===== */
.rusnetim-filter-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

/* Контейнер кнопок категорий – занимает всё свободное место для работы justify-content */
.rusnetim-category-filter {
    flex: 1;
    margin-bottom: 0; /* убираем лишний нижний отступ, так как он есть у обёртки */
}

/* Кнопка "Избранное" – без margin-left: auto */
.rusnetim-favorites-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: inherit;
    flex-shrink: 0;
}
.rusnetim-favorites-btn:hover {
    background: #f0f0f0;
}
.rusnetim-favorites-btn.active {
    background: #1e98ff;
    border-color: #1e98ff;
    color: #fff;
}
.rusnetim-favorites-count {
    background: #f44336;
    color: white;
    border-radius: 12px;
    padding: 0 6px;
    font-size: 0.8em;
    margin-left: 4px;
}
.rusnetim-fav-toggle .heart {
    font-size: 1.2em;
}

/* ===== Панель действий (Избранное + Печать) ===== */
.rusnetim-panel-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    margin-right: 40px; /* отступ, чтобы не залезать под кнопку закрытия */
}
.rusnetim-favorite-action,
.rusnetim-print-action {
    margin: 0;
}
.rusnetim-print-btn {
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.rusnetim-print-btn:hover {
    background: #e0e0e0;
}

/* Мобильные стили */
@media (max-width: 767px) {
    .rusnetim-map-wrapper {
        position: relative;
        overflow: hidden;
    }
    .rusnetim-info-panel {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 10000;
        background: #fff;
        transition: transform 0.3s ease;
        box-shadow: none;
        overflow-y: auto;
        box-sizing: border-box;
        transform: translateX(100%);
    }
    .rusnetim-info-panel.left-side {
        transform: translateX(-100%);
    }
    .rusnetim-info-panel.rusnetim-panel-open {
        transform: translateX(0) !important;
    }
    .rusnetim-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 9999;
        display: none;
    }
    .rusnetim-overlay.active {
        display: block;
    }
    .rusnetim-info-close {
        width: 40px;
        height: 40px;
        font-size: 32px;
        top: 10px;
        right: 10px;
        background: rgba(0,0,0,0.6);
        color: white;
        border-radius: 50%;
        z-index: 10001;
    }

    /* Фильтр и избранное на мобильных */
    .rusnetim-filter-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    .rusnetim-category-filter {
        justify-content: var(--cat-justify, flex-start);
        width: 100%;
        margin-bottom: 0;
    }
    .rusnetim-favorites-btn {
        align-self: center;
        width: fit-content;
        margin: 10px auto 0 auto;
    }
    .rusnetim-panel-actions {
        margin-right: 45px;
        gap: 8px;
    }
}

/* ===== ДОБАВЛЕНЫ СТИЛИ ДЛЯ ПЕЧАТИ ===== */
@media print {
    .rusnetim-info-panel {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        transform: none !important;
        display: block !important;
        background: white !important;
        color: black !important;
        padding: 20px !important;
        box-shadow: none !important;
    }
    .rusnetim-info-close,
    .rusnetim-favorite-action,
    .rusnetim-print-action,
    .rusnetim-panel-actions {
        display: none !important;
    }
    .rusnetim-gallery-main img,
    .gallery-thumb {
        page-break-inside: avoid;
        max-width: 100% !important;
        height: auto !important;
    }
    .rusnetim-gallery-thumbs {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }
    .gallery-thumb {
        width: 60px;
        border: 1px solid #ccc;
    }
}
.rusnetim-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    flex-direction: column;
}
.rusnetim-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1e98ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.rusnetim-loading-text {
    font-size: 14px;
    color: #333;
}