:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --bg-color: #f5f5f5;
    --panel-bg: #ffffff;
    --border-color: #ddd;
    --text-color: #333;
    --text-light: #666;
}

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

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

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 360px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.header {
    padding: 20px;
    background: var(--primary-color);
    color: white;
}

    .header h1 {
        font-size: 20px;
        font-weight: 600;
    }

.panel {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

    .panel h2 {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 15px;
    }

    .panel h3 {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 10px;
        color: var(--text-light);
    }

/* Form Elements */
.form-group {
    margin-bottom: 15px;
}

    .form-group label {
        display: block;
        font-size: 13px;
        font-weight: 500;
        margin-bottom: 5px;
        color: var(--text-light);
    }

/* Consistent styling for all input types */
input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: white;
    color: var(--text-color);
    box-sizing: border-box;
}

    input[type="text"]:focus,
    input[type="password"]:focus,
    select:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    }

    input[type="text"]::placeholder,
    input[type="password"]::placeholder {
        color: #999;
        opacity: 1;
    }

/* Ensure consistent height for all inputs */
input[type="text"],
input[type="password"] {
    height: 38px;
}

select {
    height: 38px;
    cursor: pointer;
}

    /* Disabled state */
    input[type="text"]:disabled,
    input[type="password"]:disabled,
    select:disabled {
        background-color: var(--bg-color);
        cursor: not-allowed;
        opacity: 0.6;
    }

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

    .btn-primary:hover {
        background: var(--primary-dark);
    }

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    width: auto;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

    .tab-btn:hover {
        color: var(--primary-color);
    }

    .tab-btn.active {
        color: var(--primary-color);
        border-bottom-color: var(--primary-color);
    }

.tab-content {
    display: none;
}

    .tab-content.active {
        display: block;
    }

/* Layer Selector */
.layer-selector {
    margin-top: 15px;
}

.layer-item {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
}

.layer-item-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.layer-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word;
}

.layer-projection {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.projection-badge {
    display: inline-block;
    background-color: #e8f4f8;
    color: #2c5282;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid #bee3f8;
}

.layer-options {
    display: flex;
    gap: 5px;
    margin-top: 8px;
}

/* Active Layers */
.active-layers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layers-section {
    margin-bottom: 16px;
}

    .layers-section:last-child {
        margin-bottom: 0;
    }

.active-layer-item {
    padding: 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.active-layer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.active-layer-title {
    font-size: 13px;
    font-weight: 500;
}

.active-layer-type {
    font-size: 11px;
    color: var(--text-light);
}

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

.opacity-slider {
    flex: 1;
    height: 4px;
}

.layer-control-btn {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 3px;
    cursor: pointer;
}

    .layer-control-btn:hover {
        background: var(--bg-color);
    }

/* Map */
.map-container {
    flex: 1;
    position: relative;
}

.map {
    width: 100%;
    height: 100%;
}

.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-color);
    cursor: pointer;
    user-select: none;
}

.grid-toggle input {
    margin: 0;
    cursor: pointer;
}

/* Status Bar */
.status {
    padding: 10px 20px;
    font-size: 12px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
}

    .status.error {
        background: #ffebee;
        color: var(--danger-color);
    }

    .status.success {
        background: #e8f5e9;
        color: var(--success-color);
    }

    .status.warning {
        background: #fff3e0;
        color: var(--warning-color);
    }

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
.empty-state {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

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

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

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

    ::-webkit-scrollbar-thumb:hover {
        background: #999;
    }

/* Scale Display */
#scale-display {
    position: absolute;
    bottom: 30px;
    left: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    user-select: none;
    pointer-events: none;
}

/* Layer Search */
.layer-search-box {
    margin: 12px 0;
    position: relative;
}

.layer-search-input {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
    transition: all 0.2s;
}

    .layer-search-input:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    }

    .layer-search-input::placeholder {
        color: #999;
    }

.layer-search-count {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    padding-left: 2px;
}

.layers-list {
    margin-top: 8px;
}

/* Highlight search results */
.layer-item {
    transition: opacity 0.2s, transform 0.2s;
}

    .layer-item[style*="display: none"] {
        opacity: 0;
        transform: scale(0.95);
    }
