:root {
    --primary-bg: #1a1d21;
    --secondary-bg: #22262a;
    --accent-color: #3498db;
    --text-primary: #e1e1e1;
    --text-secondary: #a1a1a1;
    --border-color: #2d3236;
    --hover-bg: #2a2f34;
    --shadow-color: rgba(0, 0, 0, 0.2);
}

body, html {
    background-color: var(--primary-bg) !important;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.mobile-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--secondary-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1200;
}

.mobile-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-actions {
    display: flex;
    gap: 8px;
}

.mobile-tab {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
}

.mobile-tab.active {
    background: var(--hover-bg);
    border-color: var(--accent-color);
}

.container-fluid {
    height: 100vh;
}

/* Map styling */
#map {
    height: 100vh;
    position: relative;
    margin: 0 auto;
    z-index: 1;
}

/* Sidebar styling */
#sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    background-color: var(--secondary-bg) !important;
    box-shadow: -2px 0 15px var(--shadow-color);
    padding: 20px;
    z-index: 1000;
    overflow-y: auto;
    transition: all 0.3s ease;
    border-left: 1px solid var(--border-color);
}

/* Table of contents pane */
#toc {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    background-color: var(--secondary-bg) !important;
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

/* Tool styling */
.tool {
    cursor: pointer;
    padding: 15px;
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
    background-color: var(--secondary-bg);
}

.tool:hover {
    background-color: var(--hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

#toolContent, #toolParameters {
    margin-bottom: 1em;
}

#toolContent *, #toolParameters * {
    margin-bottom: 0.8em;
}

.param-label {
    margin-right: 1em;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Back button styling */
#backButton {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#backButton:hover {
    background-color: var(--hover-bg);
    transform: translateX(-2px);
}

/* Status message styling */
#statusMessage {
    margin-top: 1em;
}

.alert {
    padding: 12px;
    border-radius: 6px;
    background-color: var(--hover-bg);
    border: 1px solid var(--border-color);
}

/* Input styling */
input[type="number"], input[type="text"], select {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    width: 100%;
    transition: all 0.2s ease;
}

input[type="number"]:focus, input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Slider styling */
.param-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
    outline: none;
    margin: 10px 0;
}

.param-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.param-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Data content styling */
#DataContent {
    background-color: var(--secondary-bg);
    border-radius: 8px;
    padding: 15px;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid var(--border-color);
}

/* Popup table styling */
.popupTable {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.popupTable td {
    padding: 8px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    background-color: var(--secondary-bg);
}

/* Responsive design */
@media (max-width: 768px) {
    .mobile-bar { display: flex; }

    .container-fluid {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 52px);
    }

    #map {
        height: 100%;
        order: 1;
    }

    #toc,
    #sidebar {
        position: relative;
        width: 100%;
        height: 100%;
        border: none;
    }

    /* View switching */
    body[data-view="map"] #toc,
    body[data-view="map"] #sidebar { display: none; }

    body[data-view="tools"] #map,
    body[data-view="tools"] #toc { display: none; }

    body[data-view="layers"] #map,
    body[data-view="layers"] #sidebar { display: none; }

    /* Touch targets */
    .tool { padding: 18px; }
    input[type="number"], input[type="text"], select, button { min-height: 44px; }
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tool, #toolContent, #toolParameters {
    animation: fadeIn 0.3s ease-out;
}

/* AI Settings */
.ai-settings-trigger {
    border-style: dashed !important;
    color: var(--text-secondary);
    text-align: center;
}

.ai-settings label {
    display: block;
}

.ai-settings input[type="password"] {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    width: 100%;
}

#aiSettingsPanel {
    animation: fadeIn 0.3s ease-out;
}

/* Hidden class and visibility control */
.hidden {
    display: none !important;
}

#toolSelection, #toolDetails {
    display: none;
}

#toolSelection:not(.hidden) {
    display: block;
}

#toolDetails:not(.hidden) {
    display: block;
}