/* Dark Theme Variables */
:root[data-bs-theme="dark"] {
    --map-height: calc(50vh - 4rem);
    --plot-height: 500px;
}

/* Body */
body {
    background-color: #0d1117;
    color: #c9d1d9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Cards */
.card {
    background-color: #161b22;
    border: 1px solid #30363d;
    padding: 0px;
}

.card-header {
    background-color: rgba(2, 43, 90, 0.61);
    border-bottom: 1px solid #30363d;
}

/* Map */
#map {
    height: var(--map-height);
    width: 100%;
    background-color: #0d1117;
}


/* Controls Panel Toggle */
#toggleControlsBtn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Desktop Controls - Always visible, scrollable sidebar */
@media (min-width: 992px) {
    #controlsPanel {
        display: block !important;
        max-height: calc(50vh - 4rem);;
    }

    /* Make controls card sticky and scrollable on desktop */
    .col-lg-2 .card {
        position: sticky;
        top: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    /* Ensure map has minimum height on desktop */
    #map {
        min-height: 500px;
    }
}

/* Plots */
.chart-container {
    height: 500px;
    width: 100%;
    position: relative;
}

#timeseriesPlot,
#scatterPlot {
    width: 100%;
    height: 100%;
}

/* Card body for time series - full height */
#timeseriesPlot.chart-container {
    height: 100%;
    min-height: 500px;
}

/* Card body for scatter plot needs flex to accommodate stats */
.card-body:has(#scatterPlot) {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

#scatterPlot.chart-container {
    flex: 0 0 400px;
    height: 400px;
}

/* Ensure charts stay on one row for desktop */
@media (min-width: 992px) {
    .chart-container {
        height: 500px;
    }

    #scatterPlot.chart-container {
        flex: 0 0 450px;
        height: 450px;
    }
}

/* Charts Row Spacing */
.row:has(.chart-container) {
    gap: 1rem;
}

/* Better mobile chart rendering */
@media (max-width: 768px) {
    .chart-container {
        height: 400px;
    }

    #timeseriesPlot.chart-container {
        min-height: 400px;
    }

    #scatterPlot.chart-container {
        height: 350px;
        flex: 0 0 350px;
    }

    #statistics {
        font-size: 0.8rem;
    }

    #statistics p {
        font-size: 0.8rem;
    }

    /* Ensure Plotly charts are responsive on mobile */
    .js-plotly-plot .plotly {
        width: 100% !important;
    }

    .js-plotly-plot .plotly .svg-container {
        width: 100% !important;
        height: 100% !important;
    }
}

/* Form Controls */
.form-control,
.form-select {
    background-color: #0d1117;
    border-color: #30363d;
    color: #c9d1d9;
}

.form-control:focus,
.form-select:focus {
    background-color: #0d1117;
    border-color: #58a6ff;
    color: #c9d1d9;
    box-shadow: 0 0 0 0.25rem rgba(88, 166, 255, 0.25);
}

.form-control::placeholder {
    color: #8b949e;
}

/* Checkboxes */
.form-check-input {
    background-color: #0d1117;
    border-color: #30363d;
}

.form-check-input:checked {
    background-color: #58a6ff;
    border-color: #58a6ff;
}

.form-check-input:focus {
    border-color: #58a6ff;
    box-shadow: 0 0 0 0.25rem rgba(88, 166, 255, 0.25);
}

.percentile-checks {
    max-height: 200px;
    overflow-y: auto;
}

.percentile-checks .form-check {
    margin-bottom: 0.5rem;
}

/* Buttons */
#updateBtn, #updateBtnMobile {
    background-color: #2b0eaa;
    border-color: #2b0eaa;
    box-shadow: 0 0 10px rgba(107, 24, 163, 0.5);
    color: #c9d1d9;
}
#updateBtn:hover, #updateBtn:focus, #updateBtnMobile:hover, #updateBtnMobile:focus {
    background-color: #6b18a3;
    border-color: #6b18a3;
    color: #fff;
}

#getCurrentLocationBtn:hover {
    background-color: #2ea043;
    border-color: #2ea043;
}
.btn-primary {
    background-color: #238636;
    border-color: #238636;
}

.btn-primary:hover {
    background-color: #2ea043;
    border-color: #2ea043;
}

.btn-primary:focus {
    box-shadow: 0 0 0 0.25rem rgba(46, 160, 67, 0.5);
}

.btn-outline-primary {
    color: #58a6ff;
    border-color: #58a6ff;
}

.btn-outline-primary:hover {
    background-color: #58a6ff;
    border-color: #58a6ff;
    color: #0d1117;
}

.btn-outline-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Badges */
.badge {
    font-size: 0.875rem;
    padding: 0.5em 1em;
}

/* Station List */
.station-list-item:last-child {
    border-bottom: none !important;
}

#stationListContent {
    line-height: 1.4;
}

#toggleStationListBtn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-color: #30363d;
    color: #8b949e;
}

#toggleStationListBtn:hover {
    background-color: #1c2128;
    border-color: #58a6ff;
    color: #58a6ff;
}

/* Statistics Display */
#statistics {
    background-color: transparent !important;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 1rem;
    padding: 0 !important;
}

#statistics .card {
    background-color: #0d1117;
    border: 1px solid #30363d;
    padding: 0.75rem;
    margin: 0;
}

