body {
    margin: 0;
}

.page-wrapper {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#image-container {
    flex: 1;
    height: 100%;
    overflow: hidden;
    cursor: grab;
    background-color: #ffffff;
    transition: background-color 0.3s;
    position: relative;
}

#pannable-image {
    max-width: none;
    transform-origin: 0 0;
    transition: opacity 0.4s ease-in;
    opacity: 0;
}

#marker-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}

.marker {
    position: absolute;
    width: 32px;
    height: 32px;
    background-color: #7f8c8d;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    cursor: pointer;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, opacity 0.2s;
    opacity: var(--marker-opacity, 1);
}

.marker svg {
    width: 18px;
    height: 18px;
    fill: white;
    pointer-events: none;
}

.marker:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

.marker.active {
    transform: translate(-50%, -50%) scale(1.3);
    z-index: 10;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7), 
                0 0 0 8px rgba(0, 150, 255, 0.5);
    animation: pulse 1.5s infinite;
}

.sidebar {
    width: 280px;
    height: 100%;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto;
    transition: background-color 0.3s, color 0.3s;
    flex-shrink: 0;
}

.sidebar-left { background-color: #e9e9e9; color: #333; }
.sidebar-right { background-color: #f4f4f4; color: #333; }

/* --- DARK MODE STYLES --- */
html.dark-mode #image-container { background-color: #111111; }
html.dark-mode .sidebar { background-color: #2c2c2e; color: #f2f2f7; }
html.dark-mode .sidebar button { background-color: #3a3a3c; color: #f2f2f7; border: 1px solid #545458; }
html.dark-mode .sidebar h2 { color: #ffffff; }
html.dark-mode .sidebar label { color: #f2f2f7; }

.sidebar h2 { 
    margin-top: 0;
}
.sidebar button { display: block; width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; background-color: #fff; cursor: pointer; transition: background-color 0.3s; }

#image-container.markers-hidden .marker {
    display: none !important;
}

#legend-list { 
    list-style: none; 
    padding: 0; 
    margin: 0;
}

#legend-list li {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

/* --- NEW STYLES FOR THE LEGEND ICONS --- */
.legend-icon-container {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    /* Center the SVG icon inside */
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0,0,0,0.1);
}

.legend-icon-container svg {
    width: 14px;
    height: 14px;
    fill: white;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7), 
                    0 0 0 8px rgba(0, 150, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7), 
                    0 0 0 14px rgba(0, 150, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7), 
                    0 0 0 8px rgba(0, 150, 255, 0.5);
    }
}

/* --- CUSTOM TOGGLE SWITCH STYLES --- */
/* Hide the default checkbox */
#visibility-toggle {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

/* Style the label to look like a switch track */
label[for="visibility-toggle"] {
    cursor: pointer;
    display: flex;
    align-items: center;
    position: relative;
}

label[for="visibility-toggle"]::before {
    content: '';
    width: 38px;
    height: 20px;
    border-radius: 10px;
    background-color: #555;
    transition: background-color 0.2s ease;
    margin-right: 8px; /* Spacing between switch and text */
}

/* Style the 'thumb' of the switch */
label[for="visibility-toggle"]::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: white;
    left: 2px; /* Initial position */
    top: 2px;
    transition: transform 0.2s ease;
}

/* When the checkbox is checked, move the thumb and change the track color */
#visibility-toggle:checked + label[for="visibility-toggle"]::before {
    background-color: #2ECC71; /* A nice green color for 'on' */
}

#visibility-toggle:checked + label[for="visibility-toggle"]::after {
    transform: translateX(18px);
}

/* --- CUSTOM SCROLLBAR STYLES --- */
/* Works on Chrome, Edge, and Safari */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #2c2c2e; /* Match dark sidebar background */
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* --- MODAL STYLES --- */
#modal-container {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    /* Flexbox to center the modal content */
    align-items: center;
    justify-content: center;
}

#modal-container.open {
    display: flex; /* Shown when 'open' class is added */
}

#modal-content {
    position: relative;
    background-color: #fefefe;
    color: #333;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

html.dark-mode #modal-content {
    background-color: #2c2c2e;
    color: #f2f2f7;
}

#modal-close {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

#modal-close:hover {
    color: #333;
}

html.dark-mode #modal-close:hover {
    color: #fff;
}

#modal-image {
    width: 100%;
    height: auto;
    border-radius: 5px;
    margin-bottom: 15px;
}

/* --- Style for the water warning text --- */
.water-warning {
    color: #E74C3C;
    font-size: 0.8em;
    font-weight: bold;
    margin-top: -5px;
    margin-bottom: 10px;
}

/* --- NEW STYLES FOR TOGGLING MARKERS --- */

/* This class will be added by JavaScript to hide a marker */
.marker.is-hidden {
    display: none !important;
}

