:root {
    --colour-whitbread: #4575b4;
    --colour-replacement: #e74c3c;
    --colour-text: #333;
    --colour-text-light: #444;
    --colour-text-muted: #888;
    --colour-text-heading: #1a1a1a;
    --colour-border: #eee;
}

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

body {
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
    color: var(--colour-text);
}

#map {
    width: 100vw;
    height: 100vh;
}

/* Sidebar layout */

#sidebar {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
}

/* Shared box styles */

#controls,
#toggle-box,
#heatmap-controls,
#stats-box,
#detail-box {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Main controls */

#controls h1 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--colour-text-heading);
}

#controls p {
    font-size: 13px;
    font-weight: 400;
    color: #666;
    line-height: 1.5;
    margin-bottom: 10px;
}

/* Legend */

#legend {
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

#legend h2 {
    font-size: 12px;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

.legend-bar {
    height: 12px;
    border-radius: 3px;
    background: linear-gradient(to right,
        #313695 0%,
        #4575b4 17%,
        #abd9e9 33%,
        #fee090 50%,
        #f46d43 67%,
        #a50026 100%);
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 3px;
    font-size: 10px;
    font-weight: 400;
    color: #888;
}

/* Collapsible sections */

.collapsible-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--colour-text-light);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.collapsible-header::after {
    content: '\25BC';
    font-size: 10px;
    color: #999;
    transition: transform 0.2s;
}

.collapsed .collapsible-header::after {
    transform: rotate(-90deg);
}

.collapsible-content {
    margin-top: 10px;
}

.collapsed .collapsible-content {
    display: none;
}

/* Layer toggles */

.layer-toggle {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layer-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    color: var(--colour-text-light);
}

/* Heatmap sliders */

.slider-group {
    margin-bottom: 10px;
}

.slider-group label {
    font-size: 12px;
    font-weight: 400;
    color: #555;
    display: block;
    margin-bottom: 3px;
}

.slider-group input[type="range"] {
    width: 100%;
    cursor: pointer;
}

/* Stats box */

#stats-box h2 {
    font-size: 13px;
    font-weight: 600;
    color: var(--colour-text-light);
    margin-bottom: 10px;
}

#stats-content {
    font-size: 13px;
    font-weight: 400;
    color: var(--colour-text-light);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
}

.stat-label {
    font-size: 12px;
    font-weight: 400;
    color: var(--colour-text-muted);
}

.stat-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--colour-text);
    text-align: right;
}

.stat-distance {
    color: var(--colour-replacement);
    font-weight: 700;
}

#stats-content a {
    color: var(--colour-whitbread);
    text-decoration: underline;
    font-weight: 500;
    cursor: pointer;
}

/* Detail box (selected pub) — visually distinct from permanent boxes */

#detail-box {
    border-left: 3px solid var(--colour-whitbread);
    background: #f8f9fc;
}

#detail-content {
    font-size: 13px;
    font-weight: 400;
    color: var(--colour-text-light);
}

.detail-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--colour-whitbread);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--colour-border);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
}

.detail-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--colour-text-muted);
}

.detail-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--colour-text);
    text-align: right;
}

.detail-value-replacement {
    color: var(--colour-replacement);
}

.detail-distance {
    color: var(--colour-replacement);
    font-weight: 700;
}

/* Map labels (shown on pub selection) */

.map-label {
    background: none;
    border: none;
}

.map-label-text {
    background: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-family: 'Roboto', sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.map-label-text.map-label-nearest {
    color: var(--colour-replacement);
    border-left: 3px solid var(--colour-replacement);
}

.map-label-text.map-label-selected {
    color: var(--colour-whitbread);
    border-left: 3px solid var(--colour-whitbread);
}

/* Info pills */

.info-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ccc;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    cursor: help;
    position: relative;
    vertical-align: text-top;
    margin-left: 4px;
    line-height: 1;
}

.info-pill:hover,
.info-pill.active {
    background: #888;
}

.info-pill:hover::after,
.info-pill.active::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    width: 200px;
    padding: 8px 10px;
    background: #333;
    color: #fff;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.4;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 2000;
    pointer-events: none;
}

.info-pill:hover::before,
.info-pill.active::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    right: 4px;
    border: 4px solid transparent;
    border-top-color: #333;
    z-index: 2000;
    pointer-events: none;
}

/* Mobile responsive */

@media (max-width: 480px) {
    #sidebar {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        max-width: 100%;
        max-height: 45vh;
        overflow-y: auto;
        gap: 6px;
        padding: 6px;
        border-radius: 12px 12px 0 0;
        background: rgba(255,255,255,0.95);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
    }

    #controls,
    #toggle-box,
    #heatmap-controls,
    #stats-box,
    #detail-box {
        padding: 10px 14px;
        border-radius: 6px;
        box-shadow: none;
    }

    #controls h1 {
        font-size: 14px;
    }

    #controls p {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .collapsible-header {
        font-size: 12px;
        padding: 2px 0;
    }

    .layer-toggle label {
        font-size: 12px;
    }

    .slider-group label {
        font-size: 11px;
    }

    .detail-title {
        font-size: 13px;
    }

    .detail-label,
    .stat-label {
        font-size: 11px;
    }

    .detail-value,
    .stat-value {
        font-size: 12px;
    }

    .legend-labels {
        font-size: 9px;
    }

    #legend h2,
    #stats-box h2 {
        font-size: 11px;
    }

    /* Larger tap targets for markers - handled in JS */
}
