:root {
    --primary-color: #333;
    --accent-color: #333;
    /* Darker accent for map controls */
    --accent-active: #000;
    --bg-color: #ffffff;
    --text-color: #333333;
    --control-bg: #ffffff;
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    --radius: 4px;
    /* Slightly sharper styling like typical map controls */
}

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

body,
html {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Discrete Map Controls */
.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    /* Let clicks pass through empty space */
}

.control-group {
    background: transparent;
    pointer-events: auto;
    /* Re-enable pointer events for controls */
}

.segmented-control {
    display: flex;
    background: var(--control-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2px;
    overflow: hidden;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: #555;
    transition: all 0.2s ease;
    border-radius: 2px;
    text-align: center;
    user-select: none;
}

.segmented-control label:hover {
    color: #000;
    background-color: #f5f5f5;
}

.segmented-control input[type="radio"]:checked+label {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Specific adjustments for Leaflet positioning compatibility */
.leaflet-top.leaflet-right {
    top: 90px;
    /* Move default controls down if needed */
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .map-controls {
        top: auto;
        bottom: 25px;
        /* Move to bottom on mobile for easier reach */
        right: 10px;
        left: 10px;
        flex-direction: row;
        justify-content: center;
    }

    .control-group {
        flex: 1;
        max-width: 200px;
    }

    .segmented-control {
        width: 100%;
    }

    .segmented-control label {
        flex: 1;
    }
}

/* District Dropdown */
.district-dropdown {
    width: 100%;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background-color: #ffffff;
    /* Solid white background for visibility */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    color: #333333;
    /* Dark text for contrast */
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    /* Dark arrow for contrast */
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s ease;
    outline: none;
}

.district-dropdown:hover,
.district-dropdown:focus {
    border-color: #888;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    background-color: #f9f9f9;
}

.district-dropdown option {
    background: #ffffff;
    color: #333;
    padding: 10px;
}

/* District Specific Colors for Dropdown Text if desired, but white is safer on dark bg */

/* Static District Labels */
.district-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: bold;
    font-size: 14px;
    text-align: center;
    opacity: 0.8;
    /* High transparency as requested */
    white-space: nowrap;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    /* Enhance readability */
}

/* Colors matching lines */
.label-federal {
    color: #722F37 !important;
}

.label-local {
    color: #FF1493 !important;
}

.label-jta-aux {
    color: #B8860B !important;
    /* Darker yellow/Gold for better readability on light backgrounds */
    text-shadow: 1px 1px 1px #000;
    /* Subtle dark shadow to pop against the map */
}

/* Remove default tooltip arrow */
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-top:before {
    display: none !important;
}

/* Section List Container */
.section-list-container {
    background: rgba(255, 255, 255, 0.95);
    /* High opacity for readability */
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    max-height: 300px;
    /* Limit height */
    overflow-y: auto;
    /* Scrollable */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-list-container h4 {
    margin: 0;
    font-size: 14px;
    color: #333;
    text-align: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

#section-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#section-list li {
    padding: 5px 8px;
    background: #f5f5f5;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
    border: 1px solid #eee;
}

#section-list li:last-child {
    margin-bottom: 0;
}

/* Legend Window */
/* Legend Window */
.legend-window {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 8px 15px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90%;
    /* Ensure it doesn't overflow on small screens */
}

.legend-window h4 {
    margin: 0 0 5px 0;
    font-size: 13px;
    color: #333;
    text-align: center;
    border-bottom: none;
    /* Removed border for cleaner horizontal look */
    padding-bottom: 0;
    font-weight: 600;
}

.legend-list {
    display: flex;
    flex-direction: row;
    /* Horizontal */
    gap: 15px;
    flex-wrap: wrap;
    /* Wrap on small screens */
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 12px;
    /* Slightly smaller for horizontal fit */
    color: #333;
    white-space: nowrap;
}

.legend-line {
    width: 18px;
    height: 4px;
    margin-right: 6px;
    display: inline-block;
    border-radius: 2px;
}

.legend-circle {
    width: 12px;
    height: 12px;
    margin-right: 6px;
    display: inline-block;
    border-radius: 50%;
}

/* Mobile check for legend */
@media (max-width: 600px) {
    .legend-window {
        top: 80px;
        /* Moved down to avoid zoom controls */
        width: 90%;
        padding: 5px 10px;
    }

    .legend-list {
        gap: 8px;
    }

    .legend-item {
        font-size: 11px;
    }
}