/* Discharge Map Styles */

/* Leaflet popup close button - ensure always on the right */
.leaflet-popup-close-button,
.leaflet-container .leaflet-popup-close-button,
.leaflet-popup .leaflet-popup-close-button {
    right: 8px !important;
    left: auto !important;
    top: 8px !important;
    position: absolute !important;
}

/* Ensure popup content doesn't overlap with close button */
.leaflet-popup-content-wrapper {
    padding-right: 20px;
}

.leaflet-popup-content {
    margin-right: 10px;
}

/* Modal styles for time series */
.time-series-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
}

.close {
    color: #aaa;
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
}

.chart-container {
    position: relative;
    height: 400px;
    margin-top: 20px;
}

/* Discharge station styles */
.discharge-icon {
    background-color: #ff4444;
    border: 2px solid white;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

/* DEM Legend styles - Updated for image-based legend */
.dem-legend {
    position: absolute;
    bottom: 80px;
    right: 30px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 150px;
    max-width: 200px;
}

.dem-legend h6 {
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
}

.dem-legend img {
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Fallback gradient styles (kept for compatibility) */
.dem-gradient {
    width: 30px;
    height: 120px;
    background: linear-gradient(to top, 
        #006837 0%, 
        #1a9850 10%, 
        #66bd63 20%, 
        #a6d96a 30%, 
        #d9ef8b 40%, 
        #ffffbf 50%, 
        #fee08b 60%, 
        #fdae61 70%, 
        #f46d43 80%, 
        #d73027 90%, 
        #a50026 100%);
    border: 1px solid #ccc;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.dem-gradient-bar {
    width: 100%;
    height: 20px;
    background: linear-gradient(to right, 
        #006837 0%, 
        #1a9850 10%, 
        #66bd63 20%, 
        #a6d96a 30%, 
        #d9ef8b 40%, 
        #ffffbf 50%, 
        #fee08b 60%, 
        #fdae61 70%, 
        #f46d43 80%, 
        #d73027 90%, 
        #a50026 100%);
    border: 1px solid #ccc;
    border-radius: 2px;
    margin: 8px 0;
}

.dem-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
    margin-top: 4px;
}

.dem-label {
    display: block;
    margin: 4px 0;
}

.dem-label:first-child {
    margin-top: 0;
}

.dem-label:last-child {
    margin-bottom: 0;
}

/* Layer control styles */
.layer-controls {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.layer-control-item {
    margin: 10px 0;
}

.layer-control-item input[type="checkbox"] {
    margin-right: 8px;
}

.layer-control-item label {
    margin-bottom: 0;
    cursor: pointer;
}

/* Make control column smaller for better map visibility */
.control-column {
    font-size: 0.9rem;
}

.control-column .form-control {
    font-size: 0.9rem;
}

.control-column .layer-controls {
    font-size: 0.85rem;
}

/* Map container adjustments */
.map-container {
    position: relative;
}

/* Fixed map legend positioning */
.map-legend {
    background: white;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: absolute;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    max-width: 200px;
}

/* Ensure legend stays within map bounds on larger maps */
@media (min-width: 1200px) {
    .map-legend {
        bottom: 40px;
        right: 40px;
    }
    
    .dem-legend {
        bottom: 100px;
        right: 40px;
        max-width: 220px;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 2% auto;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .dem-legend {
        min-width: 120px;
        max-width: 160px;
        padding: 8px;
        bottom: 60px;
        right: 20px;
    }
    
    .dem-legend h6 {
        font-size: 11px;
    }
    
    .dem-legend img {
        max-width: 120px;
    }
    
    .dem-labels {
        font-size: 9px;
    }
    
    .map-legend {
        bottom: 20px;
        right: 20px;
        padding: 10px 14px;
    }
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Icon styles for monitoring stations */
.groundwater-station,
.precipitation-station {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Time series chart styles */
#timeSeriesChart {
    max-height: 400px;
}

/* Status message styles */
.status-message {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.status-message.loading {
    background-color: #d4edda;
    color: #155724;
}

.status-message.success {
    background-color: #d4edda;
    color: #155724;
}

.status-message.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* Legend item styles for consistent formatting */
.legend-item {
    display: flex;
    align-items: center;
    margin: 5px 0;
}

.legend-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
}

/* Hover effects for interactive elements */
.discharge-station:hover {
    transform: scale(1.1);
    transition: transform 0.2s;
}

.layer-control-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    transition: background-color 0.2s;
}

/* Ensure legend image is responsive */
.dem-legend img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}