:root {
    --toolbar-h: 44px;
    /* compacte toolbarhoogte */
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    display: flex;
    height: 100vh;
    color: #f5f5f5;
    background: #111;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    background: #18181b;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border-right: 1px solid #27272f;
    overflow-y: auto;
    z-index: 2000;
    transition: transform 0.3s ease;
}

.sidebar h1 {
    margin: 0 0 8px;
    font-size: 16px;
}

.sidebar section {
    margin-bottom: 10px;
}

label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #a1a1aa;
    display: block;
    margin-bottom: 3px;
}

select,
input[type="text"],
input[type="number"],
input[type="color"] {
    width: 100%;
    margin-bottom: 6px;
    padding: 5px 7px;
    border-radius: 5px;
    border: 1px solid #27272f;
    background: #09090b;
    color: #f5f5f5;
    font-size: 12px;
    box-sizing: border-box;
}

.row {
    display: flex;
    gap: 8px;
}

.row>div {
    flex: 1;
}

button {
    border-radius: 5px;
    border: none;
    padding: 6px 8px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

.btn-primary {
    background: #4bb3ff;
    color: #000;
}

.btn-secondary {
    background: #27272f;
    color: #f5f5f5;
}

.btn-danger {
    background: #b91c1c;
    color: #fff;
}

.checkbox-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 11px;
}

.checkbox-row label {
    text-transform: none;
    color: #e4e4e7;
    margin-bottom: 0;
}

#map-mode {
    margin-left: 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #a1a1aa;
}

/* MAIN AREA */
.main {
    flex: 1;
    display: flex;
    justify-content: center;
    background: #020617;
    position: relative;
    overflow: hidden;
    margin-right: 0;
    /* Dynamic - set by JS when stats panel shown */
}

#preview-container {
    width: 100%;
    height: calc(100vh - var(--toolbar-h));
    padding: 10px;
    /* marge rondom */
    box-sizing: border-box;

    display: flex;
    justify-content: center;
    align-items: center;

    overflow: hidden;
    position: relative;
}

#mapbox-gl {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 100%;
    height: 100%;
    visibility: hidden;
    pointer-events: none;
}

#preview-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    display: block;
}

/* ULTRA-COMPACT BOTTOM TOOLBAR */
#bottom-toolbar {
    position: fixed;
    bottom: 0;
    left: 280px;
    right: 0;
    /* Dynamic - set by JS when stats panel shown */

    height: 44px;
    /* compact */
    background: #131316f2;
    border-top: 1px solid #27272f;

    padding: 0 18px;
    box-sizing: border-box;
    z-index: 9999;

    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* LEFT SIDE STATUS */
#bottom-left {
    font-size: 12px;
    color: #a1a1aa;
    white-space: nowrap;
}

/* RIGHT SIDE BUTTONS – compact clean buttons */
#wysiwyg-buttons {
    justify-self: end;
    display: flex;
    gap: 8px;
}

/* SMALLER SMART BUTTONS */
.wysiwyg-btn {
    width: 32px;
    height: 32px;
    background: #1d1d22;
    border: 1px solid #2c2c33;
    border-radius: 6px;
    cursor: pointer;

    font-size: 16px;
    color: #d6d6d6;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: background 120ms, border-color 120ms;
}

.wysiwyg-btn:hover {
    background: #29292f;
}

.wysiwyg-btn:active {
    background: #34343a;
    border-color: #4d4d56;
}

/* RIGHT STATS PANEL */
#stats-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: #18181b;
    border-left: 1px solid #27272f;
    padding: 8px 12px;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 2000;
    display: none;
    /* Hidden until GPX loaded */
    transition: transform 0.3s ease;
}

#stats-panel h2 {
    margin: 0 0 4px;
    font-size: 11px;
    color: #f5f5f5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-row {
    margin-bottom: 3px;
    padding-bottom: 3px;
    border-bottom: 1px solid #27272f;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.stat-row:last-child {
    border-bottom: none;
}

.stats-separator {
    height: 2px;
    background: #4bb3ff;
    margin: 6px 0;
    border-radius: 2px;
}

.info-stats-separator {
    height: 2px;
    background: #ff4b4b;
    margin: 6px 0;
    border-radius: 2px;
}

.stat-checkbox {
    flex-shrink: 0;
    cursor: pointer;
    width: 14px;
    height: 14px;
    accent-color: #4bb3ff;
}

.stat-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.drag-handle {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    opacity: 0;
    color: #888;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.stat-row[draggable="true"] .drag-handle {
    opacity: 0.5;
}

.stat-row[draggable="true"]:hover .drag-handle {
    opacity: 1;
    color: #4bb3ff;
}

/* Info stats styling */
.stat-row.info-stat {
    opacity: 0.6;
}

.stat-row.info-stat .stat-checkbox {
    cursor: not-allowed;
}

.stat-label {
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #71717a;
    margin-bottom: 0px;
}

.stat-value {
    font-size: 12px;
    font-weight: 600;
    color: #f5f5f5;
}

.stat-value.large {
    font-size: 18px;
}

.stat-value .unit {
    font-size: 14px;
    color: #a1a1aa;
    font-weight: 400;
}

/* HAMBURGER BUTTONS (Mobile Only) */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 10px;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    backdrop-filter: blur(4px);
}

#btn-toggle-settings {
    left: 10px;
}

#btn-toggle-stats {
    right: 10px;
}

/* MOBILE LAYOUT */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    /* Sidebars hidden by default */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 85%;
        max-width: 320px;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        z-index: 10000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    #stats-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        left: auto;
        /* Reset left */
        width: 85%;
        max-width: 320px;
        transform: translateX(100%);
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
        border-left: 1px solid #27272f;
        display: block !important;
        /* Always block, controlled by transform */
        z-index: 10000;
    }

    #stats-panel.open {
        transform: translateX(0);
    }

    /* Main area takes full width */
    .main {
        width: 100%;
        margin-right: 0 !important;
        /* Override JS inline styles */
    }

    /* Bottom toolbar adjustments */
    #bottom-toolbar {
        left: 0;
        right: 0 !important;
        /* Override JS inline styles */
        padding: 0 10px;
        justify-content: center;
        /* Center content or adjust as needed */
    }

    #bottom-left {
        display: none;
        /* Hide status text on very small screens if needed */
    }

    #wysiwyg-buttons {
        gap: 4px;
    }

    .wysiwyg-btn {
        width: 36px;
        /* Larger touch targets */
        height: 36px;
        font-size: 18px;
    }

    /* Show hamburger buttons */
    .hamburger-btn {
        display: block;
    }

    /* Adjust preview container to account for toolbar */
    #preview-container {
        height: calc(100vh - var(--toolbar-h));
    }
}