.rs-map-wrapper {
    position: relative;
}

/* --- Corrected Click to Zoom Overlay --- */
.rs-map-zoom-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: bold;
    z-index: 1001;
    cursor: pointer;
    text-shadow: 0 0 5px rgba(0,0,0,0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

/* A11y: Focus styles for overlay */
.rs-map-zoom-overlay:focus {
    outline: 2px solid #fff;
    outline-offset: -5px;
    opacity: 1;
}

/* --- Modern Controls --- */
.leaflet-bar a, 
.leaflet-bar button,
.rs-map-control-btn {
    background-color: #fff !important;
    border: none !important;
    color: #333 !important;
    font-size: 1.2em !important;
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    text-align: center;
    border-radius: 4px !important;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    padding: 0;
}

.leaflet-bar a:hover, 
.leaflet-bar button:hover,
.rs-map-control-btn:hover {
    background-color: #f4f4f4 !important;
    color: #000 !important;
}

/* A11y: Visible Focus State */
.leaflet-bar a:focus,
.leaflet-bar button:focus,
.rs-map-control-btn:focus {
    outline: 2px solid #000;
    z-index: 1002;
    position: relative;
}

.leaflet-control-layers {
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.leaflet-bar {
    border-radius: 4px;
    box-shadow: none;
    border: none;
}

.leaflet-bar > *:not(:last-child) {
    border-bottom: 1px solid #ddd !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.leaflet-bar > *:first-child {
    border-top-left-radius: 4px !important;
    border-top-right-radius: 4px !important;
}

.leaflet-bar > *:last-child {
    border-bottom-left-radius: 4px !important;
    border-bottom-right-radius: 4px !important;
    border-bottom: none !important;
}

.leaflet-control-layers-toggle {
    background-image: none !important;
    width: 30px !important;
    height: 30px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.leaflet-control-layers-toggle::after {
    content: "☰";
    font-size: 1.1em;
    color: #333;
    line-height: 30px;
}

/* --- Theme Switcher Specific --- */
.rs-map-theme-switcher {
    position: relative;
}

.rs-theme-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    list-style: none;
    padding: 0;
    min-width: 150px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
}

.rs-theme-dropdown.rsm-show {
    display: block;
}

.rs-theme-dropdown li {
    margin: 0;
    padding: 0;
}

.rs-theme-dropdown li button {
    background: none;
    border: none;
    padding: 8px 12px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    display: block;
    color: #333;
    font-size: 14px;
    white-space: nowrap;
}

.rs-theme-dropdown li button:hover {
    background-color: #f0f0f0;
}

/* --- Ward Map Specific --- */
.rs-maps-ward-search {
    position: absolute;
    top: 10px;
    left: 50px;
    z-index: 1000;
    display: flex;
    gap: 5px;
    align-items: center;
    background-color: #fff;
    padding: 5px;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.rs-maps-ward-search-input {
    border: 1px solid #ccc;
    padding: 0 8px;
    height: 30px;
    border-radius: 2px;
}

.rs-maps-ward-search-button {
    background-color: #007cba;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 2px;
    cursor: pointer;
    height: 30px;
}

.rs-maps-ward-search-button:hover {
    background-color: #005a87;
}

.rs-maps-ward-confirmation {
    padding-left: 10px;
    font-size: 0.9em;
    font-style: italic;
    display: none;
}

.leaflet-tooltip.ward-label {
    background-color: transparent;
    border: none;
    box-shadow: none;
    color: #000;
    font-weight: bold;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}

.ward-polygon {
    backdrop-filter: blur(5px);
    stroke-linejoin: round;
    stroke-linecap: round;
}

.ward-polygon path {
    stroke-width: 5px;
    stroke-opacity: 0.8;
}

/* --- Fullscreen --- */
.rs-map-wrapper.rs-map-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.rs-map-wrapper.rs-map-fullscreen .rs-map-container {
    height: 100% !important;
}

/* --- Legacy Styles (Retained for compatibility) --- */
.rs-maps-ward-map-interactive-wrapper {
    display: flex;
    gap: 20px;
}
.rs-maps-ward-map-interactive-wrapper .rs-map-wrapper {
    flex-grow: 1;
}
.rs-maps-ward-list-wrapper {
    width: 300px;
    flex-shrink: 0;
}
.rs-maps-ward-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.rs-maps-ward-list li button {
    display: block;
    width: 100%;
    padding: 10px 15px;
    border: none;
    background: #fff;
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
}
.rs-maps-ward-list li:last-child button {
    border-bottom: none;
}
.rs-maps-ward-list li button:hover {
    background-color: #f9f9f9;
}
.rs-maps-ward-list li.active button {
    background-color: #007cba;
    color: #fff;
    font-weight: bold;
}
.rs-maps-ward-search-result {
    padding: 10px 15px;
    background-color: #f0f6fc;
    border-top: 1px solid #ddd;
    font-size: 0.9em;
    color: #333;
}

@media screen and (max-width: 782px) {
    .rs-maps-ward-map-interactive-wrapper {
        flex-direction: column;
    }
    .rs-maps-ward-list-wrapper {
        width: 100%;
    }
    .rs-maps-ward-search {
        left: 10px;
    }
}

/* --- Map Theme CSS Filters (Frontend) --- */
/* CRITICAL FIX: Filter ONLY the tile pane (map background) to preserve boundary colors and fix Chrome GPU dropouts */
.rsm-theme-dark .leaflet-tile-pane {
    -webkit-filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%) !important;
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%) !important;
}

.rsm-theme-high-contrast {
    background-color: #000 !important;
}

.rsm-theme-high-contrast .leaflet-tile-pane {
    -webkit-filter: grayscale(100%) contrast(300%) invert(100%) brightness(110%) !important;
    filter: grayscale(100%) contrast(300%) invert(100%) brightness(110%) !important;
}

/* --- Directions HTML5 Modal --- */
.rs-directions-dialog {
    border: none;
    border-radius: 8px;
    padding: 0;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    font-family: inherit;
}
.rs-directions-dialog::backdrop {
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}
.rsm-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}
.rsm-dialog-header h3 {
    margin: 0;
    font-size: 1.2rem;
}
.rsm-dialog-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
}
.rsm-dialog-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.rsm-dialog-body input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}
.rsm-dialog-body button {
    padding: 10px;
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
}
.rsm-dialog-body hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 5px 0;
}
#rsm-btn-mylocation {
    background: #fff;
    color: #007cba;
    border: 1px solid #007cba;
}
#rsm-btn-mylocation:hover {
    background: #f0f6fc;
}

