/* Яндекс Карты Pro - Стили */

/* === ОСНОВНЫЕ СТИЛИ КАРТЫ === */
.yandex-maps-container {
    position: relative;
    display: flex;
    gap: 0;
    margin: 20px 0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(16, 41, 46, 0.3);
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 400px;
    border: 1px solid #e2e8f0;
}

.yandex-map-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
    height: 400px;
}

.yandex-map {
    width: 100%;
    height: 400px;
    border: none;
    display: block;
}

/* === ЗАГРУЗКА === */
.yandex-maps-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    color: #31708F;
    flex-direction: column;
    gap: 15px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #31708F;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === БОКОВАЯ ПАНЕЛЬ СЛЕВА === */
.yandex-maps-sidebar {
    flex: 0 0 350px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    height: 400px;
    order: -1;
}

.sidebar-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, #10292E 0%, #31708F 100%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-header h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.sidebar-header .markers-count {
    font-size: 14px;
    opacity: 0.9;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #5085A5 transparent;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #5085A5;
}

/* === АККОРДЕОН ГОРОДОВ === */
.cities-accordion {
    background: #f8fafc;
}

.accordion-item {
    border-bottom: 1px solid #e2e8f0;
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    background: #ffffff;
    transition: background-color 0.15s ease;
    user-select: none;
}

.accordion-header:hover {
    background: #f1f5f9;
}

.accordion-header.active {
    background: #e2f1f8;
    border-bottom: 1px solid #31708F;
}

.city-icon {
    flex: 0 0 20px;
    margin-right: 8px;
    font-size: 14px;
}

.city-info {
    flex: 1;
    min-width: 0;
}

.city-name {
    margin: 0 0 1px 0;
    font-size: 14px;
    font-weight: 600;
    color: #10292E;
}

.city-markers-count {
    font-size: 12px;
    color: #5085A5;
}

.accordion-arrow {
    flex: 0 0 20px;
    text-align: center;
    font-size: 12px;
    color: #5085A5;
    transition: transform 0.2s ease;
}

.accordion-header.active .accordion-arrow {
    transform: rotate(90deg);
}

.accordion-content {
    background: #f1f5f9;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-content.open {
    max-height: 1000px;
}

/* === ЭЛЕМЕНТЫ МЕТОК === */
.marker-item {
    display: flex;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
    background: #ffffff;
}

.marker-item:hover {
    background: #f8fafc;
    transform: translateX(2px);
}

.marker-item.active {
    background: #e2f1f8;
    border-left: 4px solid #31708F;
    transform: translateX(4px);
}

.marker-item:last-child {
    border-bottom: none;
}

.marker-icon {
    flex: 0 0 30px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 1px;
    margin-right: 8px;
}

.icon-marker {
    position: relative;
    width: 16px;
    height: 16px;
    background: #31708F;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 1px 3px rgba(16, 41, 46, 0.3);
}

.icon-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
}

