/* Monitor Global — Estilos aislados para WordPress */
#mg-app-root.mg-root {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #0b1120;
    color: #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #1e293b;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    box-sizing: border-box;
}

#mg-app-root *,
#mg-app-root *::before,
#mg-app-root *::after {
    box-sizing: border-box;
}

#mg-app-root .mg-hidden {
    display: none !important;
}

/* Barra superior */
#mg-app-root .mg-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: #0f172a;
    border-bottom: 1px solid #1e293b;
    z-index: 20;
    flex-shrink: 0;
}

#mg-app-root .mg-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

#mg-app-root .mg-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#mg-app-root .mg-brand-text strong {
    font-size: 14px;
    letter-spacing: 0.06em;
    color: #f8fafc;
    white-space: nowrap;
}

#mg-app-root .mg-brand-text span {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mg-app-root .mg-pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: mgPulse 2s infinite;
    flex-shrink: 0;
}

@keyframes mgPulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

#mg-app-root .mg-hud-pills {
    display: flex;
    gap: 8px;
    align-items: center;
}

#mg-app-root .mg-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e293b;
    border: 1px solid #334155;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
}

#mg-app-root .mg-pill-label {
    color: #94a3b8;
    font-size: 11px;
}

#mg-app-root .mg-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

#mg-app-root .mg-btn {
    appearance: none;
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease;
    margin: 0;
}

#mg-app-root .mg-btn:hover {
    background: #334155;
    border-color: #475569;
}

#mg-app-root .mg-btn-primary {
    background: #0284c7;
    border-color: #0369a1;
    color: #ffffff;
}

#mg-app-root .mg-btn-primary:hover {
    background: #0369a1;
}

#mg-app-root .mg-btn-accent {
    background: #0f766e;
    border-color: #115e59;
    color: #ffffff;
}

#mg-app-root .mg-btn-accent:hover {
    background: #115e59;
}

#mg-app-root .mg-btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* Banner de alerta cercana */
#mg-app-root .mg-alert-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #991b1b;
    color: #fef2f2;
    padding: 8px 14px;
    font-size: 13px;
    border-bottom: 1px solid #dc2626;
    z-index: 19;
}

#mg-app-root .mg-alert-close {
    background: transparent;
    border: none;
    color: #fef2f2;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

/* Workspace */
#mg-app-root .mg-workspace {
    position: relative;
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#mg-app-root .mg-map-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 100%;
}

#mg-app-root .mg-map {
    width: 100%;
    height: 100%;
    background: #090d16;
    z-index: 1;
}

/* Controles flotantes sobre mapa */
#mg-app-root .mg-flybar {
    position: absolute;
    bottom: 16px;
    left: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    z-index: 500;
}

#mg-app-root .mg-chip {
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 999px;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(6px);
}

#mg-app-root .mg-chip:hover,
#mg-app-root .mg-chip-active {
    background: #0284c7;
    border-color: #38bdf8;
    color: #fff;
}

#mg-app-root .mg-radar-bar {
    position: absolute;
    top: 12px;
    left: 52px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid #334155;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 500;
}

/* Panel lateral */
#mg-app-root .mg-panel {
    width: 320px;
    max-width: 100%;
    background: #0f172a;
    border-left: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    z-index: 600;
    transition: transform 0.25s ease, width 0.25s ease;
    flex-shrink: 0;
}

#mg-app-root .mg-panel.mg-panel-collapsed {
    width: 0;
    border-left: none;
    overflow: hidden;
}

#mg-app-root .mg-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #1e293b;
    gap: 8px;
}

#mg-app-root .mg-tabs {
    display: flex;
    flex: 1;
    gap: 4px;
    background: #1e293b;
    padding: 3px;
    border-radius: 8px;
}

#mg-app-root .mg-tab {
    flex: 1;
    background: transparent;
    color: #94a3b8;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

#mg-app-root .mg-tab-active {
    background: #0284c7;
    color: #ffffff;
}

#mg-app-root .mg-tab-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

#mg-app-root .mg-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 700;
    margin: 12px 0 8px 0;
}

#mg-app-root .mg-section-title:first-child {
    margin-top: 0;
}

#mg-app-root .mg-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    user-select: none;
}

#mg-app-root .mg-toggle input[type="checkbox"] {
    margin: 0;
    accent-color: #38bdf8;
    width: 15px;
    height: 15px;
}

#mg-app-root .mg-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

#mg-app-root .mg-toggle-text {
    flex: 1;
    font-size: 13px;
    color: #f1f5f9 !important;
}

#mg-app-root .mg-count {
    background: #0f172a;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
}

#mg-app-root .mg-subcontrol {
    padding: 6px 10px 10px 10px;
    font-size: 12px;
    color: #cbd5e1 !important;
}

#mg-app-root .mg-subcontrol label {
    color: #cbd5e1 !important;
    font-weight: 500;
}

#mg-app-root .mg-subcontrol strong {
    color: #f8fafc !important;
}

#mg-app-root .mg-subcontrol input[type="range"] {
    width: 100%;
    margin-top: 4px;
    accent-color: #38bdf8;
}

#mg-app-root .mg-basemap-row {
    display: flex;
    gap: 6px;
}

/* Lista de eventos */
#mg-app-root .mg-search-box input {
    width: 100%;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    margin-bottom: 10px;
}

#mg-app-root .mg-event-item {
    background: #1e293b;
    border: 1px solid #334155;
    border-left: 4px solid #38bdf8;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

#mg-app-root .mg-event-item:hover {
    background: #273549;
}

#mg-app-root .mg-event-title {
    font-weight: 600;
    font-size: 13px;
    color: #f8fafc;
    margin-bottom: 3px;
}

#mg-app-root .mg-event-meta {
    font-size: 11px;
    color: #94a3b8;
}

/* Inspector de clima */
#mg-app-root .mg-climate-hint {
    background: rgba(2, 132, 199, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    color: #bae6fd;
    margin-bottom: 10px;
}

#mg-app-root .mg-climate-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 12px;
}

#mg-app-root .mg-climate-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

#mg-app-root .mg-metric {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px;
}

#mg-app-root .mg-metric span {
    display: block;
    font-size: 11px;
    color: #94a3b8;
}

#mg-app-root .mg-metric strong {
    font-size: 15px;
    color: #f8fafc;
}

#mg-app-root .mg-muted {
    color: #94a3b8;
    font-size: 12px;
    margin: 0;
}

#mg-app-root .mg-only-mobile {
    display: none;
}

/* Popups Leaflet en modo oscuro */
#mg-app-root .leaflet-popup-content-wrapper,
#mg-app-root .leaflet-popup-tip {
    background: #0f172a;
    color: #f1f5f9;
    border: 1px solid #334155;
}

#mg-app-root .leaflet-popup-content a {
    color: #38bdf8;
}

/* Responsive móvil */
@media (max-width: 768px) {
    #mg-app-root .mg-hide-mobile {
        display: none !important;
    }
    #mg-app-root .mg-only-mobile {
        display: inline-block;
    }
    #mg-app-root .mg-panel {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 86%;
        max-width: 340px;
        transform: translateX(0);
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.55);
    }
    #mg-app-root .mg-panel.mg-panel-collapsed {
        width: 86%;
        transform: translateX(105%);
    }
    #mg-app-root .mg-flybar {
        bottom: 24px;
        left: 8px;
        right: 8px;
    }
}