/* Routing Sliding Panel Modernization */
.leaflet-routing-container {
    background-color: #fff !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
    padding: 15px !important;
    margin: 10px !important;
    max-height: 400px !important;
    overflow-y: auto !important;
    font-family: inherit !important;
    display: none; /* Hidden strictly by default until activated */
}
.leaflet-routing-container.rsm-route-active {
    display: block !important;
    animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Icon-based steps override */
.leaflet-routing-alt h2 {
    font-size: 1.2rem !important;
    color: #333 !important;
    margin-bottom: 10px !important;
}
.leaflet-routing-alt table {
    width: 100% !important;
    border-collapse: collapse !important;
}
.leaflet-routing-alt tr {
    border-bottom: 1px solid #f0f0f0 !important;
}
.leaflet-routing-alt td {
    padding: 10px 5px !important;
}
.leaflet-routing-geocoders { display: none !important; }

/* Replace default sprite image with native Unicode icons */
.leaflet-routing-icon {
    background-image: none !important;
    width: 24px !important;
    height: 24px !important;
    display: inline-block !important;
    position: relative !important;
}
.leaflet-routing-icon::before {
    content: "📍"; 
    font-size: 18px;
    line-height: 24px;
    display: block;
    text-align: center;
}
.leaflet-routing-icon-continue::before { content: "⬆️"; }
.leaflet-routing-icon-turn-right::before, .leaflet-routing-icon-bear-right::before { content: "↗️"; }
.leaflet-routing-icon-turn-left::before, .leaflet-routing-icon-bear-left::before { content: "↖️"; }
.leaflet-routing-icon-roundabout::before { content: "🔄"; }
.leaflet-routing-icon-arrive::before { content: "🏁"; }

.rsm-print-route-btn {
    width: 100%;
    padding: 8px;
    margin-top: 10px;
    cursor: pointer;
    background: #f0f6fc;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-weight: 500;
}
.rsm-print-route-btn:hover { background: #e0f0ff; }

/* Print Window Magic */
@media print {
    body * { visibility: hidden !important; }
    .leaflet-routing-container, .leaflet-routing-container * {
        visibility: visible !important;
    }
    .leaflet-routing-container {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-height: none !important;
        box-shadow: none !important;
    }
}