/* Цвета иконок */
.icon-marker.red { background: #FF7C4C; }
.icon-marker.blue { background: #31708F; }
.icon-marker.green { background: #22c55e; }
.icon-marker.yellow { background: #eab308; }
.icon-marker.orange { background: #FF7C4C; }
.icon-marker.purple { background: #5085A5; }
.icon-marker.pink { background: #ec4899; }
.icon-marker.teal { background: #10b981; }

.marker-content {
    flex: 1;
    min-width: 0;
}

.marker-title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
    color: #10292E;
    line-height: 1.2;
}

.marker-description {
    margin: 0 0 6px 0;
    font-size: 11px;
    color: #5085A5;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.marker-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 10px;
    color: #71717a;
}

.marker-address {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.marker-coordinates {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 9px;
    color: #9ca3af;
    margin-top: 2px;
}

/* === ПОПАПЫ СПРАВА === */
.custom-popup {
    position: absolute;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(16, 41, 46, 0.25);
    z-index: 1000;
    min-width: 320px;
    max-width: 450px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 1px solid #e2e8f0;
    top: 20px;
    right: 20px;
}

.popup-header {
    background: linear-gradient(135deg, #10292E 0%, #31708F 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.popup-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    flex: 1;
    margin-right: 10px;
}

.popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.popup-body {
    padding: 20px;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.5;
}

.popup-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 16px;
    float: right;
    max-height: 80px;
    max-width: 80px;
}

.popup-description {
    margin: 0 0 16px 0;
    color: #374151;
}

.popup-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    font-size: 14px;
}

.popup-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #5085A5;
}

.popup-meta-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.popup-meta a {
    color: #FF7C4C;
    text-decoration: none;
}

.popup-meta a:hover {
    text-decoration: underline;
}

.sidebar-empty {
    text-align: center;
    padding: 40px 20px;
    color: #5085A5;
    font-style: italic;
}

.sidebar-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #5085A5;
    flex-direction: column;
    gap: 12px;
}

/* === АДМИНКА === */
.yandex-maps-admin {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: 0 20px 0 0;
}

.ym-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #c3c4c7;
}

.ym-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.ym-stat-card {
    background: white;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: box-shadow 0.2s ease;
}

.ym-stat-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ym-stat-number {
    font-size: 32px;
    font-weight: bold;
    color: #135e96;
    margin-bottom: 5px;
    display: block;
}

.ym-stat-label {
    color: #646970;
    font-size: 14px;
    font-weight: 500;
}

.ym-section {
    background: white;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.ym-section h2, .ym-section h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #1d2327;
    border-bottom: 1px solid #f0f0f1;
    padding-bottom: 10px;
}

.ym-form .form-table th {
    width: 200px;
    font-weight: 600;
}

.ym-form input.error, .ym-form select.error, .ym-form textarea.error {
    border-color: #d63638;
    box-shadow: 0 0 0 1px #d63638;
}

.error-message {
    color: #d63638;
    font-size: 12px;
    margin-top: 5px;
}

.admin-map {
    height: 400px;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    margin: 20px 0;
}

.ym-api-key-notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    color: #856404;
}

.ym-api-key-notice strong {
    color: #664d03;
}

.city-edit-link {
    text-decoration: none;
    color: #0073aa;
    font-size: 12px;
    margin-left: 10px;
}

.city-edit-link:hover {
    text-decoration: underline;
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 1024px) {
    .yandex-maps-sidebar {
        flex: 0 0 300px;
    }

    .custom-popup {
        right: 10px;
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .yandex-maps-container {
        flex-direction: column !important;
        gap: 0;
        height: auto !important;
    }

    .yandex-maps-sidebar {
        flex: 0 0 250px;
        border-right: none !important;
        border-top: 1px solid #e2e8f0;
        height: 450px !important;
        order: 1;
    }

    .sidebar-header {
        padding: 10px 16px;
    }

    .sidebar-header h3 {
        font-size: 15px;
    }

    .yandex-map-wrapper {
        height: 300px !important;
    }

    .yandex-map {
        height: 300px !important;
    }

    .custom-popup {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%) !important;
        z-index: 9999;
        max-width: 90vw;
        max-height: 80vh;
    }

    .popup-body {
        max-height: 60vh;
    }

    .ym-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .ym-stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 480px) {
    .yandex-maps-container {
        margin: 10px 0;
        border-radius: 8px;
    }

    .sidebar-header {
        padding: 8px 12px;
    }

    .marker-item {
        padding: 6px 12px;
    }

    .accordion-header {
        padding: 8px 12px;
    }

    .ym-section {
        padding: 15px;
    }

    .ym-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* === УТИЛИТЫ === */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-down {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Файл: yandex-maps.css */
.cities-sortable-list tr {
    cursor: grab!important;
}
/* Опционально: курсор при самом перетаскивании */
.cities-sortable-list tr:active,
.ui-sortable-helper {
    cursor: grabbing!important; /* Рука с сжатой ладонью */
}
.cities-sortable-list .ui-sortable-placeholder {
    height: 50px;
    background-color: #f0f0f1;
    border: 1px dashed #b4b9be;
    visibility: visible !important;
}
.cities-sortable-list .ui-sortable-helper {
    display: table;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

a[href="admin.php?page=yandex-maps-edit-marker"],
a[href="admin.php?page=yandex-maps-edit-city"] {
    display: none !important;
}

/* === СТИЛИ ДЛЯ СОРТИРОВКИ ГОРОДОВ === */
/* Элемент "бургер" для перетаскивания */
.drag-handle {
    cursor: grab!important;
    width: 12px;
    height: 10px;
    padding: 2px 0; /* Уменьшаем внутренний отступ сверху и снизу */
    cursor: move; /* Показывает, что элемент можно перетаскивать */
    opacity: 0.6;
    transition: opacity 0.2s ease;
    /* Центрируем по вертикали */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    margin-right: 10px; /* Отступ справа от бургера до текста */
}

.drag-handle:hover {
    opacity: 1;
    cursor: grab!important;
}

/* Линии внутри "бургера" */
.drag-handle::before,
.drag-handle::after,
.drag-handle span {
    content: '';
    display: block;
    width: 100%;
    height: 2px;
    background-color: #5085A5; /* Цвет линий */
    border-radius: 1px;
}
/* Убираем центральную линию, так как span уже есть */
.drag-handle span {
    width: 100%;
    height: 2px;
    background-color: #5085A5;
    border-radius: 1px;
}

/* Стили для сортировки меток */
.markers-sortable-list tr {
    cursor: grab !important;
}

.markers-sortable-list tr:active,
.markers-sortable-list .ui-sortable-helper {
    cursor: grabbing !important;
}

.markers-sortable-list .ui-sortable-placeholder {
    height: 50px;
    background-color: #f0f0f1;
    border: 1px dashed #b4b9be;
    visibility: visible !important;
}

.markers-sortable-list .ui-sortable-helper {
    display: table;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ui-sortable td,
.ui-sortable-handle td {
    vertical-align: middle;
}