:root {
    --bg-dark: #1a1a1a;
    --bg-darker: #121212;
    --bg-lighter: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --accent: #4a9eff;
    --accent-hover: #6ab4ff;
    --danger: #ff4444;
    --success: #44ff44;
    --border: #333;
    --toolbar-height: 50px;
    --sidebar-width: 280px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

.app {
    display: grid;
    grid-template-rows: var(--toolbar-height) 1fr;
    grid-template-columns: 1fr auto;
    height: 100vh;
}

.toolbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border);
    z-index: 100;

    h1 {
        font-size: 1.1rem;
        font-weight: 600;
        margin-right: 16px;
    }

    &-left,
    &-center,
    &-right {
        display: flex;
        align-items: center;
        gap: 12px;
    }
}

.map-select {
    padding: 6px 12px;
    background: var(--bg-lighter);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;

    &:hover {
        border-color: var(--accent);
    }

    &:focus {
        outline: none;
        border-color: var(--accent);
    }
}

.btn {
    padding: 6px 12px;
    background: var(--bg-lighter);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.15s ease;

    &:hover {
        background: var(--bg-dark);
        border-color: var(--accent);
    }

    &:active {
        transform: scale(0.95);
    }

    &-primary {
        background: var(--accent);
        border-color: var(--accent);
        color: #000;

        &:hover {
            background: var(--accent-hover);
        }
    }

    &-secondary {
        background: transparent;
    }

    &-icon {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 4px;

        &:hover {
            color: var(--text-primary);
        }
    }
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-display {
    min-width: 50px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.coords-display {
    display: flex;
    gap: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.map-container {
    position: relative;
    overflow: hidden;
    background: var(--bg-darker);
    cursor: grab;

    &:active {
        cursor: grabbing;
    }
}

.map-viewport {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.map-svg {
    display: block;
    width: 8192px;
    height: 8192px;
    pointer-events: none;
}

.markers-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 8192px;
    height: 8192px;
    pointer-events: none;
}

.marker {
    position: absolute;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -100%);
    cursor: pointer;
    pointer-events: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    transition: transform 0.15s ease;

    &:hover {
        transform: translate(-50%, -100%) scale(1.2);
    }

    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 0;
        border-left: 12px solid transparent;
        border-right: 12px solid transparent;
        border-top: 24px solid currentColor;
    }

    &::after {
        content: '';
        position: absolute;
        top: -4px;
        left: 50%;
        transform: translateX(-50%);
        width: 8px;
        height: 8px;
        background: white;
        border-radius: 50%;
    }

    .marker-label {
        position: absolute;
        top: -24px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 2px 6px;
        border-radius: 3px;
        font-size: 0.75rem;
        white-space: nowrap;
        opacity: 0;
        transition: opacity 0.15s ease;
    }

    &:hover .marker-label {
        opacity: 1;
    }
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-darker);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, opacity 0.2s ease;

    &.collapsed {
        width: 0;
        opacity: 0;
        overflow: hidden;
    }

    &-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border);

        h2 {
            font-size: 0.95rem;
            font-weight: 500;
        }
    }
}

.marker-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 24px 16px;
}

.marker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-lighter);
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;

    &:hover {
        background: var(--bg-dark);
    }

    .marker-color {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .marker-info {
        flex: 1;
        min-width: 0;

        .marker-name {
            font-size: 0.9rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .marker-coords {
            font-size: 0.75rem;
            color: var(--text-secondary);
        }
    }

    .marker-delete {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 4px;
        border-radius: 3px;

        &:hover {
            color: var(--danger);
            background: rgba(255, 68, 68, 0.1);
        }
    }
}

.context-menu {
    position: fixed;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    min-width: 160px;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);

    &.visible {
        display: block;
    }
}

.context-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9rem;

    &:hover {
        background: var(--accent);
        color: #000;
    }
}

.marker-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;

    &.visible {
        display: flex;
    }

    .modal-content {
        background: var(--bg-darker);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 20px;
        min-width: 300px;

        h3 {
            margin-bottom: 16px;
        }

        input {
            width: 100%;
            padding: 10px 12px;
            background: var(--bg-lighter);
            border: 1px solid var(--border);
            border-radius: 4px;
            color: var(--text-primary);
            font-size: 0.95rem;
            margin-bottom: 16px;

            &:focus {
                outline: none;
                border-color: var(--accent);
            }
        }
    }
}

.marker-colors {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;

    &:hover {
        transform: scale(1.1);
    }

    &.active {
        border-color: white;
    }
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Loading state */
.loading {
    position: relative;

    &::after {
        content: 'Loading...';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: var(--text-secondary);
        font-size: 1.2rem;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;

    &:hover {
        background: var(--text-secondary);
    }
}