#statistics p {
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

#statistics strong {
    color: #58a6ff;
}

#statistics h6 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

#statistics .row {
    margin: 0;
}

#statistics .row > [class*="col-"] {
    padding: 0 0.5rem;
}

/* Navbar */
.navbar {
    border-bottom: 1px solid #30363d;
}

.navbar-brand {
    font-weight: 600;
    color: #58a6ff !important;
}

/* Footer */
footer {
    margin-top: 3rem !important;
    padding-top: 2rem;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0d1117;
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}
.legend{
    max-height:100px;
}
/* Leaflet Dark Theme Overrides */
.leaflet-container {
    background-color: #0d1117;
}

.leaflet-popup-content-wrapper {
    background-color: #161b22;
    color: #c9d1d9;
    border: 1px solid #30363d;
}

.leaflet-popup-tip {
    background-color: #161b22;
}

.leaflet-control-layers {
    background-color: #161b22;
    border: 1px solid #30363d;
}

.leaflet-control-layers-expanded {
    color: #c9d1d9;
}

.leaflet-bar a {
    background-color: #161b22;
    border-bottom: 1px solid #30363d;
    color: #c9d1d9;
}

.leaflet-bar a:hover {
    background-color: #1c2128;
}

/* Leaflet.draw Dark Theme */
.leaflet-draw-toolbar a {
    background-color: #161b22 !important;
    border-bottom: 1px solid #30363d !important;
    color: #c9d1d9 !important;
}

.leaflet-draw-toolbar a:hover {
    background-color: #1c2128 !important;
}

.leaflet-draw-actions a {
    background-color: #161b22;
    color: #c9d1d9;
    border: 1px solid #30363d;
}

.leaflet-draw-actions a:hover {
    background-color: #1c2128;
}

.leaflet-draw-tooltip {
    background-color: #161b22;
    border: 1px solid #30363d;
    color: #c9d1d9;
}

.leaflet-draw-tooltip-single {
    background-color: #161b22;
    color: #c9d1d9;
}

.leaflet-draw-tooltip-subtext {
    color: #8b949e;
}

/* User Location Marker */
.user-location-marker {
    background: transparent;
    border: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    :root[data-bs-theme="dark"] {
        --map-height: 400px;
        --plot-height: 400px;
    }

    .card-body {
        padding: 0.75rem;
    }

    h5 {
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    :root[data-bs-theme="dark"] {
        --map-height: 350px;
        --plot-height: 350px;
    }

    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Loading States */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Date Inputs */
input[type="date"] {
    color-scheme: dark;
}

/* Range Sliders */
.form-range {
    height: 0.5rem;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0;
}

.form-range::-webkit-slider-runnable-track {
    height: 0.5rem;
    background-color: #30363d;
    border-radius: 0.25rem;
}

.form-range::-moz-range-track {
    height: 0.5rem;
    background-color: #30363d;
    border-radius: 0.25rem;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    background-color: #58a6ff;
    border-radius: 50%;
    cursor: grab;
    margin-top: -0.375rem;
    border: 3px solid #161b22;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    transition: all 0.15s ease;
}

.form-range::-moz-range-thumb {
    width: 1.25rem;
    height: 1.25rem;
    background-color: #58a6ff;
    border-radius: 50%;
    cursor: grab;
    border: 3px solid #161b22;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    transition: all 0.15s ease;
}

.form-range:active::-webkit-slider-thumb {
    cursor: grabbing;
    transform: scale(1.1);
}

.form-range:active::-moz-range-thumb {
    cursor: grabbing;
    transform: scale(1.1);
}

.form-range::-webkit-slider-thumb:hover {
    background-color: #79c0ff;
    box-shadow: 0 2px 6px rgba(88, 166, 255, 0.6);
}

.form-range::-moz-range-thumb:hover {
    background-color: #79c0ff;
    box-shadow: 0 2px 6px rgba(88, 166, 255, 0.6);
}

.form-range:focus {
    outline: none;
}

.form-range:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3), 0 2px 4px rgba(0, 0, 0, 0.4);
}

.form-range:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3), 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Dual Range Slider Container */
.dual-range-container {
    position: relative;
    height: 40px;
    margin-bottom: 10px;
}

.range-track {
    position: absolute;
    top: 17px;
    left: 0;
    right: 0;
    height: 6px;
    background-color: #30363d;
    border-radius: 3px;
    pointer-events: none;
}

.range-highlight {
    position: absolute;
    top: 17px;
    height: 6px;
    background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
    border-radius: 3px;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    pointer-events: none;
}

.dual-range-container input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    top: 17px;
    background: transparent;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
}

/* Hide the track for sliders in dual-range */
.dual-range-container input[type="range"]::-webkit-slider-runnable-track {
    background: transparent;
    height: 6px;
}

.dual-range-container input[type="range"]::-moz-range-track {
    background: transparent;
    height: 6px;
}

.dual-range-container input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border: 2px solid #1e293b;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.5);
    transition: all 0.2s ease;
}

.dual-range-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border: 2px solid #1e293b;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.5);
    transition: all 0.2s ease;
}

.dual-range-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.7);
}

.dual-range-container input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.7);
}

/* Plot Container */
.js-plotly-plot {
    background-color: transparent !important;
}

.modebar {
    background-color: transparent !important;
}
