* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
}

.container {
    max-width: 2400px;
    margin: 0;
    padding: 5px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 15px;
}

header h1 {
    color: #333;
    font-size: 24px;
}

main {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.map-container {
    flex: 5;
    background: white;
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.map-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    flex-wrap: wrap;
}

.coordinates-display {
    padding: 4px 8px;
    background: #e9ecef;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

#cursor-coords {
    color: #495057;
    font-weight: bold;
}

.map-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: #f8f9fa;
    min-height: 0;
}

.map-inner {
    position: relative;
    width: 100%;
    height: 100%;
}

#map-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

#map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.click-marker {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff0000;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 8px rgba(255,0,0,0.5);
    display: none;
}

/* Стили для маркеров объектов */
.object-marker {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #007bff;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 0 6px rgba(0,123,255,0.5);
    transition: all 0.3s ease;
    display: none;
}

.object-marker:hover {
    transform: translate(-50%, -50%) scale(1.3);
    background: #0056b3;
    z-index: 90;
}

.object-label {
    position: absolute;
    background: rgba(255,255,255,0.95);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    color: #333;
    pointer-events: none;
    z-index: 6;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    /* max-width: 120px; */
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
    transform: translate(8px, -50%); /* Справа от маркера */
}

/* Стили для маркеров персонажей */
.character-marker {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #dc3545;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 7;
    box-shadow: 0 0 5px rgba(220,53,69,0.5);
    transition: all 0.3s ease;
    display: none;
}

.character-marker:hover {
    transform: translate(-50%, -50%) scale(1.4);
    background: #c82333;
    z-index: 100;
}

.character-label {
    position: absolute;
    background: rgba(255,255,255,0.95);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: bold;
    color: #dc3545;
    pointer-events: none;
    z-index: 8;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    border: 1px solid #dc3545;
    /* max-width: 100px; */
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
    transform: translate(8px, -50%); /* Справа от маркера */
}

/* Классы для управления видимостью */
.objects-visible .object-marker,
.objects-visible .object-label {
    display: block;
}

.characters-visible .character-marker,
.characters-visible .character-label {
    display: block;
}

.filter-active .object-marker,
.filter-active .object-label,
.filter-active .character-marker,
.filter-active .character-label {
    display: none;
}

/* Стили при наведении */
.object-marker:hover ~ .object-label,
.object-label:hover {
    z-index: 91;
    background: rgba(255,255,255,1);
}

.character-marker:hover ~ .character-label,
.character-label:hover {
    z-index: 101;
    background: rgba(255,255,255,1);
}

.area-highlight {
    stroke: #ff0000;
    stroke-width: 3;
    fill: rgba(255,0,0,0.1);
    cursor: pointer;
}

/* Компактная боковая панель */
.sidebar {
    flex: 1;
    min-width: 280px;
    background: white;
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 15px;
}

.filters {
    margin-bottom: 0;
}

#search {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

#filter-type {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: white;
}

.lists {
    flex: 1;
    /* overflow-y: auto; */
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.objects-list, .characters-list {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.objects-list h3, .characters-list h3 {
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    font-weight: bold;
}

.objects-list ul, .characters-list ul {
    flex: 4;
    overflow-y: auto;
    min-height: 80px;
    max-height: 270px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 4px;
}

.coordinates-panel {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 10px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.coordinates-panel h3 {
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    font-weight: bold;
}

#click-history {
    flex: 1;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    background: white;
    border-radius: 3px;
    padding: 8px;
    max-height: 100px;
}

.click-item {
    padding: 3px;
    margin-bottom: 3px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 10px;
}

.click-item:hover {
    background: #e9ecef;
}

.click-item:last-child {
    border-bottom: none;
}

ul {
    list-style: none;
}

li {
    padding: 6px 8px;
    margin-bottom: 3px;
    background: #f8f9fa;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 12px;
}

li:hover {
    background: #e9ecef;
}

li.active {
    background: #007bff;
    color: white;
}

.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
}

.popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    min-width: 280px;
    max-width: 400px;
}

.close {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 20px;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
    }
    
    .map-container, .sidebar {
        flex: none;
    }
    
    .sidebar {
        min-width: auto;
    }
    
    .map-controls {
        flex-wrap: wrap;
    }
    
    .coordinates-display {
        width: 100%;
        text-align: center;
    }
}