/**
 * Weather Overlay Styles
 * Visual styles for weather data on map
 */

/* Weather Submenu Popup - Minimalista */
/* Los tokens ya cambian en body.dark-mode: no hace falta repetir cada
   regla para el tema oscuro. */
.weather-submenu-popup .leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-1);
    padding: 16px;
}

.weather-submenu-popup .leaflet-popup-tip {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

/* Geofence Popup - Theme Adaptive */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.leaflet-popup-tip {
    background: var(--bg-secondary);
}

/* Weather menu buttons hover effect */
.weather-menu-btn:hover {
    background: var(--bg-tertiary) !important;
}

/* Weather Marker on Map - Small circles */
.weather-marker-container {
    background: transparent;
    border: none;
}

.weather-marker {
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}

.weather-marker:hover {
    transform: scale(1.2);
}

.weather-icon {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 4px;
}

.weather-temp {
    font-size: 15px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.weather-rain {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--info-text);
    font-weight: 600;
}

/* Weather Panel Overlay */
.weather-panel-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 450px;
    height: 100vh;
    background: var(--bg-primary);
    box-shadow: var(--shadow-2);
    z-index: 10000;
    overflow-y: auto;
    animation: slideInRight 240ms var(--ease);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.weather-panel-header {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.weather-panel-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.1;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}

.close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.weather-panel-body {
    padding: 20px;
}

/* Weather Panel - Theme Adaptive */
.weather-panel {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Weather Sections */
.weather-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}

.weather-section h4 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Weather Stats Grid */
.weather-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.weather-stat {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.stat-icon {
    font-size: 28px;
    display: block;
    margin-bottom: 6px;
}

.stat-value {
    display: block;
    font-size: 20px;
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* Rainfall Summary */
.rainfall-summary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    text-align: center;
}

.rainfall-total {
    margin-bottom: 12px;
}

.big-number {
    font-size: 40px;
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1;
}

.unit {
    font-size: 20px;
    color: var(--text-secondary);
    margin-left: 4px;
}

.rainfall-recommendation {
    font-size: 13px;
    color: var(--text-primary);
    padding: 8px 12px;
    background: var(--info-wash);
    border-radius: 8px;
    border-left: 4px solid var(--info);
}

/* Rainfall Chart */
.rainfall-chart {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.rainfall-bars {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 120px;
    gap: 8px;
}

.rain-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.rain-bar {
    width: 100%;
    background: linear-gradient(180deg, #1890ff 0%, #0050b3 100%);
    border-radius: 4px 4px 0 0;
    position: relative;
    min-height: 4px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 4px;
}

.rain-value {
    font-size: 12px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: #fff;
}

.rain-day {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

/* Soil Moisture Status: el estado va escrito en .status-text; el borde y
   el fondo lo acompanan con los colores de estado de la guia */
.soil-status {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid var(--success);
}

.soil-status.saturated {
    border-color: var(--info);
    background: var(--info-wash);
}

.soil-status.optimal {
    border-color: var(--success);
    background: var(--success-wash);
}

.soil-status.moderate {
    border-color: var(--warning);
    background: var(--warning-wash);
}

.soil-status.low {
    border-color: var(--gold-text);
    background: var(--warning-wash);
}

.soil-status.critical {
    border-color: var(--error);
    background: var(--error-wash);
}

.status-emoji {
    font-size: 32px;
}

.status-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Soil Layers */
.soil-layers-list {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.soil-layer {
    margin-bottom: 12px;
}

.soil-layer:last-child {
    margin-bottom: 0;
}

.layer-name {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.layer-bar {
    background: var(--bg-tertiary);
    height: 24px;
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-bottom: 4px;
}

.layer-fill {
    height: 100%;
    transition: width 250ms var(--ease);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
}

.layer-value {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-weight: 600;
}

/* Irrigation Recommendation: punto clave, borde izquierdo dorado */
.irrigation-rec {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--gold);
}

.irrigation-action {
    margin-bottom: 12px;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--accent-on);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all var(--dur) var(--ease);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

#irrigationResult {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    display: none;
}

#irrigationResult.show {
    display: block;
}

/* Weather Toggle Button - Override geofencing styles */
#weatherToggleBtn {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--accent-primary) !important;
    border-radius: var(--radius-sm) !important;
    padding: 12px 16px !important;
    cursor: pointer !important;
    box-shadow: var(--shadow-1) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    transition: all var(--dur) var(--ease) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

#weatherToggleBtn:hover {
    background: var(--bg-hover) !important;
    border-color: var(--accent-hover) !important;
}

#weatherToggleBtn.active {
    background: var(--accent-primary) !important;
    color: var(--accent-on) !important;
    border-color: var(--accent-primary) !important;
}

#weatherToggleBtn.active:hover {
    background: var(--accent-hover) !important;
    border-color: var(--accent-hover) !important;
}

/* No Data Message */
.no-data {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
    padding: 20px;
}

/* Weather View Selector Buttons */
.weather-view-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.weather-view-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.weather-view-btn.active {
    background: var(--accent-primary);
    color: var(--accent-on);
    border-color: var(--accent-primary);
}


.weather-view-btn i {
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .weather-panel-overlay {
        width: 100%;
    }

    .weather-grid {
        grid-template-columns: 1fr;
    }

    #weatherViewSelector {
        flex-wrap: wrap;
        left: 10px !important;
        right: 10px !important;
        transform: none !important;
    }

    .weather-view-btn {
        flex: 1;
        min-width: 100px;
    }
}

