/* Ensure everything fills the full screen and removes scrollbars */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: Arial, sans-serif;
    background: #f9fafb;
}

/* === Header with inline data sources === */
#pageTitle {
    position: relative;
    text-align: center;
    margin: 0px 0px;
    font-family: sans-serif;
    font-size: 1.1rem;
}

/* Container fills everything below title */
#container {
    display: flex;
    flex-direction: column;
    height: calc(100% - 25px);
    position: relative;
}

/* Resizable areas with fixed percentages with map fade transition for resize */
#map {
    height: 65%;
    min-height: 150px;
    background: #ccc;
    transition: height 0.1s ease, opacity 0.25s ease-in-out;
}

#divider {
    height: 8px;
    background: #ddd;
    cursor: row-resize;
    flex-shrink: 0;
}

    #divider:hover {
        background: #bbb;
    }

#chartContainer {
    height: 35%;
    min-height: 150px;
    background: white;
    border-top: 1px solid #ccc;
    padding: 0;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
    transition: height 0.1s ease;
    overflow: hidden;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

canvas {
    flex: 1;
    width: 100%;
    height: 100%;
    display: block;
}

/* Slightly dim divider during fade for smoother look */
.fading #divider {
    opacity: 0.6;
    transition: opacity 0.25s ease-in-out;
}

/* Leaflet legend overlay */
.leaflet-control.legend {
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    font: 12px/1.4 "Helvetica Neue", Arial, sans-serif;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    color: #333;
}

    .leaflet-control.legend i {
        width: 14px;
        height: 14px;
        float: left;
        margin-right: 6px;
        opacity: 0.9;
        border: 1px solid #666;
        border-radius: 2px;
    }

#citation {
    font-size: 0.85rem;
    color: #555;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5000;
}

#citation-header {
    cursor: pointer;
    padding: 3px 8px;
    background: #f4f4f4;
    border-radius: 4px;
    transition: background 0.2s;
}

    #citation-header:hover {
        background: #e8e8e8;
    }

#citation-content {
    display: none;
    position: absolute;
    right: -15px;
    top: 35px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 5px 5px;
    width: 300px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    line-height: 1.4em;
    text-align:left;
    font-size: 12px;
    z-index: 1000;
}

    #citation-content.show {
        display: block;
        animation: fadeIn 0.25s ease;
    }

    #citation-content a {
        color: #00704A;
        text-decoration: none;
    }

        #citation-content a:hover {
            text-decoration: underline;
        }
.citation-item {
    display:inline-block;
}

#chartControls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-align: center;
    margin: 5px 0;
    font-size: 0.9rem;
    color: #333;
    position: relative;
}

#yearSlider {
    width: 60%;
    height: 6px;
    border-radius: 0;
    background: #ddd;
    outline: none;
    appearance: none;
    z-index: 2;
}

    /* Remove default ticks */
    #yearSlider::-webkit-slider-runnable-track,
    #yearSlider::-moz-range-track {
        background: transparent;
    }

.slider-ticks {
    position: absolute;
    top: 13%;
    height: 12px;
    pointer-events: none;
    z-index: 1000;
}

    .slider-ticks div {
        width: 2px;
        height: 8px;
        background: #666;
        border-radius: 1px;
        transition: background 0.2s, height 0.2s, transform 0.2s;
    }

/* --- Filter Button --- */
#filterButton {
    background: #0078d7;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0 7px; /* 0 height padding for tight vertical fit */
    height: 15px; /* matches slider thumb height nicely */
    line-height: 22px;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.9px;
}

    #filterButton:hover {
        background: #005fa3;
    }

/* --- Filter Panel --- */
#filterPanel {
    position: relative;
    width: 100%;
    height: 0;
    overflow: hidden;
    background: #f3f3f3;
    border-top: 1px solid #ccc;
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    transition: height 0.3s ease;
    display: flex;
    flex-direction: column;
}

    /* Panel visible */
    #filterPanel.open {
        height: 250px;
    }

/* Resize handle */
#filterResizeHandle {
    height: 6px;
    background: #ddd;
    cursor: ns-resize;
}

    #filterResizeHandle:hover {
        background: #ccc;
    }

/* Scrollable content */
.filter-content {
    flex: 1;
    overflow-y: auto;
    /*padding: 12px;*/
}