/* Style for a legend item when its category is hidden */
#legend-list li.inactive {
    opacity: 0.5;
    text-decoration: line-through;
    transition: opacity 0.2s, text-decoration 0.2s;
}

#legend-list li {
    cursor: pointer; /* Make legend items look clickable */
}

/* --- ISOLATE & IDENTIFY STYLES --- */

/* Style for markers that are NOT selected */
.marker.dimmed {
    opacity: 0.2;
    pointer-events: none; /* Makes them unclickable */
}

/* Style for the selected group of markers */
.marker.highlighted {
    z-index: 11; /* Bring highlighted markers to the front */
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7), 
                0 0 0 8px rgba(255, 215, 0, 0.8); /* White and Gold glow */
}

/* The text label for a marker's name */
.marker-label {
    display: none; /* Hidden by default */
    position: absolute;
    bottom: 125%; /* Position above the marker */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap; /* Prevent name from wrapping to a new line */
    pointer-events: none; /* Label doesn't interfere with clicks */
}

/* Show the label when its parent marker is highlighted */
.marker.highlighted .marker-label {
    display: block;
}

/* Style for the active legend item */
#legend-list li.category-active {
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
}
html.dark-mode #legend-list li.category-active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Style for the new 'Show All' button */
#show-all-btn {
    display: none; /* Hidden by default, shown with JS */
    margin-top: 15px;
    background-color: #2980b9; /* A neutral blue color */
    color: white;
    border-color: #2471a3;
}
html.dark-mode #show-all-btn {
    background-color: #3498db;
    border-color: #2980b9;
}

/* Changes the background to red when the 'attention' class is added */
label[for="visibility-toggle"].attention::before {
    background-color: #E74C3C; /* A noticeable red */
}

/* --- STYLE FOR THE CONTRIBUTE BUTTON --- */
#contribute-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    border: 1px solid #ccc;
    background-color: #1abc9c;
    color: white !important;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    box-sizing: border-box;
    border-radius: 0px;
    font-size: 14px;
}
html.dark-mode #contribute-btn {
    background-color: #16a085;
    border-color: #148f77;
}

/* --- STYLE FOR THE SUPPORT BUTTON --- */
#support-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    border: 1px solid #ccc;
    background-color: #3498db; /* A friendly blue color */
    color: white !important;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    box-sizing: border-box;
    border-radius: 0px;
    font-size: 14px;
}
html.dark-mode #support-btn {
    background-color: #2980b9;
    border-color: #2471a3;
}


/* --- RESPONSIVE STYLES FOR MOBILE --- */
/* By default on all screen sizes, the toggle buttons are hidden */
.sidebar-toggle {
    display: none;
}

/* On screens 800px or smaller, these styles will apply */
@media (max-width: 800px) {
    .page-wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        height: 100vh;
        z-index: 200;
        box-shadow: 0 0 15px rgba(0,0,0,0.3);
        transition: transform 0.3s ease-out;
    }

    .sidebar-left {
        left: 0;
        transform: translateX(-100%);
    }
    .sidebar-right {
        right: 0;
        transform: translateX(100%);
    }

    .sidebar-left.open {
        transform: translateX(0);
    }
    .sidebar-right.open {
        transform: translateX(0);
    }
    
    /* This rule correctly overrides the default and shows the buttons */
    .sidebar-toggle {
        display: block; 
        position: fixed;
        z-index: 150;
        top: 10px;
        background-color: rgba(44, 62, 80, 0.8);
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.5);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        font-size: 20px;
        cursor: pointer;
        line-height: 36px;
    }

    #left-sidebar-toggle {
        left: 10px;
    }
    #right-sidebar-toggle {
        right: 10px;
    }
}

/* Hide toggle buttons on desktop by default */
.sidebar-toggle {
    display: none;
}

/* On screens 800px or less, show the buttons and hide sidebars */
@media (max-width: 800px) {
    .page-wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        height: 100vh;
        z-index: 200;
        box-shadow: 0 0 15px rgba(0,0,0,0.3);
        transition: transform 0.3s ease-out;
    }

    .sidebar-left {
        left: 0;
        transform: translateX(-100%);
    }
    .sidebar-right {
        right: 0;
        transform: translateX(100%);
    }

    .sidebar-left.open {
        transform: translateX(0);
    }
    .sidebar-right.open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block; /* This now correctly overrides the default 'none' */
        position: fixed;
        z-index: 150;
        top: 10px;
        background-color: rgba(44, 62, 80, 0.8);
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.5);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        font-size: 20px;
        cursor: pointer;
        line-height: 36px;
    }
    #left-sidebar-toggle {
        left: 10px;
    }
    #right-sidebar-toggle {
        right: 10px;
    }
}