/* Basic page setup for horizontal layout */
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f0f0f0;
}

/* Horizontal Map Container */
.horizontal-map-container {
    width: 95% !important;
    max-width: 100% !important;
    left: 50%;
    right: 50%;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    position: center;
    aspect-ratio: 16/9;
    min-height: 500px;
    max-height: 900px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

.vertical-map-container {
    width: 100%;
    max-width: 900px;
    margin: 20px auto;
    padding: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    position: relative;
}

/* Map styling optimized for horizontal layout */
#map {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border-radius: 12px;
    position: relative;
    z-index: 1;
}

/* Adjust Leaflet controls for horizontal layout */
.leaflet-control-container .leaflet-top.leaflet-right {
    display: flex;
    flex-direction: column;
    gap: 18px; /* Increased gap to avoid overlap */
    margin-top: 15px;
    margin-right: 15px;
}

.leaflet-control-container .leaflet-bottom.leaflet-left {
    margin-bottom: 15px;
    margin-left: 15px;
}

/* General styling for all control panels - optimized for horizontal view */
.info-panel {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 3px 12px rgba(0,0,0,0.15);
    border-radius: 10px;
    line-height: 1.6;
    max-width: 280px;
    backdrop-filter: blur(10px);
}

.info-panel h4 { 
    margin: 0 0 10px; 
    color: #333; 
    border-bottom: 2px solid #007bff; 
    padding-bottom: 6px;
    font-size: 16px;
}

/* Legend specific styles for horizontal layout */
.legend {
    max-width: 220px; /* Slightly reduced for new layout */
}

.legend .legend-title {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 10px;
    display: block;
    color: #333;
}

.legend .legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    padding: 2px 0;
}

.legend i {
    width: 20px;
    height: 16px;
    margin-right: 10px;
    opacity: 0.9;
    border: 1px solid #777;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend span { 
    font-weight: 500; 
    font-size: 13px;
    color: #333;
}

/* UI Controls styling for horizontal layout */
#ui-main-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 200px;
}

.category-container {
    display: flex;
    flex-direction: column;
    position: relative;
}

.category-container button {
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    text-align: left;
    width: 100%;
    transition: all 0.3s ease;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.category-container button:hover {
    background-color: #f8f9ff;
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.category-container button.active {
    background-color: #007bff;
    color: white;
    border-color: #0056b3;
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

/* Custom Dropdown Styling for horizontal layout */
.attribute-selector-container {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 100%;
    padding: 8px 0;
    margin-top: 6px;
    backdrop-filter: blur(10px);
}

.attribute-selector-container a {
    display: block;
    padding: 10px 16px;
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.attribute-selector-container a:hover {
    background-color: #f0f8ff;
    color: #0056b3;
}

.details-toggle-container {
    padding-top: 12px;
    border-top: 1px solid #eee;
    margin-top: 8px;
}

.details-toggle-container label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.details-toggle-container input {
    margin-right: 8px;
    transform: scale(1.1);
}

/* Popup Styling optimized for horizontal layout */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
}

.leaflet-popup-content {
    font-size: 14px;
    line-height: 1.8;
    margin: 18px 22px !important;
    width: auto !important;
    min-width: 260px;
    max-width: 400px;
}

.popup-header {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 12px;
    border-bottom: 2px solid #007bff;
    padding-bottom: 6px;
}

.popup-hr {
    border: 0;
    height: 1px;
    background: linear-gradient(to right, #eee, #ddd, #eee);
    margin: 12px 0;
}

.popup-category-title {
    font-weight: bold;
    color: #555;
    margin-bottom: 8px;
    font-size: 15px;
}

.popup-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 4px;
}

.popup-row-label {
    color: #666;
    text-align: left;
    font-size: 13px;
}

.popup-row-value {
    font-weight: bold;
    color: #333;
    text-align: right;
    font-size: 14px;
}

/* Responsive design for horizontal layout */
@media (max-width: 768px) {
	.horizontal-map-container {
        /* This rule gives the map a specific height on mobile */
        height: 65vh;
        min-height: 450px;
        width: 95%;
        margin: 20px auto;
        aspect-ratio: unset;
    }

    /* --- COMPACT UI STYLES --- */

    /* Makes the stack of panels in the top-right tighter */
    [id^="map-"] .leaflet-control-container .leaflet-top.leaflet-right {
        gap: 8px;
    }

    /* Further shrinks all control panels */
    [id^="map-"] .info-panel {
        padding: 6px 10px;
        max-width: 170px; /* Narrows the panels */
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }

    /* Shrinks the panel titles */
    [id^="map-"] .info-panel h4 {
        font-size: 13px;
        margin-bottom: 5px;
        padding-bottom: 3px;
    }

    /* Makes the main UI buttons smaller */
    [id^="map-"] .category-container button {
        padding: 6px 10px;    /* Reduced padding */
        font-size: 12px;      /* Reduced font size */
        border-radius: 6px;
    }

    /* Shrinks the checkbox label */
    [id^="map-"] .details-toggle-container label {
        font-size: 11px;
    }

    /* Makes the legend more compact */
    [id^="map-"] .legend {
        max-width: 150px;
    }
    [id^="map-"] .legend .legend-item {
        margin-bottom: 4px;
    }
    [id^="map-"] .legend i {
        width: 15px;
        height: 15px;
        margin-right: 8px;
    }
    [id^="map-"] .legend span {
        font-size: 12px;
    }

    /* Makes the zoom (+/-) buttons smaller */
    [id^="map-"] .leaflet-control-zoom a {
        width: 28px;
        height: 28px;
        line-height: 28px;
    }
}

@media (min-width: 1400px) {
    .horizontal-map-container {
        max-width: 1000px;
        width: 60%;
        max-height: 1200px;
    }
    
    .info-panel {
        max-width: 320px;
        padding: 14px 18px;
    }
    
    .legend {
        max-width: 250px;
    }
    .category-container button {
        font-size: 15px; /* Makes font slightly larger on big screens */
        padding: 12px 16px; /* Increases button size on big screens */
    }
}

/* Additional styling for better horizontal presentation */
.leaflet-control-zoom {
    border-radius: 8px !important;
    box-shadow: 0 3px 12px rgba(0,0,0,0.15) !important;
}

.leaflet-control-zoom a {
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
}

.leaflet-control-zoom a:hover {
    background-color: #f8f9ff !important;
    color: #007bff !important;
}