html, body {
    height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    display: flex;
    flex-direction: column;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1001; /* Above map */
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent main from scrolling, handle scroll in children */
    min-height: 0; /* Fix for flexbox scrolling issues */
}

#map {
    flex-basis: 60%;
    flex-shrink: 0;
    width: 100%;
}

.unified-filter-control {
    display: flex;
    align-items: flex-start;
    position: relative;
    right: -280px;
    transition: right 0.3s ease-in-out;
}

.filter-toggle-button {
    width: 35px;
    height: 35px;
    background-color: white;
    color: black;
    text-align: center;
    font-size: 1.5rem;
    line-height: 1.2;
    text-decoration: none;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px 0 0 4px;
    box-shadow: -2px 1px 5px rgba(0,0,0,0.4);
    cursor: pointer;
    z-index: 2;
}

.filter-panel {
    width: 280px;
    max-width: 75vw;
    /* Set a max-height to ensure it doesn't overflow the screen */
    max-height: 70dvh;
    background: white;
    padding: 15px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    box-sizing: border-box;
    border-radius: 0 4px 4px 0;
    overflow-y: auto;
}

/* When the container gets the class, slide the whole control into view */
.unified-filter-control.filters-visible {
    right: 0;
}

/* Styles for new radio button filters */
.filter-group {
    margin-bottom: 10px;
}

.filter-group h4 {
    margin: 0 0 5px 0;
    font-size: 0.9rem;
    font-weight: bold;
}

.radio-options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.radio-options label {
    display: inline-block;
    margin-bottom: 0;
    font-weight: normal;
}

.radio-options input[type="radio"] {
    display: none; /* Hide the actual radio button */
}

.radio-options span {
    display: block;
    padding: 6px 10px;
    background-color: #f2f2f2;
    border: 1px solid #ccc;
    border-radius: 15px; /* More rounded buttons */
    cursor: pointer;
    text-align: center;
    font-size: 0.85rem;
}

.radio-options input[type="radio"]:checked + span {
    background-color: #3498db; /* A lighter, friendly blue */
    color: white;
    border-color: #2980b9;
}

.radio-options span:hover {
    background-color: #e0e0e0;
    border-color: #bbb;
}

.radio-options input[type="radio"]:checked + span:hover {
    background-color: #2980b9;
}

.leaflet-popup-content-wrapper {
    border-radius: 5px;
}

.leaflet-popup-content {
    font-size: 14px;
}

.leaflet-popup-content strong {
    font-weight: bold;
}

#results-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    border-top: 1px solid #ccc;
}

#results-table table {
    width: 100%;
    border-collapse: collapse;
}

#results-table th, #results-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

#results-table th {
    background-color: #f2f2f2;
}

.clickable-row:hover {
    cursor: pointer;
    background-color: #f9f9f9;
}

footer {
    background-color: #34495e;
    color: white;
    text-align: center;
    padding: 1rem;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

footer a {
    color: #1abc9c;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive styles for main layout */
@media (max-width: 768px) {
    main {
        flex-direction: column; /* Map on top, results below */
    }
    #map {
        flex: 1 1 50%; /* flex-grow, flex-shrink, flex-basis */
        min-height: 0; /* Prevents flexbox overflow issues */
    }
    #results-container {
        flex: 1 1 50%;
        min-height: 0; /* Prevents flexbox overflow issues */
        border-top: 1px solid #ccc; /* Ensure border is visible */
    }
    .filter-panel {
        /* On mobile, constrain the height more aggressively */
        max-height: 40dvh;
    }
}