/* --- Filter panel tabs + close button --- */
.filter-tabs {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #ccc;
    background: #f0f0f0;
    flex-shrink: 0;
    padding: 0 8px;
    gap: 2px;
}

.filter-tab {
    flex: 0;
    padding: 6px 12px;
    cursor: pointer;
    text-align: center;
    border: 1px solid transparent;
    border-bottom: none;
    background: #e8e8e8;
    font-weight: 600;
    color: #444;
    transition: all 0.2s;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    white-space: nowrap;
}

    .filter-tab:hover {
        background: #e0e0e0;
        color: #222;
    }

    .filter-tab.active {
        background: #ffffff;
        border: 1px solid #ccc;
        border-bottom: 1px solid #fff;
        color: #000;
        z-index: 2;
        box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.08) inset;
    }

/* --- Close button aligned to right --- */
#closeFilter {
    margin-left: auto;
    background: none;
    border: none;
    color: #666;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}

    #closeFilter:hover {
        color: #000;
    }

/* --- Tab content containers --- */
.filter-tab-content {
    display: none !important; /* hidden by default */
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    height: 100%;
    box-sizing: border-box;
}

    .filter-tab-content.active {
        display: block !important; /* only active one is visible */
    }

/* === Data Source Tab (with hover tooltip) === */
#dataOptions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1rem;
    margin-bottom: 8px;
}

.data-option {
    position: relative;
    font-size: 0.95rem;
    color: #333;
    cursor: pointer;
}

/* --- Country list --- */
#countryList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 12px;
    width: 100%;
    align-content: start;
    overflow-y: auto;
    flex: 1;
    padding-right: 8px; /* space before scrollbar */
    box-sizing: border-box;
}

    #countryList label {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 0.9rem;
        line-height: 1.2;
        white-space: nowrap;
    }

/* --- Year range sliders --- */
.year-range-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    padding-top: 6px;
}

    .year-range-controls input[type=range] {
        width: 100%;
    }

#yearRangeDisplay {
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 2px;
}

/* --- Dual Range Slider --- */
.year-range-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 6px;
}

/* --- Year range header --- */
.year-range-header {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 4px;
}

    .year-range-header label {
        font-weight: 600;
        font-size: 0.9rem;
        color: #333;
    }

.year-range-display {
    font-weight: 600;
    font-size: 0.9rem;
    color: #0078d7; /* blue accent for current range */
}

/*.dual-slider {
    position: relative;
    width: 100%;
    height: 24px;
}
*/
    .dual-slider input[type="range"] {
        position: absolute;
        left: 0;
        top: 40%;
        width: 100%;
        pointer-events: none;
        -webkit-appearance: none;
        background: none;
        height: 6px;
        margin: 0;
    }

/* Track */
.slider-track {
    position: absolute;
    height: 4px;
    border-radius: 3px;
    background: #ddd;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    z-index: 1;
}

.dual-slider input[type="range"]::-webkit-slider-thumb {
    pointer-events: all;
    position: relative;
    z-index: 2;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: #0078d7;
    border: 1px solid #005fa3;
    cursor: pointer;
    -webkit-appearance: none;
}

.dual-slider input[type="range"]::-moz-range-thumb {
    pointer-events: all;
    position: relative;
    z-index: 2;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: #0078d7;
    border: 1px solid #005fa3;
    cursor: pointer;
}

.dual-slider input[type="range"]::-webkit-slider-runnable-track,
.dual-slider input[type="range"]::-moz-range-track {
    background: transparent;
}

/* Active range highlight */
.slider-range-fill {
    position: absolute;
    height: 4px;
    background: #0078d7;
    border-radius: 3px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

/* --- Dual slider with edge year labels --- */
.dual-slider-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    position: relative;
}

.year-range-edge {
    font-size: 0.85rem;
    color: #555;
    min-width: 30px;
    text-align: center;
}

.dual-slider {
    flex: 1;
    position: relative;
    height: 24px;
    display: flex;
    align-items: center;
}

/* Tick marks for dual year-range slider */
.dual-slider-ticks {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 12px;
    pointer-events: none;
    z-index: 1; /* below handles, above track background */
    display: block;
}

    .dual-slider-ticks div {
        position: absolute;
        width: 2px;
        height: 8px;
        background: #666;
        top: 50%;
        transform: translateY(-50%);
        border-radius: 1px;
    }

