*, *::before, *::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f7f8fb;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-shell {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#mapbox-map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}



/* ── Sidebar (pure HTML, glassmorphism, edge-anchored) ── */
#sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
    pointer-events: auto;
    background: rgba(26, 28, 33, 0.62);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
    backdrop-filter: blur(28px) saturate(150%);
    border-radius: 0;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    width: 192px;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.sidebar-collapsed {
    width: 70px;
}

/* Sidebar items (shared base for header + nav buttons) */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    /* 
       Mathematical centering for 70px collapsed width AND square buttons:
       Nav button width: 13px margin + 12px padding + 20px icon + 12px padding + 13px margin = 70px.
       Height: 12px padding + 20px icon + 12px padding = 44px (Perfect 44x44 square!)
       Since padding-left NEVER changes, the icon NEVER moves during animation!
    */
    padding: 12px 12px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-family: inherit;
    font-size: 17px;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    transition: background 0.15s, color 0.15s;
}

/* Logo — sized to match a full nav button */
.sidebar-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 8px;
}

/* Brand text */
.sidebar-brand {
    font-weight: 700;
    font-size: 22px;
    letter-spacing: -0.05em;
    color: #fff;
}

/* Header spacing — top padding aligns with content panel title */
#sidebar-header {
    /* Logo centering: 17px pad + 36px logo + 17px pad = 70px */
    padding: 32px 17px 14px 17px;
    margin-bottom: 8px;
}

/* Nav buttons — same margin & border-radius in BOTH states */
.sidebar-nav {
    margin: 4px 13px;
    border-radius: 12px;
}

/* Collapsed state overrides — ONLY hide the text, do NOT change paddings/margins! */
.sidebar-collapsed .sidebar-label {
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: width 0.15s, opacity 0.1s;
}

/* Expanded: show labels */
.sidebar-label {
    opacity: 1;
    width: auto;
    transition: opacity 0.2s 0.08s;
}

/* Material Symbols icon sizing */
.sidebar-item .material-symbols-rounded {
    font-size: 20px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* Nav button hover */
.sidebar-nav:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Nav button active/selected */
.sidebar-nav.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-weight: 600;
}

.sidebar-spacer {
    height: 8px;
}

/* ── Content panel (Compose canvas) ── */
#webApp {
    position: absolute;
    top: 16px;
    left: 208px; /* 192px sidebar + 16px gap */
    width: 420px;
    height: calc(100% - 32px);
    z-index: 10;
    background: #f7f8fb;
    border-radius: 24px;
    box-shadow: 0 12px 48px rgba(15, 23, 42, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Force Compose canvas to perfectly fill its container so it receives all clicks */
#webApp canvas {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    outline: none !important;
    border: none !important;
    pointer-events: auto !important;
}

.sidebar-collapsed ~ #webApp {
    left: 86px; /* 70px collapsed sidebar + 16px gap */
}



/* ── Mapbox ── */
#mapbox-map .mapboxgl-map {
    width: 100%;
    height: 100%;
}

#mapbox-map canvas.mapboxgl-canvas {
    outline: none;
}

.mapboxgl-ctrl-top-right {
    top: 16px;
    right: 16px;
}

.mapboxgl-ctrl-group {
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
    border: none !important;
}

.mapboxgl-ctrl-bottom-right {
    bottom: 8px;
    right: 8px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    #sidebar {
        display: none;
    }
    #webApp {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        height: 48vh;
        border-radius: 24px 24px 0 0;
        box-shadow: 0 -12px 48px rgba(15, 23, 42, 0.12);
    }
}
