/* Weather Controls Styling */
.mpfy-weather-controls {
    position: absolute;
    top: 10px;
    right: 20px; /* Match search controls margin from map.css */
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    padding: 10px;
    z-index: 1100; /* Match search/filter controls z-index */
    min-width: 200px;
    font-family: 'Montserrat', sans-serif;
}

.mpfy-weather-controls.mpfy-hidden {
    display: none;
}

/* Toggle arrow - positioned differently based on state */
.mpfy-weather-toggle-arrow {
    font-size: 12.4px;
    cursor: pointer;
    color: #3e5269;
    transition: all 0.2s;
    user-select: none;
    padding: 0;
    line-height: 1;
    position: absolute;
    top: 16px;
    right: 10px;
}

/* When only time adjuster is enabled, position arrow in the header next to refresh button */
.mpfy-weather-controls:not(:has(.mpfy-weather-toggles)) .mpfy-weather-toggle-arrow {
    position: static;
    top: auto;
    right: auto;
}

/* Adjust header spacing when arrow is in the header - keep space-between but arrow floats right */
.mpfy-weather-controls:not(:has(.mpfy-weather-toggles)) .mpfy-weather-playback-header {
    justify-content: space-between;
    gap: 15px; /* 15px gap between items */
}

/* Create a wrapper effect by grouping refresh + arrow together */
.mpfy-weather-controls:not(:has(.mpfy-weather-toggles)) .mpfy-weather-reset-btn {
    margin-left: auto; /* Push to right */
    margin-right: 0;
}

.mpfy-weather-toggle-arrow:hover {
    color: #7ebccb;
}

/* Collapsed state - match search field height */
.mpfy-weather-controls.mpfy-collapsed {
    min-width: auto;
    padding: 0;
    width: 37px;
    height: 39px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px; /* Match search field border-radius */
}

.mpfy-weather-controls.mpfy-collapsed .mpfy-weather-toggle-arrow {
    position: static;
    margin-left: 0; /* Remove margin in collapsed state */
    display: block !important; /* Force arrow to show even when inside hidden content */
}

.mpfy-weather-controls.mpfy-collapsed .mpfy-weather-content {
    display: none !important;
}

/* When no toggles and collapsed, arrow needs to be visible */
.mpfy-weather-controls.mpfy-collapsed:not(:has(.mpfy-weather-toggles)) .mpfy-weather-toggle-arrow {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Layer Toggles Section */
.mpfy-weather-toggles {
    margin-bottom: 0;
}

.mpfy-weather-toggles:last-child {
    margin-bottom: 0;
}

.mpfy-weather-toggles-title {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-right: 24px;
}

.mpfy-weather-layer-toggle {
    display: block;
    padding: 6px 8px;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 3px;
    margin-bottom: 2px;
    font-size: 13px;
    color: #555;
    user-select: none;
    font-weight: normal;
}

.mpfy-weather-layer-toggle:last-child {
    margin-bottom: 0;
}

.mpfy-weather-layer-toggle:hover {
    background: #f5f5f5;
}

.mpfy-weather-layer-toggle.active {
    background: #f0f0f0;
    color: #333;
    font-weight: normal;
}

/* Playback Controls Section */
.mpfy-weather-playback {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

/* Hide divider when toggles section is not present */
.mpfy-weather-controls:not(:has(.mpfy-weather-toggles)) .mpfy-weather-playback {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Add bottom padding when only time adjuster is enabled (but not when collapsed) */
.mpfy-weather-controls:not(:has(.mpfy-weather-toggles)):not(.mpfy-collapsed) {
    padding-bottom: 11px; /* 8px default + 3px extra */
}

.mpfy-weather-playback-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.mpfy-weather-playback-title {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.mpfy-weather-reset-btn {
    background: transparent;
    border: none;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: right;
    cursor: pointer;
    font-size: 18px;
    color: #3e5269;
    padding: 0;
    transition: color 0.2s;
    line-height: 1;
}

.mpfy-weather-reset-btn:hover {
    color: #7fbdca;
}

.mpfy-weather-timeline {
    margin-top: 0;
}

.mpfy-weather-timeline-slider {
    width: calc(100% - 11px);
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    margin: 8px 0 8px 11px;
}

.mpfy-weather-timeline-progress {
    height: 100%;
    background: #7ab9ca;
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s linear;
    position: relative;
}

.mpfy-weather-timeline-progress::after {
    content: '';
    position: absolute;
    right: -5.7px;
    top: 50%;
    transform: translateY(-50%);
    width: 11.4px;
    height: 11.4px;
    background: #3d5773;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: grab;
}

.mpfy-weather-timeline-slider:active .mpfy-weather-timeline-progress::after {
    cursor: grabbing;
}

.mpfy-weather-timeline-label {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    text-align: center;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .mpfy-weather-controls {
        top: 60px;
        right: 10px;
        min-width: 180px;
        padding: 6px;
    }

    .mpfy-weather-toggles-title,
    .mpfy-weather-playback-title {
        font-size: 11px;
    }

    .mpfy-weather-layer-toggle {
        font-size: 12px;
        padding: 5px 6px;
    }
}

/* Position adjustment when search/filters are present - push to left side */
.mpfy-container.has-weather-controls .mpfy-controls-wrap {
    left: 20px;
    right: 229px; /* Make space for weather controls on the right (200px min-width + 20px margin + 9px gap) */
}

/* Remove the default 20px right margin from search controls when weather is enabled */
.mpfy-container.has-weather-controls .mpfy-controls-wrap .mpfy-controls {
    margin-right: 0;
}

/* When weather controls are collapsed, reduce the right margin */
.mpfy-container.has-weather-controls .mpfy-weather-controls.mpfy-collapsed ~ .mpfy-controls-wrap,
.mpfy-container.has-weather-controls:has(.mpfy-weather-controls.mpfy-collapsed) .mpfy-controls-wrap {
    right: 69px; /* Space for collapsed square + margins (40px + 20px + 9px) */
}


/* Weather layer fade transitions */
.leaflet-tile-pane {
    transition: opacity 0.3s ease-in-out;
}
